Skip to content

Commit cd4e10a

Browse files
committed
Add code coverage calculation
Add code coverage Add upload to codecov Add badge to readme
1 parent 2b70e6b commit cd4e10a

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

.github/workflows/python-package.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,41 @@ jobs:
125125
run: |
126126
sphinx-build -b html docs docs/_build
127127
128+
coverage:
129+
runs-on: ubuntu-latest
130+
needs: test
131+
132+
steps:
133+
- uses: actions/checkout@v4
134+
- name: Set up Python 3.13
135+
uses: actions/setup-python@v5
136+
with:
137+
python-version: 3.13
138+
- name: Install dependencies
139+
run: |
140+
python -m pip install --upgrade pip
141+
python -m pip install coverage codecov
142+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
143+
- name: Run coverage
144+
run: |
145+
coverage run --source=waffle -m pytest
146+
coverage report
147+
coverage xml
148+
- name: Upload coverage to Codecov
149+
uses: codecov/codecov-action@v5
150+
with:
151+
token: ${{ secrets.CODECOV_TOKEN }}
152+
files: ./coverage.xml
153+
flags: unittests
154+
name: codecov-umbrella
155+
128156
release-production:
129157
# Only upload if a tag is pushed (otherwise just build & check)
130158
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
131159

132160
runs-on: ubuntu-latest
133161

134-
needs: [test, lint, i18n, docs]
162+
needs: [test, lint, i18n, docs, coverage]
135163

136164
steps:
137165
- uses: actions/checkout@v4

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ a number of ways.
1818
.. image:: https://img.shields.io/readthedocs/waffle
1919
:target: https://app.readthedocs.org/projects/waffle
2020
:alt: Read the Docs
21-
21+
.. image:: https://codecov.io/gh/jazzband/django-waffle/branch/master/graph/badge.svg
22+
:target: https://codecov.io/gh/jazzband/django-waffle
23+
:alt: Codecov
2224

2325
:Code: https://github.com/jazzband/django-waffle
2426
:License: BSD; see LICENSE file

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
ruff
22
tox
3+
coverage

tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ envlist =
55
py{311}-django{42,50,51}
66
py{312}-django{42,50,51}
77
py{313}-django{51}
8+
coverage
89
isolated_build = True
910

1011
[gh-actions]
@@ -42,3 +43,13 @@ deps =
4243
-r{toxinidir}/requirements.txt
4344
commands =
4445
./run.sh typecheck
46+
47+
[testenv:coverage]
48+
deps =
49+
coverage
50+
Django>=4.2,<5.2
51+
-r{toxinidir}/requirements.txt
52+
commands =
53+
coverage run --source=waffle ./run.sh test
54+
coverage report
55+
coverage html

0 commit comments

Comments
 (0)