Skip to content

Commit cd9415b

Browse files
committed
Configure azure to enable coverage on PYTEST_COVERAGE=1, similar to Travis
1 parent 6bd77c0 commit cd9415b

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

azure-pipelines.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ variables:
88
python.exe: "python"
99
COVERAGE_FILE: "$(Build.Repository.LocalPath)/.coverage"
1010
COVERAGE_PROCESS_START: "$(Build.Repository.LocalPath)/.coveragerc"
11-
_PYTEST_TOX_COVERAGE_RUN: "coverage run -m"
12-
_PYTEST_TOX_EXTRA_DEP: "coverage-enable-subprocess"
11+
PYTEST_COVERAGE: '0'
1312

1413
jobs:
1514

@@ -21,47 +20,54 @@ jobs:
2120
py27:
2221
python.version: '2.7'
2322
tox.env: 'py27'
23+
PYTEST_COVERAGE: '1'
2424
py27-xdist:
2525
python.version: '2.7'
2626
tox.env: 'py27-xdist'
27+
PYTEST_COVERAGE: '1'
2728
py27-numpy/nobyte:
2829
python.version: '2.7'
2930
tox.env: 'py27-numpy,py27-nobyte'
31+
PYTEST_COVERAGE: '1'
3032
py27-trial:
3133
python.version: '2.7'
3234
tox.env: 'py27-trial'
3335
python.needs_vc: True
36+
PYTEST_COVERAGE: '1'
3437
py27-pluggymaster-xdist:
3538
python.version: '2.7'
3639
tox.env: 'py27-pluggymaster-xdist'
3740
pypy:
3841
python.version: 'pypy'
3942
tox.env: 'pypy'
4043
python.exe: 'pypy'
41-
_PYTEST_TOX_COVERAGE_RUN: ""
42-
_PYTEST_TOX_EXTRA_DEP: ""
43-
PYTEST_NO_COVERAGE: "1"
4444
py34:
4545
python.version: '3.4'
4646
tox.env: 'py34'
47+
PYTEST_COVERAGE: '1'
4748
py35:
4849
python.version: '3.5'
4950
tox.env: 'py35'
51+
PYTEST_COVERAGE: '1'
5052
py36:
5153
python.version: '3.6'
5254
tox.env: 'py36'
55+
PYTEST_COVERAGE: '1'
5356
py37:
5457
python.version: '3.7'
5558
tox.env: 'py37'
59+
PYTEST_COVERAGE: '1'
5660
py37-linting/docs/doctesting:
5761
python.version: '3.7'
5862
tox.env: 'linting,docs,doctesting'
5963
py37-xdist:
6064
python.version: '3.7'
6165
tox.env: 'py37-xdist'
66+
PYTEST_COVERAGE: '1'
6267
py37-trial/numpy:
6368
python.version: '3.7'
6469
tox.env: 'py37-trial,py37-numpy'
70+
PYTEST_COVERAGE: '1'
6571
py37-pluggymaster-xdist:
6672
python.version: '3.7'
6773
tox.env: 'py37-pluggymaster-xdist'
@@ -98,7 +104,9 @@ jobs:
98104
- script: $(python.exe) -m pip install --upgrade pip && $(python.exe) -m pip install tox
99105
displayName: 'Install tox'
100106

101-
- script: $(python.exe) -m tox -e $(tox.env)
107+
- script: |
108+
call scripts/setup-coverage-vars.bat || goto :eof
109+
$(python.exe) -m tox -e $(tox.env)
102110
displayName: 'Run tests'
103111
104112
- task: PublishTestResults@2
@@ -109,5 +117,6 @@ jobs:
109117

110118
- script: call scripts\upload-coverage.bat
111119
displayName: 'Upload coverage'
120+
condition: eq(variables['PYTEST_COVERAGE'], '1')
112121
env:
113122
CODECOV_TOKEN: $(CODECOV_TOKEN)

scripts/setup-coverage-vars.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if "%PYTEST_COVERAGE%" == "1" (
2+
set "_PYTEST_TOX_COVERAGE_RUN=coverage run -m"
3+
set "_PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess"
4+
echo Coverage vars configured, PYTEST_COVERAGE=%PYTEST_COVERAGE%
5+
) else (
6+
echo Skipping coverage vars setup, PYTEST_COVERAGE=%PYTEST_COVERAGE%
7+
)

scripts/upload-coverage.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
REM script called by AppVeyor to combine and upload coverage information to codecov
2-
if not defined PYTEST_NO_COVERAGE (
1+
REM script called by Azure to combine and upload coverage information to codecov
2+
if "%PYTEST_COVERAGE%" == "1" (
33
echo Prepare to upload coverage information
44
if defined CODECOV_TOKEN (
55
echo CODECOV_TOKEN defined
@@ -12,5 +12,5 @@ if not defined PYTEST_NO_COVERAGE (
1212
coverage report -m --ignore-errors
1313
scripts\retry codecov --required -X gcov pycov search -f coverage.xml --flags windows
1414
) else (
15-
echo Skipping coverage upload, PYTEST_NO_COVERAGE is set
15+
echo Skipping coverage upload, PYTEST_COVERAGE=%PYTEST_COVERAGE%
1616
)

0 commit comments

Comments
 (0)