Skip to content

Commit 0d80f3a

Browse files
committed
tox: generate test code coverage info
Add a tox env to record the code coverage while running the tests. Add a coverage job for github actions and upload the results to codecov.io at the end. Signed-off-by: Robin Jarry <[email protected]>
1 parent bd20f1d commit 0d80f3a

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

.github/workflows/ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ jobs:
5555
- run: python -m pip install --upgrade tox
5656
- run: python -m tox -e ${{ matrix.toxenv }}
5757

58+
coverage:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v2
62+
- uses: actions/setup-python@v2
63+
with:
64+
python-version: 3.x
65+
- uses: actions/cache@v2
66+
with:
67+
path: ~/.cache/pip
68+
key: pip
69+
restore-keys: pip
70+
- run: python -m pip install --upgrade pip setuptools wheel
71+
- run: python -m pip install --upgrade tox codecov
72+
- run: python -m tox -e coverage
73+
- run: codecov
74+
5875
deploy:
5976
needs: [lint, test]
6077
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ __pycache__/
55
/build/
66
/dist/
77
/*.egg-info/
8+
/.coverage
9+
/htmlcov
10+
/coverage.xml

setup.cfg

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ group = root
77
universal = false
88

99
[coverage:run]
10-
omit = */tests/*
10+
include = libyang/*
11+
omit = tests/test_*
1112

1213
[coverage:report]
13-
skip_covered = False
14-
ignore_errors = True
14+
skip_covered = false
15+
ignore_errors = true
1516
sort = Cover
1617

1718
[flake8]

tox.ini

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = format,lint,py{35,36,37,38,py3},py3-{master,devel}
2+
envlist = format,lint,py{35,36,37,38,py3},py3-{master,devel},coverage
33
skip_missing_interpreters = true
44
isolated_build = true
55
distdir = {toxinidir}/dist
@@ -16,6 +16,15 @@ setenv =
1616
install_command = {toxinidir}/tox-install.sh {envdir} {opts} {packages}
1717
commands = python -m unittest discover -c
1818

19+
[testenv:coverage]
20+
changedir = .
21+
deps = coverage
22+
install_command = {toxinidir}/tox-install.sh {envdir} {opts} {packages}
23+
commands =
24+
python -m coverage run -m unittest discover -c tests/
25+
python -m coverage report
26+
python -m coverage html
27+
1928
[testenv:format]
2029
basepython = python3
2130
description = Format python code using isort and black.

0 commit comments

Comments
 (0)