diff --git a/.travis.yml b/.travis.yml index 0b62b133c..073017a99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,13 +114,7 @@ script: tox after_success: - | if [[ "$PYTEST_COVERAGE" = 1 ]]; then - set -e - # Add last TOXENV to $PATH. - PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH" - coverage combine - coverage xml - coverage report -m - bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -n $TOXENV-$TRAVIS_OS_NAME + env CODECOV_NAME="$TOXENV-$TRAVIS_OS_NAME" scripts/report-coverage.sh fi notifications: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 72e4af732..b3515d5e0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,8 +4,6 @@ trigger: variables: PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml -vv" - COVERAGE_FILE: "$(Build.Repository.LocalPath)/.coverage" - COVERAGE_PROCESS_START: "$(Build.Repository.LocalPath)/.coveragerc" PYTEST_COVERAGE: '0' jobs: @@ -55,8 +53,13 @@ jobs: - script: python -m pip install --upgrade pip && python -m pip install tox displayName: 'Install tox' - - script: | - call scripts/setup-coverage-vars.bat || goto :eof + - bash: | + if [[ "$PYTEST_COVERAGE" == "1" ]]; then + export _PYTEST_TOX_COVERAGE_RUN="coverage run -m" + export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess + export COVERAGE_FILE="$PWD/.coverage" + export COVERAGE_PROCESS_START="$PWD/.coveragerc" + fi python -m tox -e $(tox.env) displayName: 'Run tests' @@ -66,9 +69,12 @@ jobs: testRunTitle: '$(tox.env)' condition: succeededOrFailed() - - script: call scripts\upload-coverage.bat - displayName: 'Report and upload coverage' - condition: eq(variables['PYTEST_COVERAGE'], '1') + - bash: | + if [[ "$PYTEST_COVERAGE" == 1 ]]; then + scripts/report-coverage.sh + fi env: + CODECOV_NAME: $(tox.env) CODECOV_TOKEN: $(CODECOV_TOKEN) - PYTEST_CODECOV_NAME: $(tox.env) + displayName: Report and upload coverage + condition: eq(variables['PYTEST_COVERAGE'], '1') diff --git a/scripts/report-coverage.sh b/scripts/report-coverage.sh new file mode 100755 index 000000000..755783d2a --- /dev/null +++ b/scripts/report-coverage.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e +set -x + +if [ -z "$TOXENV" ]; then + python -m pip install coverage +else + # Add last TOXENV to $PATH. + PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH" +fi + +python -m coverage combine +python -m coverage xml +python -m coverage report -m +bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml diff --git a/scripts/setup-coverage-vars.bat b/scripts/setup-coverage-vars.bat deleted file mode 100644 index 7a4a6d4de..000000000 --- a/scripts/setup-coverage-vars.bat +++ /dev/null @@ -1,7 +0,0 @@ -if "%PYTEST_COVERAGE%" == "1" ( - set "_PYTEST_TOX_COVERAGE_RUN=coverage run -m" - set "_PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess" - echo Coverage vars configured, PYTEST_COVERAGE=%PYTEST_COVERAGE% -) else ( - echo Skipping coverage vars setup, PYTEST_COVERAGE=%PYTEST_COVERAGE% -) diff --git a/scripts/upload-coverage.bat b/scripts/upload-coverage.bat deleted file mode 100644 index 08ed57791..000000000 --- a/scripts/upload-coverage.bat +++ /dev/null @@ -1,16 +0,0 @@ -REM script called by Azure to combine and upload coverage information to codecov -if "%PYTEST_COVERAGE%" == "1" ( - echo Prepare to upload coverage information - if defined CODECOV_TOKEN ( - echo CODECOV_TOKEN defined - ) else ( - echo CODECOV_TOKEN NOT defined - ) - python -m pip install codecov - python -m coverage combine - python -m coverage xml - python -m coverage report -m - scripts\retry python -m codecov --required -X gcov pycov search -f coverage.xml --name %PYTEST_CODECOV_NAME% -) else ( - echo Skipping coverage upload, PYTEST_COVERAGE=%PYTEST_COVERAGE% -)