@@ -2,6 +2,12 @@ name: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.rr)
2
2
3
3
variables :
4
4
" System.PreferGit " : true
5
+ CI_NAME : Azure Pipelines
6
+ CI_BUILD_ID : $(Build.BuildId)
7
+ CI_BUILD_URL : " https://toxdev.visualstudio.com/tox/_build/results?buildId=$(Build.BuildId)"
8
+ GIT_BRANCH : $(Build.SourceBranch)
9
+ GIT_COMMIT_SHA : $(Build.SourceVersion)
10
+ PYTEST_ADDOPTS : " -vra --showlocals"
5
11
6
12
trigger :
7
13
batch : true
@@ -23,63 +29,155 @@ trigger:
23
29
- tasks/*
24
30
25
31
jobs :
32
+ - job : notify_build_start
33
+ pool : {vmImage: 'Ubuntu 16.04'}
34
+ steps :
35
+ - script : |
36
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && \
37
+ chmod +x ./cc-test-reporter && \
38
+ ./cc-test-reporter before-build
39
+ displayName: notify code climate of new build
40
+
26
41
- template : azure-run-tox-env.yml
27
- parameters : {name: check_code_style, tox: "fix-lint", python: '3.7', image: 'Ubuntu 16.04'}
42
+ parameters : {tox: fix_lint, python: 3.7}
43
+ - template : azure-run-tox-env.yml
44
+ parameters : {tox: docs, python: 3.7}
45
+ - template : azure-run-tox-env.yml
46
+ parameters : {tox: package_description, python: 3.7}
47
+
28
48
- template : azure-run-tox-env.yml
29
- parameters : {name: generate_docs, tox: docs , python: '3.7', image: 'Ubuntu 16.04' }
49
+ parameters : {tox: pypy , python: pypy, os: linux }
30
50
- template : azure-run-tox-env.yml
31
- parameters : {name: check_package_long_description, tox: "package-description" , python: '3.7', image: 'Ubuntu 16.04' }
51
+ parameters : {tox: pypy3 , python: pypy3, os: linux }
32
52
33
53
- template : azure-run-tox-env.yml
34
- parameters : {name: windows_37 , python: ' 3.7', image: 'vs2017-win2016' }
54
+ parameters : {tox: py37 , python: 3.7, os: windows }
35
55
- template : azure-run-tox-env.yml
36
- parameters : {name: windows_36 , python: ' 3.6', image: 'vs2017-win2016' }
56
+ parameters : {tox: py36 , python: 3.6, os: windows }
37
57
- template : azure-run-tox-env.yml
38
- parameters : {name: windows_35 , python: ' 3.5', image: 'vs2017-win2016' }
58
+ parameters : {tox: py35 , python: 3.5, os: windows }
39
59
- template : azure-run-tox-env.yml
40
- parameters : {name: windows_34 , python: ' 3.4', image: 'vs2017-win2016' }
60
+ parameters : {tox: py34 , python: 3.4, os: windows }
41
61
- template : azure-run-tox-env.yml
42
- parameters : {name: windows_27 , python: ' 2.7', image: 'vs2017-win2016' }
62
+ parameters : {tox: py27 , python: 2.7, os: windows }
43
63
44
64
- template : azure-run-tox-env.yml
45
- parameters : {name: linux_37 , python: ' 3.7', image: 'Ubuntu 16.04' }
65
+ parameters : {tox: py37 , python: 3.7, os: linux }
46
66
- template : azure-run-tox-env.yml
47
- parameters : {name: linux_36 , python: ' 3.6', image: 'Ubuntu 16.04' }
67
+ parameters : {tox: py36 , python: 3.6, os: linux }
48
68
- template : azure-run-tox-env.yml
49
- parameters : {name: linux_35 , python: ' 3.5', image: 'Ubuntu 16.04' }
69
+ parameters : {tox: py35 , python: 3.5, os: linux }
50
70
- template : azure-run-tox-env.yml
51
- parameters : {name: linux_34 , python: ' 3.4', image: 'Ubuntu 16.04' }
71
+ parameters : {tox: py34 , python: 3.4, os: linux }
52
72
- template : azure-run-tox-env.yml
53
- parameters : {name: linux_27 , python: ' 2.7', image: 'Ubuntu 16.04' }
73
+ parameters : {tox: py27 , python: 2.7, os: linux }
54
74
55
75
- template : azure-run-tox-env.yml
56
- parameters : {name: macOS_36 , python: ' 3.6', image: 'macOS 10.13' }
76
+ parameters : {tox: py36 , python: 3.6, os: macOs }
57
77
58
- - job : tests_done
78
+ - job : report_coverage
59
79
pool : {vmImage: 'Ubuntu 16.04'}
60
- condition : always()
80
+ condition : and( always(), eq(variables['system.pullrequest.isfork'], false) )
61
81
dependsOn :
62
- - windows_37
63
- - windows_36
64
- - windows_35
65
- - windows_34
66
- - windows_27
67
- - linux_37
68
- - linux_36
69
- - linux_35
70
- - linux_34
71
- - linux_27
72
- - macOS_36
82
+ - windows_py37
83
+ - windows_py36
84
+ - windows_py35
85
+ - windows_py34
86
+ - windows_py27
87
+ - linux_py37
88
+ - linux_py36
89
+ - linux_py35
90
+ - linux_py34
91
+ - linux_py27
92
+ - linux_pypy3
93
+ - linux_pypy
94
+ - macOS_py36
73
95
steps :
74
- - script : echo "done"
75
- displayName : running tests done
96
+ - task : DownloadBuildArtifacts@0
97
+ displayName : download coverage files for run
98
+ inputs :
99
+ buildType : current
100
+ downloadType : specific
101
+ itemPattern : coverage-*/*
102
+ downloadPath : $(Build.StagingDirectory)
103
+
104
+ - task : UsePythonVersion@0
105
+ displayName : setup python
106
+ inputs :
107
+ versionSpec : 3.7
108
+
109
+ - script : |
110
+ python -c '
111
+ from pathlib import Path
112
+ import shutil
113
+
114
+ from_folder = Path("$(Build.StagingDirectory)")
115
+ destination_folder = Path("$(System.DefaultWorkingDirectory)") / ".tox"
116
+ destination_folder.mkdir()
117
+ for coverage_file in from_folder.glob("*/.coverage"):
118
+ destination = destination_folder / f".coverage.{coverage_file.parent.name[9:]}"
119
+ print(f"{coverage_file} copy to {destination}")
120
+ shutil.copy(str(coverage_file), str(destination))'
121
+ displayName: move coverage files into .tox
122
+
123
+ - script : ' python -m pip install -U tox --pre'
124
+ displayName : install tox
125
+
126
+ - script : ' python -m tox -e py --sdistonly'
127
+ displayName : generate version.py
128
+
129
+ - script : ' python -m tox -e coverage'
130
+ displayName : create coverag report via tox
131
+
132
+ - task : PublishCodeCoverageResults@1
133
+ displayName : publish overall coverage report to Azure
134
+ inputs :
135
+ codeCoverageTool : ' cobertura'
136
+ summaryFileLocation : ' $(System.DefaultWorkingDirectory)/.tox/coverage.xml'
137
+ reportDirectory : ' $(System.DefaultWorkingDirectory)/.tox/htmlcov'
138
+ failIfCoverageEmpty : true
139
+
140
+ - script : |
141
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && \
142
+ chmod +x ./cc-test-reporter
143
+ displayName: get code climate binary
144
+
145
+ - script : |
146
+ python -c '
147
+ from xml.etree import ElementTree as et
148
+ from pathlib import Path
149
+ import subprocess
150
+
151
+ from_folder = Path("$(Build.StagingDirectory)")
152
+ for counter, coverage_file in enumerate(from_folder.glob("*/coverage.xml")):
153
+ key = coverage_file.parent.name[9:]
154
+ print(f"{counter}){coverage_file}")
155
+
156
+ # first we need to fix the root file
157
+ tree = et.parse(str(coverage_file))
158
+ tree.getroot().find('sources/source').text = "$(System.DefaultWorkingDirectory)"
159
+ tree.write(str(coverage_file))
160
+
161
+ cmd = ["$(System.DefaultWorkingDirectory)/cc-test-reporter", "format-coverage",
162
+ str(coverage_file), "-t", "coverage.py", -o
163
+ f"$(Build.StagingDirectory)/code-climate.{key}.json"]
164
+ print(f"\t{cmd}")
165
+ subprocess.check_call(cmd)'
166
+ displayName: format coverage.xml-s for code climate
167
+
168
+ - script : |
169
+ ./cc-test-reporter sum-coverage --output - \
170
+ --parts 13 \
171
+ $(Build.StagingDirectory)/code-climate.*.json | \
172
+ ./cc-test-reporter upload-coverage --input -
173
+ displayName: publish code climate
76
174
77
175
- job : publish
78
176
dependsOn :
79
- - tests_done
80
- - check_code_style
81
- - generate_docs
82
- - check_package_long_description
177
+ - report_coverage
178
+ - linux_fix_lint
179
+ - linux_docs
180
+ - linux_package_description
83
181
condition : and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
84
182
pool : {vmImage: 'Ubuntu 16.04'}
85
183
steps :
90
188
displayName : Package and publish to PyPI
91
189
inputs :
92
190
pypiConnection : pypi-conn
93
- packageDirectory : ' $(System.DefaultWorkingDirectory)'
191
+ packageDirectory : $(System.DefaultWorkingDirectory)
94
192
alsoPublishWheel : true
0 commit comments