Skip to content

🚚 Move location of scripts to simplify file structure #1352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions backend/prestart.sh → backend/scripts/prestart.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions backend/scripts/tests-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /usr/bin/env bash
set -e
set -x

python app/tests_pre_start.py

bash scripts/test.sh "$@"
7 changes: 0 additions & 7 deletions backend/tests-start.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ services:
db:
condition: service_healthy
restart: true
command: bash prestart.sh
command: bash scripts/prestart.sh
env_file:
- .env
environment:
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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