diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a417432..bee0c5b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,9 +18,12 @@ jobs: run: docker-compose up -d web - name: Run test suite - run: docker-compose run -T --rm app pytest -v - if: always() + run: docker-compose run -T --rm app pytest -v --cov-report=xml --cov=. - name: Check Migrations are up-to-date run: docker-compose run -T --rm app ./manage.py makemigrations --check - if: always() + + - name: Upload coverage report to codecov + uses: codecov/codecov-action@v1 + with: + file: ./project/coverage.xml diff --git a/README.md b/README.md index f02ce4e1..48e40451 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Django proof-of-concept for CodeBuddies V3 ![Test](https://github.com/codebuddies/django-concept/workflows/Test/badge.svg) +[![codecov](https://codecov.io/gh/codebuddies/backend/branch/master/graph/badge.svg)](https://codecov.io/gh/codebuddies/backend) + + + Background: https://github.com/codebuddies/codebuddies/issues/1136 @@ -104,6 +108,7 @@ docker-compose run --rm app ./manage.py help * We use [pytest](https://docs.pytest.org/en/latest/contents.html) with the [pytest-django](https://pytest-django.readthedocs.io/en/latest/) plugin for running tests. * Please add tests for your code when contributing. * Run the test suite using `docker-compose run --rm app pytest` +* With test coverage report `docker-compose run --rm app pytest --cov-report=term --cov=.` ### Import Postman collection Postman is a free interactive tool for verifying the APIs of your project. You can download it at postman.com/downloads. diff --git a/project/.coveragerc b/project/.coveragerc index 094c2ace..3bf162e6 100644 --- a/project/.coveragerc +++ b/project/.coveragerc @@ -1,5 +1,12 @@ [run] -include = project/* -omit = *migrations*, *tests* +omit = + */apps.py, + */config/*, + */migrations/*, + */tests/*, + */tests.py, + */*.html, + conftest.py, + manage.py, plugins = django_coverage_plugin diff --git a/project/requirements/local.txt b/project/requirements/local.txt index 9af4c30b..7cde2c0c 100644 --- a/project/requirements/local.txt +++ b/project/requirements/local.txt @@ -9,6 +9,7 @@ psycopg2-binary==2.8.3 # https://github.com/psycopg/psycopg2 # ------------------------------------------------------------------------------ mypy==0.720 # https://github.com/python/mypy pytest==5.1.1 # https://github.com/pytest-dev/pytest +pytest-cov==2.8.1 # https://github.com/pytest-dev/pytest-cov pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar # Code quality