Skip to content

Commit

Permalink
Add workflow steps to upload dummy db artifact for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed Nov 25, 2024
1 parent d23cbcb commit 8f3afcf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/reusable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
- name: Validate integrity of fixtures
run: make load-dummy-data

- name: Dump db
# if: ${{ inputs.event_name == 'push' || github.event_name == 'push' }}
run: make dump-db

- name: Run tests
run: make test-coverage

Expand All @@ -76,3 +80,13 @@ jobs:
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Pipfile.lock', 'docker/dev.Dockerfile') }}

- name: Upload db artifact
# if: ${{ inputs.event_name == 'push' || github.event_name == 'push' }}
uses: actions/upload-artifact@v4
with:
name: care-db-dump
path: care_db.dump
retention-days: 30
compression-level: 0 # file is already compressed
overwrite: true # keep only the last artifact
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,5 @@ secrets.sh
*.rdb

jwks.b64.txt

care_db.dump
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ checkmigration:
makemigrations:
docker compose exec backend bash -c "python manage.py makemigrations"

migrate:
docker compose exec backend bash -c "python manage.py migrate"

test:
docker compose exec backend bash -c "python manage.py test --keepdb --parallel --shuffle"

Expand All @@ -48,9 +51,16 @@ test-coverage:
docker compose exec backend bash -c "coverage combine || true; coverage xml"
docker compose cp backend:/app/coverage.xml coverage.xml

reset_db:
dump-db:
docker compose exec db sh -c "pg_dump -U postgres -Fc care > /tmp/care_db.dump"
docker compose cp db:/tmp/care_db.dump care_db.dump

load-db:
docker compose cp care_db.dump db:/tmp/care_db.dump
docker compose exec db sh -c "pg_restore -U postgres -d care /tmp/care_db.dump"

reset-db:
docker compose exec backend bash -c "python manage.py reset_db --noinput"
docker compose exec backend bash -c "python manage.py migrate"

ruff-all:
ruff check .
Expand Down

0 comments on commit 8f3afcf

Please sign in to comment.