Skip to content

Commit 91392ad

Browse files
authored
Merge pull request #520 from blueyed/coverage
Travis: add coverage reporting via pytest-cov on codecov.io
2 parents 6c5d3fb + f6793b2 commit 91392ad

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
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: 22 additions & 4 deletions
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
@@ -70,12 +69,31 @@ install:
7069
- printf '\necho "Using pip-wrapper.." >&2\ntravis_retry pip "$@"' >> bin/travis_retry_pip
7170
- chmod +x bin/travis_retry_pip
7271
- sed -i.bak 's/^\[testenv\]/\0\ninstall_command = travis_retry_pip install {opts} {packages}/' tox.ini
73-
- diff tox.ini tox.ini.bak && return 1 || true
74-
- sed -i.bak 's/whitelist_externals =/\0\n travis_retry_pip/' tox.ini
75-
- diff tox.ini tox.ini.bak && return 1 || true
72+
- if diff tox.ini tox.ini.bak; then exit 1; fi
73+
- printf '\nwhitelist_externals = travis_retry_pip' >> tox.ini
7674

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

tox.ini

Lines changed: 7 additions & 8 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

@@ -31,17 +32,15 @@ deps =
3132

3233
pytest2: pytest>=2.9,<3.0
3334
pytest3: pytest>=3.0,<4.0
34-
3535
setenv =
3636
PYTHONPATH = {toxinidir}:{env:PYTHONPATH:}
37-
37+
passenv = PYTEST_ADDOPTS
3838
usedevelop = True
39-
4039
commands =
4140
checkqa: flake8 --version
4241
checkqa: flake8 --show-source --statistics {posargs:pytest_django pytest_django_test}
43-
mysql_innodb: py.test --ds=pytest_django_test.settings_mysql_innodb --strict -r fEsxXw {posargs:tests}
44-
mysql_myisam: py.test --ds=pytest_django_test.settings_mysql_myisam --strict -r fEsxXw {posargs:tests}
45-
postgres: py.test --ds=pytest_django_test.settings_postgres --strict -r fEsxXw {posargs:tests}
46-
sqlite: py.test --ds=pytest_django_test.settings_sqlite --strict -r fEsxXw {posargs:tests}
47-
sqlite_file: py.test --ds=pytest_django_test.settings_sqlite_file --strict -r fEsxXw {posargs:tests}
42+
mysql_innodb: pytest --ds=pytest_django_test.settings_mysql_innodb --strict -r fEsxXw {posargs:tests}
43+
mysql_myisam: pytest --ds=pytest_django_test.settings_mysql_myisam --strict -r fEsxXw {posargs:tests}
44+
postgres: pytest --ds=pytest_django_test.settings_postgres --strict -r fEsxXw {posargs:tests}
45+
sqlite: pytest --ds=pytest_django_test.settings_sqlite --strict -r fEsxXw {posargs:tests}
46+
sqlite_file: pytest --ds=pytest_django_test.settings_sqlite_file --strict -r fEsxXw {posargs:tests}

0 commit comments

Comments
 (0)