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

Adds workflow to test build docker image #461

Merged
merged 3 commits into from
Feb 6, 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
46 changes: 46 additions & 0 deletions .github/workflows/test-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Pipfile.lock', 'compose/local/django/Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Bake docker images
uses: docker/bake-action@v4
with:
load: true
set: |
*.cache-from=type=local,src=/tmp/.buildx-cache
*.cache-to=type=local,dest=/tmp/.buildx-cache-new
files: docker-compose.local.yaml

- name: Start services
run: docker compose -f docker-compose.local.yaml up -d --wait --no-build

- name: Check migrations
run: make checkmigration

# - name: Run tests
# run: make test-coverage

# - name: Upload coverage report
# uses: codecov/codecov-action@v3

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
12 changes: 12 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test PR

on:
pull_request:

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

jobs:
test:
uses: ./.github/workflows/test-base.yaml
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ logs:

makemigrations: up
docker exec django bash -c "python manage.py makemigrations"

checkmigration:
docker compose -f $(docker_config_file) exec django bash -c "python manage.py makemigrations --check --dry-run"

test: up
docker exec django bash -c "python manage.py test --keepdb --parallel=$(nproc)"
Expand Down
2 changes: 1 addition & 1 deletion compose/local/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN pip install pipenv

# Requirements are installed here to ensure they will be cached.
COPY Pipfile Pipfile.lock ./
RUN pipenv sync --system --categories "packages"
RUN pipenv sync --system --categories "packages dev-packages"

# Python 'run' stage
FROM python as python-run-stage
Expand Down
Loading