diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5849d19749..1874f6886b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,9 +26,9 @@ jobs: - run: docker compose down -v --remove-orphans - run: docker compose up -d - name: Lint - run: docker compose exec -T backend bash /app/scripts/lint.sh + run: docker compose exec -T backend bash scripts/lint.sh - name: Run tests - run: docker compose exec -T backend bash /app/tests-start.sh "Coverage for ${{ github.sha }}" + run: docker compose exec -T backend bash scripts/tests-start.sh "Coverage for ${{ github.sha }}" - run: docker compose down -v --remove-orphans - name: Store coverage files uses: actions/upload-artifact@v4 diff --git a/backend/Dockerfile b/backend/Dockerfile index 716aa231ad..29331dc712 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -17,14 +17,10 @@ RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; els ENV PYTHONPATH=/app -COPY ./scripts/ /app/ +COPY ./scripts /app/scripts COPY ./alembic.ini /app/ -COPY ./prestart.sh /app/ - -COPY ./tests-start.sh /app/ - COPY ./app /app/app CMD ["fastapi", "run", "--workers", "4", "app/main.py"] diff --git a/backend/README.md b/backend/README.md index e7782d43e6..b7a77bd48d 100644 --- a/backend/README.md +++ b/backend/README.md @@ -106,15 +106,15 @@ If you use GitHub Actions the tests will run automatically. If your stack is already up and you just want to run the tests, you can use: ```bash -docker compose exec backend bash /app/tests-start.sh +docker compose exec backend bash scripts/tests-start.sh ``` -That `/app/tests-start.sh` script just calls `pytest` after making sure that the rest of the stack is running. If you need to pass extra arguments to `pytest`, you can pass them to that command and they will be forwarded. +That `/app/scripts/tests-start.sh` script just calls `pytest` after making sure that the rest of the stack is running. If you need to pass extra arguments to `pytest`, you can pass them to that command and they will be forwarded. For example, to stop on first error: ```bash -docker compose exec backend bash /app/tests-start.sh -x +docker compose exec backend bash scripts/tests-start.sh -x ``` ### Test Coverage diff --git a/backend/prestart.sh b/backend/scripts/prestart.sh similarity index 61% rename from backend/prestart.sh rename to backend/scripts/prestart.sh index fc1e5f1890..ee1f5e252f 100644 --- a/backend/prestart.sh +++ b/backend/scripts/prestart.sh @@ -1,10 +1,10 @@ #! /usr/bin/env bash # Let the DB start -python /app/app/backend_pre_start.py +python app/backend_pre_start.py # Run migrations alembic upgrade head # Create initial data in DB -python /app/app/initial_data.py +python app/initial_data.py diff --git a/backend/scripts/tests-start.sh b/backend/scripts/tests-start.sh new file mode 100644 index 0000000000..89dcb0da23 --- /dev/null +++ b/backend/scripts/tests-start.sh @@ -0,0 +1,7 @@ +#! /usr/bin/env bash +set -e +set -x + +python app/tests_pre_start.py + +bash scripts/test.sh "$@" diff --git a/backend/tests-start.sh b/backend/tests-start.sh deleted file mode 100644 index e35150c7ae..0000000000 --- a/backend/tests-start.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env bash -set -e -set -x - -python /app/app/tests_pre_start.py - -bash ./scripts/test.sh "$@" diff --git a/docker-compose.yml b/docker-compose.yml index ce92e3e3d7..db168b89cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,7 @@ services: db: condition: service_healthy restart: true - command: bash prestart.sh + command: bash scripts/prestart.sh env_file: - .env environment: diff --git a/scripts/test-local.sh b/scripts/test-local.sh index 4c180f21d3..7f2fa9fbce 100644 --- a/scripts/test-local.sh +++ b/scripts/test-local.sh @@ -12,4 +12,4 @@ fi docker-compose build docker-compose up -d -docker-compose exec -T backend bash /app/tests-start.sh "$@" +docker-compose exec -T backend bash scripts/tests-start.sh "$@" diff --git a/scripts/test.sh b/scripts/test.sh index 73c449a993..6dabef7471 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -7,5 +7,5 @@ set -x docker compose build docker compose down -v --remove-orphans # Remove possibly previous broken stacks left hanging after an error docker compose up -d -docker compose exec -T backend bash /app/tests-start.sh "$@" +docker compose exec -T backend bash scripts/tests-start.sh "$@" docker compose down -v --remove-orphans