Skip to content

Commit 83e3d1c

Browse files
tim-schillingauvipypauloxnet
authored
Remove codecov, solely use coverage. (#1542)
* Remove codecov, solely use coverage. CodeCov has become a bit flaky in their evaluation of code coverage. Using GitHub actions, we can utilize coverage to combine multiple reports. Thanks to Hynek Schlawack for the approach. https://hynek.me/articles/ditch-codecov-python/ Remove .coveragerc file in favor of configuration in setup.cfg Also applies coverage's parallel mode always. * Update setup.cfg Co-authored-by: Paolo Melchiorre <[email protected]> * Update .github/workflows/test.yml Co-authored-by: Paolo Melchiorre <[email protected]> * Update .github/workflows/test.yml Co-authored-by: Paolo Melchiorre <[email protected]> * Update setup.cfg Co-authored-by: Paolo Melchiorre <[email protected]> * Reduce acceptable code coverage percentage. Co-authored-by: Asif Saif Uddin <[email protected]> Co-authored-by: Paolo Melchiorre <[email protected]>
1 parent c27261b commit 83e3d1c

File tree

4 files changed

+65
-16
lines changed

4 files changed

+65
-16
lines changed

.coveragerc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ jobs:
7070
DB_HOST: 127.0.0.1
7171
DB_PORT: 3306
7272

73-
- name: Upload coverage
74-
uses: codecov/codecov-action@v1
73+
- name: Upload coverage data
74+
uses: actions/upload-artifact@v2
7575
with:
76-
name: Python ${{ matrix.python-version }}
76+
name: coverage-data
77+
path: ".coverage.*"
7778

7879
postgres:
7980
runs-on: ubuntu-latest
@@ -138,10 +139,11 @@ jobs:
138139
DB_HOST: localhost
139140
DB_PORT: 5432
140141

141-
- name: Upload coverage
142-
uses: codecov/codecov-action@v1
142+
- name: Upload coverage data
143+
uses: actions/upload-artifact@v2
143144
with:
144-
name: Python ${{ matrix.python-version }}
145+
name: coverage-data
146+
path: ".coverage.*"
145147

146148
sqlite:
147149
runs-on: ubuntu-latest
@@ -184,10 +186,42 @@ jobs:
184186
DB_BACKEND: sqlite3
185187
DB_NAME: ":memory:"
186188

187-
- name: Upload coverage
188-
uses: codecov/codecov-action@v1
189+
- name: Upload coverage data
190+
uses: actions/upload-artifact@v2
189191
with:
190-
name: Python ${{ matrix.python-version }}
192+
name: coverage-data
193+
path: ".coverage.*"
194+
195+
coverage:
196+
name: Check coverage.
197+
runs-on: "ubuntu-latest"
198+
needs: [sqlite, mysql, postgres]
199+
steps:
200+
- uses: actions/checkout@v2
201+
- uses: actions/setup-python@v2
202+
with:
203+
# Use latest, so it understands all syntax.
204+
python-version: "3.10"
205+
206+
- run: python -m pip install --upgrade coverage
207+
208+
- name: Download coverage data.
209+
uses: actions/download-artifact@v2
210+
with:
211+
name: coverage-data
212+
213+
- name: Combine coverage & check percentage
214+
run: |
215+
python -m coverage combine
216+
python -m coverage html
217+
python -m coverage report
218+
219+
- name: Upload HTML report if check failed.
220+
uses: actions/upload-artifact@v2
221+
with:
222+
name: html-report
223+
path: htmlcov
224+
if: ${{ failure() }}
191225

192226
lint:
193227
runs-on: ubuntu-latest

setup.cfg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ exclude =
4444
tests
4545
tests.*
4646

47+
48+
[coverage.html]
49+
skip_covered = True
50+
skip_empty = True
51+
52+
[coverage:run]
53+
branch = True
54+
parallel = True
55+
source = debug_toolbar
56+
57+
[coverage:paths]
58+
source =
59+
src
60+
.tox/*/site-packages
61+
62+
[coverage:report]
63+
fail_under = 89
64+
show_missing = True
65+
4766
[flake8]
4867
extend-ignore = E203, E501
4968

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ deps =
2121
sqlparse
2222
passenv=
2323
CI
24+
COVERAGE_ARGS
2425
DB_BACKEND
2526
DB_NAME
2627
DB_USER
@@ -36,9 +37,10 @@ setenv =
3637
DB_USER = {env:DB_USER:debug_toolbar}
3738
DB_HOST = {env:DB_HOST:localhost}
3839
DB_PASSWORD = {env:DB_PASSWORD:debug_toolbar}
40+
DJANGO_SETTINGS_MODULE = tests.settings
3941
whitelist_externals = make
4042
pip_pre = True
41-
commands = make coverage TEST_ARGS='{posargs:tests}'
43+
commands = python -b -W always -m coverage run -m django test -v2 {posargs:tests}
4244

4345
[testenv:py{36,37,38,39,310}-dj{40,main}-postgresql]
4446
setenv =

0 commit comments

Comments
 (0)