Skip to content

Commit

Permalink
Fix GitHub workflow (#14)
Browse files Browse the repository at this point in the history
* add lint dependency for django_app_test

* add coverage test in github workflow

* change secret_key import to full import

* fix dependency on django_app_test

* add codecov config

* fix import error core module
  • Loading branch information
danangmassandy authored Jun 26, 2024
1 parent 877ec2d commit 80cb1b0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
django_app_test:
needs: flake8_py3
name: 'Django App'
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -64,7 +65,10 @@ jobs:
cd ../
make dev
make wait-db
make dev-entrypoint
make sleep
make migrate
make npm-install
make build-react
make dev-runserver
make dev-load-demo-data
make sleep
Expand Down Expand Up @@ -92,5 +96,22 @@ jobs:
# path: playwright/ci-test/playwright-report/
# retention-days: 30

- name: Test backend
run: make dev-test
- name: Run Coverage test
working-directory: deployment
run: |
cat << EOF | docker-compose exec -T dev bash
python manage.py collectstatic --noinput --verbosity 0
export DJANGO_SETTINGS_MODULE=core.settings.dev && coverage run manage.py test && coverage xml
EOF
docker cp dev:/home/web/django_project/coverage.xml ../coverage.xml
- name: Show Coverage
if: ${{ github.event_name == 'pull_request' }}
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ dev-test:
@docker-compose exec -T dev python manage.py collectstatic --noinput
@docker-compose exec -T dev python manage.py test --keepdb --noinput

npm-install:
@echo
@echo "------------------------------------------------------------------"
@echo "Install frontend dependencies"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} exec -T dev npm --prefix /home/web/django_project/frontend install

migrate:
@echo
@echo "------------------------------------------------------------------"
@echo "Running migration"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} exec -T dev python manage.py migrate

build-react:
@echo
@echo "------------------------------------------------------------------"
@echo "Execute webpack build command"
@echo "------------------------------------------------------------------"
@docker-compose ${ARGS} exec -T dev npm --prefix /home/web/django_project/frontend run build

serve:
@echo
@echo "------------------------------------------------------------------"
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
coverage:
range: 50..75
round: down
precision: 2
status:
project:
default:
target: 80
changes: false
patch:
default:
threshold: "5%"
ignore:
- "**/migrations/*.py"
6 changes: 4 additions & 2 deletions django_project/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'core.wsgi.application'

# import SECRET_KEY into current namespace
# noinspection PyUnresolvedReferences
from core.settings.secret import SECRET_KEY # noqa

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand Down Expand Up @@ -144,5 +148,3 @@

LOGIN_URL = '/account/login/'
LOGIN_REDIRECT_URL = '/'

from .secret import SECRET_KEY # noqa

0 comments on commit 80cb1b0

Please sign in to comment.