Skip to content

Commit c59fea6

Browse files
committed
fix
1 parent 561dcb7 commit c59fea6

File tree

4 files changed

+84
-23
lines changed

4 files changed

+84
-23
lines changed

azure-pipelines.yml

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ jobs:
5555
- template: azure-run-tox-env.yml
5656
parameters: {name: macOS_36, python: '3.6', image: 'macOS 10.13'}
5757

58-
- job: tests_done
58+
- job: report_tests
5959
pool: {vmImage: 'Ubuntu 16.04'}
60-
condition: always()
60+
condition: and( always(), eq(variables['system.pullrequest.isfork'], false) )
6161
dependsOn:
6262
- windows_37
6363
- windows_36
@@ -71,12 +71,65 @@ jobs:
7171
- linux_27
7272
- macOS_36
7373
steps:
74-
- script: curl -vk https://coveralls.io/webhook?repo_token=$(COVERALLS_REPO_TOKEN) -d "payload[build_num]=$(Build.BuildId)&payload[status]=done"
75-
displayName: notify coveralls that we finished coverge reports
74+
- task: UsePythonVersion@0
75+
displayName: setup python for coverage
76+
inputs:
77+
versionSpec: '3.7'
78+
79+
- script: 'python -m pip install -U tox --pre'
80+
displayName: install tox
81+
82+
- task: DownloadBuildArtifacts@0
83+
displayName: 'download test coverage and junit files'
84+
inputs:
85+
buildType: 'current'
86+
downloadType: 'specific'
87+
itemPattern: 'test-report-*/*'
88+
downloadPath: '$(Build.StagingDirectory)'
89+
90+
- task: PublishTestResults@2
91+
displayName: publish test results via junit
92+
inputs:
93+
testResultsFormat: 'JUnit'
94+
testResultsFiles: '$(Build.StagingDirectory)/*/.test.*.xml'
95+
96+
- script: 'python -m tox -e coverage --notest'
97+
displayName: create coverag report env
98+
99+
- script: |
100+
python -c '
101+
from pathlib import Path
102+
import shutil
103+
104+
for coverage_file in Path("$(Build.StagingDirectory)").glob("*/.coverage"):
105+
destination = Path("$(System.DefaultWorkingDirectory)") / ".tox" / f".coverage.{coverage_file.parent.name[12:]}"
106+
print(f"{coverage_file} copy to {destination}")
107+
shutil.copy(str(coverage_file), str(destination))
108+
'
109+
displayName: move coverage files into .tox
110+
111+
- script: 'python -m tox -e coverage'
112+
displayName: create coverag report
113+
114+
- task: PublishCodeCoverageResults@1
115+
inputs:
116+
codeCoverageTool: 'cobertura'
117+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/.tox/coverage.xml'
118+
reportDirectory: '$(System.DefaultWorkingDirectory)/.tox/htmlcov'
119+
failIfCoverageEmpty: true
120+
121+
- script: 'python -m tox -e coveralls -- $(System.PullRequest.PullRequestNumber)'
122+
displayName: upload coveralls
123+
env:
124+
CI_BRANCH: $(Build.SourceBranch)
125+
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
126+
COVERALLS_PARALLEL: false
127+
COVERALLS_FLAG_NAME: ${{ parameters.name }}
128+
76129

77130
- job: publish
78131
dependsOn:
79-
- tests_done
132+
- report_tests
80133
- check_code_style
81134
- generate_docs
82135
- check_package_long_description

azure-run-tox-env.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@ jobs:
2626
displayName: perform tox env run
2727
env:
2828
TOXENV: ${{ parameters.tox }}
29+
JUNIT_XML_FILE: ${{ format('$(Build.StagingDirectory)/.test.{0}.xml', parameters.name) }}
2930

30-
- ${{ if eq(parameters.tox, 'py') }}:
31+
- ${{ if and( eq(parameters.tox, 'py'), eq(variables['system.pullrequest.isfork'], false) ) }}:
3132

32-
- script: 'python -m tox -e coverage'
33-
displayName: generate coverage report
33+
- script: 'python -m tox -e coverage'
34+
displayName: create coverag report
3435

35-
- script: 'python -m tox -e coveralls -- $(Build.BuildId) $(System.PullRequest.PullRequestNumber)'
36-
displayName: upload coveralls
37-
env:
38-
CI_BRANCH: $(Build.SourceBranch)
39-
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
40-
COVERALLS_PARALLEL: true
41-
COVERALLS_FLAG_NAME: ${{ parameters.name }}
36+
- task: CopyFiles@2
37+
displayName: move coverage files into staging area
38+
inputs:
39+
sourceFolder: $(System.DefaultWorkingDirectory)/.tox
40+
contents: '.coverage'
41+
targetFolder: $(Build.StagingDirectory)
42+
43+
- task: PublishBuildArtifacts@1
44+
displayName: publish tests data artifacts
45+
inputs:
46+
pathtoPublish: $(Build.ArtifactStagingDirectory)
47+
ArtifactName: ${{ format('test-report-{0}', parameters.name) }}

tasks/coveralls_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
content = textwrap.dedent(
1010
"""
1111
service_name: Azure Pipelines
12-
service_job_id: "{}"
1312
service_pull_request: "https://github.com/tox-dev/tox/pull/{}"
1413
""".format(
15-
sys.argv[1], sys.argv[2]
14+
sys.argv[1]
1615
)
1716
)
1817

tox.ini

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ skip_missing_interpreters = true
1616
[testenv]
1717
description = run the tests with pytest under {basepython}
1818
setenv = PIP_DISABLE_VERSION_CHECK = 1
19-
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
19+
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
2020
passenv = http_proxy https_proxy no_proxy SSL_CERT_FILE TOXENV CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
2121
deps =
2222
extras = testing
23-
commands = pytest {posargs:--cov="{envsitepackagesdir}/tox" --cov-config="{toxinidir}/tox.ini" --timeout=180 . -n {env:PYTEST_XDIST_PROC_NR:auto}}
23+
commands = pytest {posargs:\
24+
--cov="{envsitepackagesdir}/tox" \
25+
--cov-config="{toxinidir}/tox.ini" \
26+
--timeout=180 \
27+
-n={env:PYTEST_XDIST_PROC_NR:auto} \
28+
--junitxml={env:JUNIT_XML_FILE:{toxworkdir}/.test.{envname}.xml} \
29+
. }
30+
2431

2532
[testenv:docs]
2633
description = invoke sphinx-build to build the HTML docs
@@ -103,16 +110,12 @@ branch = true
103110
skip_covered = True
104111
show_missing = True
105112
exclude_lines =
106-
# Have to re-enable the standard pragma
107113
\#\s*pragma: no cover
108-
# We optionally substitute this
109114
${COVERAGE_IGNORE_WINDOWS}
110-
# Don't complain if tests don't hit defensive assertion code:
111115
^\s*raise AssertionError\b
112116
^\s*raise NotImplementedError\b
113117
^\s*return NotImplemented\b
114118
^\s*raise$
115-
# Don't complain if non-runnable code isn't run:
116119
^if __name__ == ['"]__main__['"]:$
117120
118121
[coverage:paths]

0 commit comments

Comments
 (0)