Skip to content

Commit

Permalink
Add code coverage calculation
Browse files Browse the repository at this point in the history
Add code coverage
Add upload to codecov
Add badge to readme
  • Loading branch information
dancergraham committed Jan 16, 2025
1 parent 2b70e6b commit cd4e10a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
11 changes: 11 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

0 comments on commit cd4e10a

Please sign in to comment.