Skip to content

Commit

Permalink
ci: move coverage reporting to shared script (pytest-dev#5403)
Browse files Browse the repository at this point in the history
ci: move coverage reporting to shared script
  • Loading branch information
nicoddemus committed Jun 6, 2019
2 parents 9f8b566 + 0fd1f30 commit 450d264
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 38 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Expand Up @@ -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:
Expand Down
22 changes: 14 additions & 8 deletions azure-pipelines.yml
Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand All @@ -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')
16 changes: 16 additions & 0 deletions 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
7 changes: 0 additions & 7 deletions scripts/setup-coverage-vars.bat

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/upload-coverage.bat

This file was deleted.

0 comments on commit 450d264

Please sign in to comment.