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