Skip to content

Commit f2aae7d

Browse files
gnikonorovssbarnea
andauthored
Add codecov support for python code (#370)
* Add workflow to generate codecov reports for pytest * implement codecov publishing * Move linting into its own job in the github actions file * Alphabetize this change * make coverage optional * properly add devel-cov Co-authored-by: Sorin Sbarnea <[email protected]>
1 parent 0372228 commit f2aae7d

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

.coveragerc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[coverage:report]
2+
precision = 2
3+
show_missing = true

.github/workflows/actions.yml

+24-5
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ jobs:
2222
strategy:
2323
matrix:
2424
include:
25-
- os: ubuntu-18.04
26-
name: linting-ubuntu
27-
python-version: 3.6
28-
2925
- os: ubuntu-18.04
3026
name: py36-ubuntu
3127
python-version: 3.6
@@ -111,7 +107,15 @@ jobs:
111107
split-by: '-'
112108
- name: Test with tox
113109
run: |
114-
python -m tox -e ${{ steps.split-matrix-name.outputs._0}}
110+
python -m tox -e ${{ steps.split-matrix-name.outputs._0}}-cov
111+
- name: Upload coverage to codecov
112+
uses: codecov/codecov-action@v1
113+
with:
114+
fail_ci_if_error: true
115+
file: ./coverage.xml
116+
flags: tests
117+
name: ${{ matrix.py }} - ${{ matrix.os }}
118+
verbose: true
115119
build_javascript:
116120
name: grunt
117121
runs-on: ubuntu-18.04
@@ -129,6 +133,21 @@ jobs:
129133
npm test
130134
env:
131135
CI: true
136+
linting:
137+
name: linting
138+
runs-on: ubuntu-18.04
139+
steps:
140+
- uses: actions/checkout@master
141+
- name: Set up Python
142+
uses: actions/setup-python@v2
143+
with:
144+
python-version: 3.6
145+
- name: Install tox
146+
run: |
147+
python -m pip install --upgrade tox
148+
- name: Lint with tox
149+
run: |
150+
python -m tox -e linting
132151
publish:
133152
name: Publish to PyPI registry
134153
needs:

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ __pycache__
66
build
77
dist
88

9+
# Codecov
10+
.coverage
11+
coverage.xml
12+
913
# IDE Specific files/folders
1014
## Pycharm IDE - Jetbrains
1115
.idea/*

tox.ini

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ deps =
1414
pytest-rerunfailures
1515
pytest-mock
1616
ansi2html # soft-dependency
17-
commands = pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs}
17+
cov: pytest-cov
18+
commands =
19+
!cov: pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs}
20+
cov: pytest -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html --cov={envsitepackagesdir}/pytest_html --cov-report=term --cov-report=xml {posargs}
1821

1922
[testenv:linting]
2023
skip_install = True
@@ -34,6 +37,12 @@ deps =
3437
# https://github.com/pytest-dev/pytest-rerunfailures/issues/134
3538
# pytest @ git+https://github.com/pytest-dev/pytest.git
3639

40+
[testenv:devel-cov]
41+
description = Tests with unreleased deps and coverage
42+
basepython = {[testenv:devel]basepython}
43+
pip_pre = {[testenv:devel]pip_pre}
44+
deps = {[testenv:devel]deps}
45+
3746
[testenv:packaging]
3847
description =
3948
Do packaging/distribution. If tag is not present or PEP440 compliant upload to

0 commit comments

Comments
 (0)