From cd4e10a1e299a5c5c05a4cba067060134c96f29f Mon Sep 17 00:00:00 2001 From: Graham Knapp <32717635+dancergraham@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:20:26 +0100 Subject: [PATCH 01/10] Add code coverage calculation Add code coverage Add upload to codecov Add badge to readme --- .github/workflows/python-package.yml | 30 +++++++++++++++++++++++++++- README.rst | 4 +++- requirements/test.txt | 1 + tox.ini | 11 ++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ffb96145..18099495 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -125,13 +125,41 @@ jobs: run: | sphinx-build -b html docs docs/_build + coverage: + runs-on: ubuntu-latest + needs: test + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: 3.13 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install coverage codecov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run coverage + run: | + coverage run --source=waffle -m pytest + coverage report + coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + flags: unittests + name: codecov-umbrella + release-production: # Only upload if a tag is pushed (otherwise just build & check) if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest - needs: [test, lint, i18n, docs] + needs: [test, lint, i18n, docs, coverage] steps: - uses: actions/checkout@v4 diff --git a/README.rst b/README.rst index d4e18c6a..f5a4e78f 100644 --- a/README.rst +++ b/README.rst @@ -18,7 +18,9 @@ a number of ways. .. image:: https://img.shields.io/readthedocs/waffle :target: https://app.readthedocs.org/projects/waffle :alt: Read the Docs - +.. image:: https://codecov.io/gh/jazzband/django-waffle/branch/master/graph/badge.svg + :target: https://codecov.io/gh/jazzband/django-waffle + :alt: Codecov :Code: https://github.com/jazzband/django-waffle :License: BSD; see LICENSE file diff --git a/requirements/test.txt b/requirements/test.txt index 0b86f4f4..f9b8c7ef 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,2 +1,3 @@ ruff tox +coverage diff --git a/tox.ini b/tox.ini index 08ed5c20..dc0e79be 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py{311}-django{42,50,51} py{312}-django{42,50,51} py{313}-django{51} + coverage isolated_build = True [gh-actions] @@ -42,3 +43,13 @@ deps = -r{toxinidir}/requirements.txt commands = ./run.sh typecheck + +[testenv:coverage] +deps = + coverage + Django>=4.2,<5.2 + -r{toxinidir}/requirements.txt +commands = + coverage run --source=waffle ./run.sh test + coverage report + coverage html From b6fa870d8db58bf21c7dc282f62884d5dabb875a Mon Sep 17 00:00:00 2001 From: Graham Knapp <32717635+dancergraham@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:38:27 +0100 Subject: [PATCH 02/10] fix: test command --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 18099495..5d56f224 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -142,7 +142,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run coverage run: | - coverage run --source=waffle -m pytest + coverage run --source=waffle ./run.sh test coverage report coverage xml - name: Upload coverage to Codecov From 21a5e2d57b0f4e1eee99afd9661ca70b9c1d4725 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 14:52:43 +0100 Subject: [PATCH 03/10] fix: coverage calculation in ci --- .github/workflows/python-package.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5d56f224..cd91f53b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -142,16 +142,10 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run coverage run: | - coverage run --source=waffle ./run.sh test - coverage report - coverage xml + coverage run --source=waffle django-admin test waffle + coverage report -m - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml - flags: unittests - name: codecov-umbrella release-production: # Only upload if a tag is pushed (otherwise just build & check) From bf6ffe498025b4c9595639dac27239d9b9957807 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:01:21 +0100 Subject: [PATCH 04/10] fix: coverage calculation in ci --- .github/workflows/python-package.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cd91f53b..36c68981 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -137,8 +137,13 @@ jobs: python-version: 3.13 - name: Install dependencies run: | + python -m venv .venv + source .venv/bin/activate python -m pip install --upgrade pip + python -m pip install -r requirements.txt python -m pip install coverage codecov + export DJANGO_SETTINGS_MODULE="test_settings" + export PYTHONPATH=.".:$PYTHONPATH" if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run coverage run: | From 716bd954e327d825c0e86490d4f35dac4aaaf314 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:05:49 +0100 Subject: [PATCH 05/10] fix: coverage calculation in ci --- .github/workflows/python-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 36c68981..d0fe3d81 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -142,11 +142,11 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements.txt python -m pip install coverage codecov - export DJANGO_SETTINGS_MODULE="test_settings" - export PYTHONPATH=.".:$PYTHONPATH" - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run coverage run: | + source .venv/bin/activate + export DJANGO_SETTINGS_MODULE="test_settings" + export PYTHONPATH=.".:$PYTHONPATH" coverage run --source=waffle django-admin test waffle coverage report -m - name: Upload coverage to Codecov From 0bd6bab0b8fa1c1c536e0e0e73e705ec2fa2742f Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:18:20 +0100 Subject: [PATCH 06/10] fix: coverage calculation in ci --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d0fe3d81..531849ca 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -147,7 +147,7 @@ jobs: source .venv/bin/activate export DJANGO_SETTINGS_MODULE="test_settings" export PYTHONPATH=.".:$PYTHONPATH" - coverage run --source=waffle django-admin test waffle + python -m coverage run --source=waffle django-admin test waffle coverage report -m - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 From deedcbec43cb4d7b96149e14cbdf2bf215583fcb Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:22:14 +0100 Subject: [PATCH 07/10] fix: coverage calculation in ci --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 531849ca..fdf3f1ff 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -147,7 +147,7 @@ jobs: source .venv/bin/activate export DJANGO_SETTINGS_MODULE="test_settings" export PYTHONPATH=.".:$PYTHONPATH" - python -m coverage run --source=waffle django-admin test waffle + python -m coverage run --source=waffle `which django-admin` test waffle coverage report -m - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 From ee695766c0a8cc5049bf7f6be5109335c7cdb239 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:29:02 +0100 Subject: [PATCH 08/10] fix: codecov upload --- .github/workflows/python-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index fdf3f1ff..64818728 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -149,6 +149,8 @@ jobs: export PYTHONPATH=.".:$PYTHONPATH" python -m coverage run --source=waffle `which django-admin` test waffle coverage report -m + coverage html + coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 From 4cbb624005ae96d43ffb6c7f63f5795cde47c6cc Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:35:15 +0100 Subject: [PATCH 09/10] refactor: remove tox for now --- tox.ini | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tox.ini b/tox.ini index dc0e79be..08ed5c20 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,6 @@ envlist = py{311}-django{42,50,51} py{312}-django{42,50,51} py{313}-django{51} - coverage isolated_build = True [gh-actions] @@ -43,13 +42,3 @@ deps = -r{toxinidir}/requirements.txt commands = ./run.sh typecheck - -[testenv:coverage] -deps = - coverage - Django>=4.2,<5.2 - -r{toxinidir}/requirements.txt -commands = - coverage run --source=waffle ./run.sh test - coverage report - coverage html From 14ace256bb4e323288ff5e626f7060f81117ba77 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 18 Jan 2025 15:59:04 +0100 Subject: [PATCH 10/10] refactor: remove unneeded dependency --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 64818728..ae2129e5 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -141,7 +141,7 @@ jobs: source .venv/bin/activate python -m pip install --upgrade pip python -m pip install -r requirements.txt - python -m pip install coverage codecov + python -m pip install coverage - name: Run coverage run: | source .venv/bin/activate