Skip to content
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

Add workflow steps to upload dummy db artifact for tests #2616

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
sainak marked this conversation as resolved.
Show resolved Hide resolved

- 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
sainak marked this conversation as resolved.
Show resolved Hide resolved
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"
sainak marked this conversation as resolved.
Show resolved Hide resolved

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
Loading