Skip to content

Commit dfb0d40

Browse files
blueyeddulacp
authored andcommitted
Travis: add coverage reporting via pytest-cov on codecov.io
1 parent 97852b7 commit dfb0d40

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[run]
22
parallel = true
3-
source = pytest_django
3+
source = pytest_django,pytest_django_test,tests
44
branch = true

.travis.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ language: python
55
matrix:
66
fast_finish: true
77
include:
8-
98
- python: 3.6
109
env: TOXENV=py36-pytest3-djangomaster-postgres
1110
- python: 3.6
@@ -75,7 +74,27 @@ install:
7574
- diff tox.ini tox.ini.bak && return 1 || true
7675

7776
- pip install tox==2.7.0
77+
- |
78+
if [[ "${TOXENV%-checkqa}" == "$TOXENV" ]]; then
79+
export PYTEST_ADDOPTS='--cov=pytest_django --cov=tests --cov=pytest_django_test --cov-report=term-missing:skip-covered'
80+
export _PYTESTDJANGO_TOX_EXTRA_DEPS=pytest-cov
81+
fi
7882
7983
script:
8084
- tox
8185
- "find ${TRAVIS_BUILD_DIR}/.tox -name 'log' -o -name '__pycache__' -type d | xargs -I {} rm -rf {}"
86+
87+
after_success:
88+
- |
89+
set -ex
90+
if [[ "${TOXENV%-checkqa}" == "$TOXENV" ]]; then
91+
pip install codecov
92+
coverage combine
93+
coverage xml
94+
coverage report -m --skip-covered
95+
96+
codecov_flags=${TOXENV//./}
97+
codecov_flags=${codecov_flags//-/ }
98+
codecov --required -X search gcov pycov -f coverage.xml --flags $codecov_flags
99+
fi
100+
set +x

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ envlist =
1414
deps =
1515
django-configurations==2.0
1616
pytest-xdist==1.15
17+
{env:_PYTESTDJANGO_TOX_EXTRA_DEPS:}
1718

1819
checkqa: flake8
1920

@@ -35,6 +36,8 @@ deps =
3536
setenv =
3637
PYTHONPATH = {toxinidir}:{env:PYTHONPATH:}
3738

39+
passenv = PYTEST_ADDOPTS
40+
3841
usedevelop = True
3942

4043
commands =

0 commit comments

Comments
 (0)