Skip to content

Commit f5fd6fc

Browse files
authored
Add code coverage calculation (jazzband#547)
* Add code coverage calculation - Add code coverage - Add upload to codecov - Add badge to readme
1 parent 2b70e6b commit f5fd6fc

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

.github/workflows/python-package.yml

+30-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,42 @@ 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 venv .venv
141+
source .venv/bin/activate
142+
python -m pip install --upgrade pip
143+
python -m pip install -r requirements.txt
144+
python -m pip install coverage
145+
- name: Run coverage
146+
run: |
147+
source .venv/bin/activate
148+
export DJANGO_SETTINGS_MODULE="test_settings"
149+
export PYTHONPATH=.".:$PYTHONPATH"
150+
python -m coverage run --source=waffle `which django-admin` test waffle
151+
coverage report -m
152+
coverage html
153+
coverage xml
154+
- name: Upload coverage to Codecov
155+
uses: codecov/codecov-action@v5
156+
128157
release-production:
129158
# Only upload if a tag is pushed (otherwise just build & check)
130159
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
131160

132161
runs-on: ubuntu-latest
133162

134-
needs: [test, lint, i18n, docs]
163+
needs: [test, lint, i18n, docs, coverage]
135164

136165
steps:
137166
- uses: actions/checkout@v4

README.rst

+3-1
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

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
ruff
22
tox
3+
coverage

0 commit comments

Comments
 (0)