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