From 8a726bf8df5cc0a8647069eb48f20d67b7371446 Mon Sep 17 00:00:00 2001 From: chris48s Date: Sun, 29 Mar 2020 14:57:44 +0100 Subject: [PATCH 1/4] config for local coverage reports --- README.md | 1 + project/.coveragerc | 11 +++++++++-- project/requirements/local.txt | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f02ce4e1..33d36692 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,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 From 5e54191d8b1339d35ca8e146cf5bfd8e85b5b629 Mon Sep 17 00:00:00 2001 From: chris48s Date: Sun, 29 Mar 2020 14:58:50 +0100 Subject: [PATCH 2/4] generate coverage file in CI build --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a417432..e17aa0ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: run: docker-compose up -d web - name: Run test suite - run: docker-compose run -T --rm app pytest -v + run: docker-compose run -T --rm app pytest -v --cov-report= --cov=. if: always() - name: Check Migrations are up-to-date From db12818bb15f95a694d1184c53315fe63a2191af Mon Sep 17 00:00:00 2001 From: chris48s Date: Sun, 29 Mar 2020 20:52:00 +0100 Subject: [PATCH 3/4] upload coverage to codecov with codecov-action --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e17aa0ee..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 --cov-report= --cov=. - 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 From 2483ebec77fea4cfa42a5c938a98076e20ba9ec7 Mon Sep 17 00:00:00 2001 From: chris48s Date: Sun, 29 Mar 2020 21:14:59 +0100 Subject: [PATCH 4/4] badge --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 33d36692..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