From ec6fca4aa715f16d7e3f68e6d33f9c100075daf2 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 2 Sep 2018 10:22:20 -0300 Subject: [PATCH 1/5] Add codecov support to AppVeyor and remove coveralls --- .gitattributes | 2 +- .gitignore | 2 ++ .travis.yml | 10 ++++++---- appveyor.yml | 24 ++++++++++++------------ scripts/call-tox.bat | 8 -------- scripts/prepare-coverage.bat | 10 ++++++++++ scripts/upload-coverage.bat | 11 +++++++++++ tox.ini | 24 ++++-------------------- 8 files changed, 46 insertions(+), 45 deletions(-) delete mode 100644 scripts/call-tox.bat create mode 100644 scripts/prepare-coverage.bat create mode 100644 scripts/upload-coverage.bat diff --git a/.gitattributes b/.gitattributes index 242d3da0d74..ec1c66dc1e9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -CHANGELOG merge=union +*.bat text eol=crlf diff --git a/.gitignore b/.gitignore index 2ae5ea752b3..1b363494dd6 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ env/ .cache .pytest_cache .coverage +.coverage.* +coverage.xml .ropeproject .idea .hypothesis diff --git a/.travis.yml b/.travis.yml index 89874f5a0e4..e7ee12de8b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,7 +82,9 @@ jobs: before_script: - | if [[ "$PYTEST_NO_COVERAGE" != 1 ]]; then - export _PYTEST_TOX_COVERAGE_RUN="env COVERAGE_FILE=$PWD/.coverage COVERAGE_PROCESS_START=$PWD/.coveragerc coverage run --source {envsitepackagesdir}/_pytest/,$PWD/testing -m" + export COVERAGE_FILE="$PWD/.coverage" + export COVERAGE_PROCESS_START="$PWD/.coveragerc" + export _PYTEST_TOX_COVERAGE_RUN="coverage run --source {envsitepackagesdir}/_pytest/,{toxinidir}/testing -m" export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess fi @@ -94,9 +96,9 @@ after_success: set -e pip install codecov coverage combine - coverage xml - coverage report -m - codecov --required -X gcov pycov search -f coverage.xml --flags ${TOXENV//-/ } + coverage xml --ignore-errors + coverage report -m --ignore-errors + codecov --required -X gcov pycov search -f coverage.xml --flags ${TOXENV//-/ } linux # Coveralls does not support merged reports. if [[ "$TOXENV" = py37 ]]; then diff --git a/appveyor.yml b/appveyor.yml index 11e57f0c8a5..949397d3b88 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,27 +1,18 @@ environment: - COVERALLS_REPO_TOKEN: - secure: 2NJ5Ct55cHJ9WEg3xbSqCuv0rdgzzb6pnzOIG5OkMbTndw3wOBrXntWFoQrXiMFi - # this is pytest's token in coveralls.io, encrypted - # using pytestbot account as detailed here: - # https://www.appveyor.com/docs/build-configuration#secure-variables - matrix: - # coveralls is not in the default env list - - TOXENV: "coveralls" - # note: please use "tox --listenvs" to populate the build matrix below - TOXENV: "linting" + PYTEST_NO_COVERAGE: "1" - TOXENV: "py27" - TOXENV: "py34" - TOXENV: "py35" - TOXENV: "py36" - TOXENV: "py37" - TOXENV: "pypy" - - TOXENV: "py27-pexpect" + PYTEST_NO_COVERAGE: "1" - TOXENV: "py27-xdist" - TOXENV: "py27-trial" - TOXENV: "py27-numpy" - TOXENV: "py27-pluggymaster" - - TOXENV: "py36-pexpect" - TOXENV: "py36-xdist" - TOXENV: "py36-trial" - TOXENV: "py36-numpy" @@ -29,7 +20,9 @@ environment: - TOXENV: "py27-nobyte" - TOXENV: "doctesting" - TOXENV: "py36-freeze" + PYTEST_NO_COVERAGE: "1" - TOXENV: "docs" + PYTEST_NO_COVERAGE: "1" install: - echo Installed Pythons @@ -37,12 +30,19 @@ install: - if "%TOXENV%" == "pypy" call scripts\install-pypy.bat + - C:\Python36\python -m pip install --upgrade pip - C:\Python36\python -m pip install --upgrade --pre tox build: false # Not a C# project, build stuff at the test step instead. +before_test: + - call scripts\prepare-coverage.bat + test_script: - - call scripts\call-tox.bat + - C:\Python36\python -m tox + +on_success: + - call scripts\upload-coverage.bat cache: - '%LOCALAPPDATA%\pip\cache' diff --git a/scripts/call-tox.bat b/scripts/call-tox.bat deleted file mode 100644 index 86fb25c1df1..00000000000 --- a/scripts/call-tox.bat +++ /dev/null @@ -1,8 +0,0 @@ -REM skip "coveralls" run in PRs or forks -if "%TOXENV%" == "coveralls" ( - if not defined COVERALLS_REPO_TOKEN ( - echo skipping coveralls run because COVERALLS_REPO_TOKEN is not defined - exit /b 0 - ) -) -C:\Python36\python -m tox diff --git a/scripts/prepare-coverage.bat b/scripts/prepare-coverage.bat new file mode 100644 index 00000000000..fbf4da66a41 --- /dev/null +++ b/scripts/prepare-coverage.bat @@ -0,0 +1,10 @@ +REM scripts called by AppVeyor to setup the environment variables to enable coverage +if not defined PYTEST_NO_COVERAGE ( + set "COVERAGE_FILE=%CD%\.coverage" + set "COVERAGE_PROCESS_START=%CD%\.coveragerc" + set "_PYTEST_TOX_COVERAGE_RUN=coverage run --source {envsitepackagesdir}/_pytest/,{toxinidir}/testing -m" + set "_PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess" + echo Coverage setup completed +) else ( + echo Skipping coverage setup, PYTEST_NO_COVERAGE is set +) diff --git a/scripts/upload-coverage.bat b/scripts/upload-coverage.bat new file mode 100644 index 00000000000..97553676cc3 --- /dev/null +++ b/scripts/upload-coverage.bat @@ -0,0 +1,11 @@ +REM script called by AppVeyor to combine and upload coverage information to codecov +if not defined PYTEST_NO_COVERAGE ( + echo Prepare to upload coverage information + C:\Python36\Scripts\pip install codecov + C:\Python36\Scripts\coverage combine + C:\Python36\Scripts\coverage xml --ignore-errors + C:\Python36\Scripts\coverage report -m --ignore-errors + C:\Python36\Scripts\codecov --required -X gcov pycov search -f coverage.xml --flags %TOXENV:-= % windows +) else ( + echo Skipping coverage upload, PYTEST_NO_COVERAGE is set +) diff --git a/tox.ini b/tox.ini index fbc5d4779d6..69397665f88 100644 --- a/tox.ini +++ b/tox.ini @@ -18,14 +18,14 @@ envlist = [testenv] commands = - {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --lsof -ra {env:_PYTEST_TEST_OPTS:} {posargs:testing} - coverage: coverage report -m --skip-covered + {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --lsof -ra {posargs:testing} +passenv = USER USERNAME setenv = + # configuration if a user runs tox with a "coverage" factor, for example "tox -e py36-coverage" coverage: _PYTEST_TOX_COVERAGE_RUN=coverage run -m coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess coverage: COVERAGE_FILE={toxinidir}/.coverage coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc -passenv = USER USERNAME deps = hypothesis>=3.56 nose @@ -56,9 +56,8 @@ deps = nose hypothesis>=3.56 {env:_PYTEST_TOX_EXTRA_DEP:} -changedir=testing commands = - {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n8 -ra {posargs:.} + {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n8 -ra {posargs:testing} [testenv:py36-xdist] deps = {[testenv:py27-xdist]deps} @@ -177,21 +176,6 @@ commands = {envpython} create_executable.py {envpython} tox_run.py - -[testenv:coveralls] -passenv = CI TRAVIS TRAVIS_* COVERALLS_REPO_TOKEN -usedevelop = True -changedir = . -deps = - {[testenv]deps} - coveralls - codecov -commands = - coverage run -m pytest testing - coverage report -m - coveralls - codecov - [testenv:release] decription = do a release, required posarg of the version number basepython = python3.6 From 5e2bd17d1834cc510a1e7bc1ba4bf7d1b914a27e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 5 Sep 2018 11:11:42 -0300 Subject: [PATCH 2/5] White list external "env" used by Travis for coverage --- tox.ini | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tox.ini b/tox.ini index 69397665f88..e16de404fbb 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ envlist = docs [testenv] +whitelist_externals = env commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --lsof -ra {posargs:testing} passenv = USER USERNAME @@ -56,6 +57,7 @@ deps = nose hypothesis>=3.56 {env:_PYTEST_TOX_EXTRA_DEP:} +whitelist_externals = env commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n8 -ra {posargs:testing} @@ -69,6 +71,7 @@ platform = linux|darwin deps = pexpect {env:_PYTEST_TOX_EXTRA_DEP:} +whitelist_externals = env commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra test_pdb.py test_terminal.py test_unittest.py @@ -89,6 +92,7 @@ changedir=testing setenv = {[testenv]setenv} PYTHONDONTWRITEBYTECODE=1 +whitelist_externals = env commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n3 -ra {posargs:.} @@ -96,6 +100,7 @@ commands = deps = twisted {env:_PYTEST_TOX_EXTRA_DEP:} +whitelist_externals = env commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra {posargs:testing/test_unittest.py} @@ -107,6 +112,7 @@ commands = {[testenv:py27-trial]commands} deps = numpy {env:_PYTEST_TOX_EXTRA_DEP:} +whitelist_externals = env commands= {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra {posargs:testing/python/approx.py} @@ -144,6 +150,7 @@ skipsdist = True deps = PyYAML {env:_PYTEST_TOX_EXTRA_DEP:} +whitelist_externals = env commands = {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra doc/en {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest From 418a66a09f7aa5c651b86ff4fbcec09472acfc82 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 5 Sep 2018 19:59:19 -0300 Subject: [PATCH 3/5] Replace coveralls' badge by codecov's --- README.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 97ab784cde4..7454893a2d1 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,9 @@ .. image:: https://img.shields.io/pypi/pyversions/pytest.svg :target: https://pypi.org/project/pytest/ -.. image:: https://img.shields.io/coveralls/pytest-dev/pytest/master.svg - :target: https://coveralls.io/r/pytest-dev/pytest +.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/master/graph/badge.svg + :target: https://codecov.io/gh/pytest-dev/pytest + :alt: Code coverage Status .. image:: https://travis-ci.org/pytest-dev/pytest.svg?branch=master :target: https://travis-ci.org/pytest-dev/pytest @@ -25,7 +26,7 @@ :target: https://ci.appveyor.com/project/pytestbot/pytest .. image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/ambv/black + :target: https://github.com/ambv/black .. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg :target: https://www.codetriage.com/pytest-dev/pytest From 9ee8d72fd27fb836e161d47a31004b954a07416d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 6 Sep 2018 09:18:32 -0300 Subject: [PATCH 4/5] Disable coverage during deployment stage Otherwise it will fail as there's no coverage data to combine/publish --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e7ee12de8b3..1e709ba058a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,7 @@ jobs: - stage: deploy python: '3.6' - env: + env: PYTEST_NO_COVERAGE=1 install: pip install -U setuptools setuptools_scm script: skip deploy: From 5eb85efa147457f4455dbb8080aa14ce784a3bdd Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 4 Sep 2018 18:58:00 -0300 Subject: [PATCH 5/5] Use -n auto now that xdist behaves well in Travis and AppVeyor This hopefully fixes the flaky test_idval_hypothesis on AppVeyor Fix #3707 --- testing/python/metafunc.py | 3 --- tox.ini | 9 ++++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index f5d839f086e..648c6c5c295 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -211,9 +211,6 @@ class A(object): @hypothesis.settings( deadline=400.0 ) # very close to std deadline and CI boxes are not reliable in CPU power - @pytest.mark.xfail( - sys.platform.startswith("win32"), reason="flaky #3707", strict=False - ) def test_idval_hypothesis(self, value): from _pytest.python import _idval diff --git a/tox.ini b/tox.ini index e16de404fbb..97fef426d42 100644 --- a/tox.ini +++ b/tox.ini @@ -40,8 +40,9 @@ deps = pytest-xdist>=1.13 mock nose +passenv = USER USERNAME TRAVIS commands = - pytest -n3 -ra --runpytest=subprocess {posargs:testing} + pytest -n auto -ra --runpytest=subprocess {posargs:testing} [testenv:linting] @@ -58,8 +59,9 @@ deps = hypothesis>=3.56 {env:_PYTEST_TOX_EXTRA_DEP:} whitelist_externals = env +passenv = USER USERNAME TRAVIS commands = - {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n8 -ra {posargs:testing} + {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n auto -ra {posargs:testing} [testenv:py36-xdist] deps = {[testenv:py27-xdist]deps} @@ -93,8 +95,9 @@ setenv = {[testenv]setenv} PYTHONDONTWRITEBYTECODE=1 whitelist_externals = env +passenv = USER USERNAME TRAVIS commands = - {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n3 -ra {posargs:.} + {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n auto -ra {posargs:.} [testenv:py27-trial] deps =