Skip to content

Commit 34a9d80

Browse files
authored
DEV: Add Code Coverage Report Generation + Upload
* Add code coverage XML report generation via pytest-cov by adding test runner options in tox.ini file. * Create .coveragerc file for pytest-cov using codecov defaults. * Add report upload to codecov and deepsource services by adding after-sucess section to .travis.yml file.
1 parent 897c47b commit 34a9d80

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

.coveragerc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Pytest-cov configuration: https://coverage.readthedocs.io/en/latest/config.html
2+
# Based off of covdecov example: https://gist.github.com/codecov-io/bf15bde2c7db1a011b6e
3+
[run]
4+
branch = True
5+
source = tiatoolbox
6+
7+
[report]
8+
exclude_lines =
9+
if self.debug:
10+
pragma: no cover
11+
raise NotImplementedError
12+
if __name__ == .__main__.:
13+
ignore_errors = True
14+
omit =
15+
tests/*

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ install: pip install -U tox-travis
1313
# Command to run tests, e.g. python setup.py test
1414
script: tox
1515

16+
# Upload test coverage reports (codecov and deepsource)
17+
after_success:
18+
# Upload coverage to codecov
19+
- bash <(curl -s https://codecov.io/bash)
20+
# Install deepsource CLI
21+
- curl https://deepsource.io/cli | sh
22+
- export DEEPSOURCE_DSN=https://sampledsn@deepsource.io
23+
# Report coverage artifact to 'test-coverage' analyzer
24+
-./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml
25+
1626
# Assuming you have installed the travis-ci CLI tool, after you
1727
# create the Github repo and add it to Travis, run the
1828
# following command to finish PyPI deployment setup:

requirements_dev.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ wheel==0.33.6
44
watchdog==0.9.0
55
flake8==3.7.8
66
tox==3.14.0
7-
coverage==4.5.4
7+
coverage==5.1
88
Sphinx==1.8.5
99
twine==1.14.0
1010
Click==7.0
1111
pytest==4.6.5
12-
pytest-runner==5.1
12+
pytest-runner==5.1
13+
pytest-cov==2.9.0

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ deps =
2323
; -r{toxinidir}/requirements.txt
2424
commands =
2525
pip install -U pip
26-
pytest --basetemp={envtmpdir}
27-
26+
pytest --basetemp={envtmpdir} --cov=tiatoolbox --cov-report=term --cov-report=xml

0 commit comments

Comments
 (0)