From 5eefd11cf70fac17200c595d4e70f5e773a89cba Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 27 Sep 2017 01:15:33 +0200 Subject: [PATCH 1/3] Travis: add coverage reporting via pytest-cov on codecov.io --- .coveragerc | 2 +- .travis.yml | 21 ++++++++++++++++++++- tox.ini | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index 3e04b511d..646b5062a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,4 @@ [run] parallel = true -source = pytest_django +source = pytest_django,pytest_django_test,tests branch = true diff --git a/.travis.yml b/.travis.yml index 89d3ca275..c27c61803 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ language: python matrix: fast_finish: true include: - - python: 3.6 env: TOXENV=py36-pytest3-djangomaster-postgres - python: 3.6 @@ -75,7 +74,27 @@ install: - diff tox.ini tox.ini.bak && return 1 || true - 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 diff --git a/tox.ini b/tox.ini index 9e1fd149a..3836a3e5a 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,7 @@ envlist = deps = django-configurations==2.0 pytest-xdist==1.15 + {env:_PYTESTDJANGO_TOX_EXTRA_DEPS:} checkqa: flake8 @@ -35,6 +36,8 @@ deps = setenv = PYTHONPATH = {toxinidir}:{env:PYTHONPATH:} +passenv = PYTEST_ADDOPTS + usedevelop = True commands = From 9f08528c53a68a99cc278daa648402b4e973ed4b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 27 Sep 2017 02:08:44 +0200 Subject: [PATCH 2/3] minor: clean up tox.ini --- tox.ini | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tox.ini b/tox.ini index 3836a3e5a..13b5122f9 100644 --- a/tox.ini +++ b/tox.ini @@ -32,19 +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} From f6793b22c0aa07e246aceb654e1e9f7021059173 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 27 Sep 2017 02:21:58 +0200 Subject: [PATCH 3/3] .travis.yml: fix travis_retry_pip hack --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c27c61803..b71def9f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,9 +69,8 @@ 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 - |