Skip to content

Commit

Permalink
Add code coverage calculation (#547)
Browse files Browse the repository at this point in the history
* Add code coverage calculation

- Add code coverage
- Add upload to codecov
- Add badge to readme
  • Loading branch information
dancergraham authored Jan 22, 2025
1 parent 2b70e6b commit f5fd6fc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,42 @@ 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 venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install coverage
- name: Run coverage
run: |
source .venv/bin/activate
export DJANGO_SETTINGS_MODULE="test_settings"
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

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
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ruff
tox
coverage

0 comments on commit f5fd6fc

Please sign in to comment.