Skip to content

Travis: add coverage reporting via pytest-cov on codecov.io #520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[run]
parallel = true
source = pytest_django
source = pytest_django,pytest_django_test,tests
branch = true
26 changes: 22 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ language: python
matrix:
fast_finish: true
include:

- python: 3.6
env: TOXENV=py36-pytest3-djangomaster-postgres
- python: 3.6
Expand Down Expand Up @@ -70,12 +69,31 @@ install:
- printf '\necho "Using pip-wrapper.." >&2\ntravis_retry pip "$@"' >> bin/travis_retry_pip
- chmod +x bin/travis_retry_pip
- sed -i.bak 's/^\[testenv\]/\0\ninstall_command = travis_retry_pip install {opts} {packages}/' tox.ini
- diff tox.ini tox.ini.bak && return 1 || true
- sed -i.bak 's/whitelist_externals =/\0\n travis_retry_pip/' tox.ini
- diff tox.ini tox.ini.bak && return 1 || true
- if diff tox.ini tox.ini.bak; then exit 1; fi
- printf '\nwhitelist_externals = travis_retry_pip' >> tox.ini

- pip install tox==2.7.0
- |
if [[ "${TOXENV%-checkqa}" == "$TOXENV" ]]; then
export PYTEST_ADDOPTS='--cov=pytest_django --cov=tests --cov=pytest_django_test --cov-report=term-missing:skip-covered'
export _PYTESTDJANGO_TOX_EXTRA_DEPS=pytest-cov
fi

script:
- tox
- "find ${TRAVIS_BUILD_DIR}/.tox -name 'log' -o -name '__pycache__' -type d | xargs -I {} rm -rf {}"

after_success:
- |
set -ex
if [[ "${TOXENV%-checkqa}" == "$TOXENV" ]]; then
pip install codecov
coverage combine
coverage xml
coverage report -m --skip-covered

codecov_flags=${TOXENV//./}
codecov_flags=${codecov_flags//-/ }
codecov --required -X search gcov pycov -f coverage.xml --flags $codecov_flags
fi
set +x
15 changes: 7 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ envlist =
deps =
django-configurations==2.0
pytest-xdist==1.15
{env:_PYTESTDJANGO_TOX_EXTRA_DEPS:}

checkqa: flake8

Expand All @@ -31,17 +32,15 @@ deps =

pytest2: pytest>=2.9,<3.0
pytest3: pytest>=3.0,<4.0

setenv =
PYTHONPATH = {toxinidir}:{env:PYTHONPATH:}

passenv = PYTEST_ADDOPTS
usedevelop = True

commands =
checkqa: flake8 --version
checkqa: flake8 --show-source --statistics {posargs:pytest_django pytest_django_test}
mysql_innodb: py.test --ds=pytest_django_test.settings_mysql_innodb --strict -r fEsxXw {posargs:tests}
mysql_myisam: py.test --ds=pytest_django_test.settings_mysql_myisam --strict -r fEsxXw {posargs:tests}
postgres: py.test --ds=pytest_django_test.settings_postgres --strict -r fEsxXw {posargs:tests}
sqlite: py.test --ds=pytest_django_test.settings_sqlite --strict -r fEsxXw {posargs:tests}
sqlite_file: py.test --ds=pytest_django_test.settings_sqlite_file --strict -r fEsxXw {posargs:tests}
mysql_innodb: pytest --ds=pytest_django_test.settings_mysql_innodb --strict -r fEsxXw {posargs:tests}
mysql_myisam: pytest --ds=pytest_django_test.settings_mysql_myisam --strict -r fEsxXw {posargs:tests}
postgres: pytest --ds=pytest_django_test.settings_postgres --strict -r fEsxXw {posargs:tests}
sqlite: pytest --ds=pytest_django_test.settings_sqlite --strict -r fEsxXw {posargs:tests}
sqlite_file: pytest --ds=pytest_django_test.settings_sqlite_file --strict -r fEsxXw {posargs:tests}