Skip to content

Commit 1420418

Browse files
authored
Adding new task in CI to report code-coverage in branches and PRs. (#58)
1 parent a32c0f8 commit 1420418

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

.ci/run_tests.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
set -e -x
44

5-
pytest tests
5+
coverage run --branch -m pytest tests
6+
coverage xml
7+
coverage erase

.coveragerc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[report]
2+
# Regexes for lines to exclude from consideration
3+
exclude_lines =
4+
# Have to re-enable the standard pragma
5+
pragma: no cover
6+
def __repr__
7+
8+
# Don't complain about missing debug-only code:
9+
if self\.debug
10+
11+
# Don't complain if tests don't hit defensive assertion code:
12+
raise AssertionError
13+
raise NotImplementedError
14+
15+
# Don't complain if non-runnable code isn't run:
16+
if 0:
17+
if False:
18+
if __name__ == .__main__.:
19+
20+
# Not counting some extra lines which don't need to be counted.
21+
print
22+
def setUp
23+
def test_
24+
def suite
25+
26+
ignore_errors = True
27+
28+
omit =
29+
*/build/*
30+
*/doc/*
31+
*/examples/*
32+
*/postprocessing/*
33+
*/test/*
34+
*/setup.py
35+
setup.py
36+
*/site-packages/*
37+
azure/functions/_thirdparty/*
38+
*/venv/*
39+
*/.venv/*
40+
*/.env*/*
41+
*/.vscode/*

azure-pipelines.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ jobs:
2929
chmod +x .ci/run_tests.sh
3030
.ci/run_tests.sh
3131
displayName: 'Run Tests'
32+
- task: PublishCodeCoverageResults@1
33+
inputs:
34+
codeCoverageTool: cobertura
35+
summaryFileLocation: coverage.xml
36+
- bash: |
37+
rm coverage.xml
38+
displayName: 'Clearing coverage.xml file'

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
'mypy',
3030
'pytest',
3131
'requests==2.*',
32+
'coverage'
3233
]
3334
},
3435
include_package_data=True,

0 commit comments

Comments
 (0)