Skip to content

Commit

Permalink
chore: add unit and integration test checks
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Feb 9, 2024
1 parent 113e787 commit 7f54bfc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Open Prices unit and integration tests

on:
push:
paths:
- "**/app/**"
- "pyproject.toml"
- "poetry.lock"
- "tests/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.11"

steps:
#----------------------------------------------
# check-out repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3

#----------------------------------------------
# Launch checks and tests
#----------------------------------------------
- name: Configure docker
run: |
# ensure a new line for .env file might not have it!
echo "" >> .env
# align user id
echo "USER_UID=$UID" >> .env
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> .env
- name: Launch tests
run: make tests
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ RUN poetry config virtualenvs.create false
ENV POETRY_VIRTUALENVS_IN_PROJECT=false

# create off user
ARG OFF_UID=1000
ARG OFF_GID=$OFF_UID
RUN groupadd -g $OFF_GID off && \
useradd -u $OFF_UID -g off -m off && \
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd -g $USER_GID off && \
useradd -u $USER_UID -g off -m off && \
mkdir -p /home/off && \
mkdir -p /opt/open-prices && \
chown off:off -R /opt/open-prices /home/off
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ docs:
checks: toml-check flake8 black-check mypy isort-check docs


tests: unit-tests integration-tests

unit-tests:
@echo "🥫 Running tests …"
# change project name to run in isolation
Expand Down
2 changes: 1 addition & 1 deletion app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def create_proof_file(file: UploadFile) -> tuple[str, str]:
# if the current directory contains 1000 images, we create a new one
current_dir_id += 1
current_dir = images_dir / str(current_dir_id)
current_dir.mkdir(exist_ok=True)
current_dir.mkdir(exist_ok=True, parents=True)
full_file_path = current_dir / f"{file_stem}{extension}"
# write the content of the file to the new file
with full_file_path.open("wb") as f:
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def override_get_db():
db = session()
yield db
finally:
# close the DB session
db.close()


Expand Down

0 comments on commit 7f54bfc

Please sign in to comment.