-
Notifications
You must be signed in to change notification settings - Fork 20
/
run-tox-env.yml
267 lines (233 loc) · 13.5 KB
/
run-tox-env.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
parameters:
envs: []
coverage: false
pytest: true
default_python: '3.x'
jobs:
- ${{ each env in parameters.envs }}:
- ${{ each env_pair in env }}:
- ${{ if or(startsWith(env_pair.key, 'linux'), eq(env_pair.key, 'manylinux'), eq(env_pair.key, 'macos'), eq(env_pair.key, 'windows')) }}:
- job: ${{ coalesce(env['name'], variables['Agent.Id']) }}
variables:
friendly_name: '${{ coalesce(env.name, env_pair.value) }} [${{ env_pair.key }}]'
posargs: ${{ coalesce(env['posargs'], parameters.posargs) }}
toxverspec: ${{ coalesce(env['toxverspec'], parameters.toxverspec, '') }}
toxdeps: ${{ coalesce(env['toxdeps'], parameters.toxdeps) }}
toxargs: ${{ coalesce(env['toxargs'], parameters.toxargs) }}
xvfb: ${{ and(coalesce(env['xvfb'], parameters.xvfb, false), eq(env_pair.key, 'linux')) }}
mesaopengl: ${{ and(coalesce(env['mesaopengl'], parameters.mesaopengl, false), eq(env_pair.key, 'windows')) }}
pytest: ${{ or(eq(coalesce(env['pytest'], parameters.pytest), 'true'), contains(env_pair.value, 'test')) }}
# Setup python version
${{ if startsWith(env_pair.value, 'py27') }}:
python: '2.7'
manylinux_python: ${{ format('/opt/python/cp{0}-cp{0}m/bin/python', replace(variables.python, '.', '')) }}
${{ if startsWith(env_pair.value, 'py35') }}:
python: '3.5'
manylinux_python: ${{ format('/opt/python/cp{0}-cp{0}m/bin/python', replace(variables.python, '.', '')) }}
${{ if startsWith(env_pair.value, 'py36') }}:
python: '3.6'
manylinux_python: ${{ format('/opt/python/cp{0}-cp{0}m/bin/python', replace(variables.python, '.', '')) }}
${{ if startsWith(env_pair.value, 'py37') }}:
python: '3.7'
manylinux_python: ${{ format('/opt/python/cp{0}-cp{0}m/bin/python', replace(variables.python, '.', '')) }}
${{ if startsWith(env_pair.value, 'py38') }}:
python: '3.8'
${{ if startsWith(env_pair.value, 'py39') }}:
python: '3.9'
${{ if startsWith(env_pair.value, 'py310') }}:
python: '3.10'
${{ if startsWith(env_pair.value, 'py311') }}:
python: '3.11'
${{ if startsWith(env_pair.value, 'py312') }}:
python: '3.12'
# Docker and manylinux
${{ if eq(env_pair.key, 'linux32') }}:
setarch: 'linux32'
${{ if not(eq(env_pair.key, 'linux32')) }}:
setarch: ''
${{ if or(eq(env_pair.key, 'linux32'), eq(env_pair.key, 'manylinux')) }}:
manylinux_container: ${{ coalesce(env['manylinux_image'], 'manylinux2010_i686') }}
manylinux_image: ${{ format('quay.io/pypa/{0}:latest', variables.manylinux_container) }}
${{ if not(variables.manylinux_python) }}:
manylinux_python: ${{ format('/opt/python/cp{0}-cp{0}/bin/python', replace(variables.python, '.', '')) }}
docker_python_exec: ${{ coalesce(env['docker_python'], variables.manylinux_python, '/opt/python/cp27-cp27m/bin/python') }}
docker_image: ${{ coalesce(env['docker_image'], variables.manylinux_image, '') }}
docker_name: ${{ coalesce(env['docker_name'], replace(replace(env['docker_image'], ':', '_'), '/', '_'), variables.manylinux_container) }}
${{ if eq(env_pair.key, 'windows') }}:
source: 'call'
${{ if not(eq(env_pair.key, 'windows')) }}:
source: 'source'
${{ if and(eq(variables.pytest, 'true'), eq(env_pair.key, 'windows')) }}:
pytest_flag: '--junitxml=junit\test-results.xml --cov-report=xml:$(System.DefaultWorkingDirectory)\coverage.xml'
${{ if and(eq(variables.pytest, 'true'), not(eq(env_pair.key, 'windows'))) }}:
pytest_flag: '--junitxml=junit/test-results.xml --cov-report=xml:$(System.DefaultWorkingDirectory)/coverage.xml'
${{ if not(eq(variables.pytest, 'true')) }}:
pytest_flag: ''
${{ if variables.docker_image }}:
displayName: '${{ coalesce(env.name, env_pair.value) }} [docker ${{ coalesce(variables.manylinux_container, variables.docker_image) }}]'
${{ if not(variables.docker_image) }}:
displayName: ${{ variables.friendly_name }}
pool:
${{ if eq(env_pair.key, 'macos') }}:
vmImage: macos-latest
${{ if or(startsWith(env_pair.key, 'linux'), eq(env_pair.key, 'manylinux')) }}:
vmImage: ubuntu-latest
${{ if eq(env_pair.key, 'windows') }}:
vmImage: windows-latest
steps:
- checkout: self
lfs: true
submodules: ${{ coalesce(parameters.submodules, true) }}
fetchDepth: 999999999
- ${{ if variables.docker_image }}:
- ${{ if env['docker_cache'] }}:
- task: Cache@2
displayName: Processing Docker cache
inputs:
key: 'docker | "$(Agent.OS)" | "${{ variables.docker_image }}"'
path: $(Pipeline.Workspace)/docker
cacheHitVar: CACHE_RESTORED
- script: |
docker load -i $(Pipeline.Workspace)/docker/cache.tar
displayName: Docker restore
condition: and(not(canceled()), eq(variables.CACHE_RESTORED, 'true'))
- script: |
docker pull ${{ variables.docker_image }}
mkdir -p $(Pipeline.Workspace)/docker
docker save -o $(Pipeline.Workspace)/docker/cache.tar ${{ variables.docker_image }}
displayName: Docker save
condition: and(not(canceled()), or(failed(), ne(variables.CACHE_RESTORED, 'true')))
- bash: docker run -v $PWD:/project -i --name ${{ variables.docker_name }} -d ${{ variables.docker_image }} /bin/bash
displayName: Start up Docker container
- ${{ if env['cache_dirs'] }}:
- ${{ each cache in env['cache_dirs'] }}:
- task: Cache@2
inputs: ${{ cache }}
displayName: Processing cache at ${{ cache['path'] }}
- ${{ elseif parameters.cache_dirs }}:
- ${{ each cache in parameters.cache_dirs }}:
- task: Cache@2
inputs: ${{ cache }}
displayName: Processing cache at ${{ cache['path'] }}
- ${{ if env['libraries'] }}:
- template: install-libraries.yml
parameters:
libraries: ${{ env['libraries'] }}
env_key: ${{ env_pair.key }}
docker_name: ${{ variables.docker_name }}
setarch: ${{ variables.setarch }}
- ${{ elseif parameters.libraries }}:
- template: install-libraries.yml
parameters:
libraries: ${{ parameters.libraries }}
env_key: ${{ env_pair.key }}
docker_name: ${{ variables.docker_name }}
setarch: ${{ variables.setarch }}
- ${{ if not(variables.docker_image) }}:
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ coalesce(variables['python'], parameters.default_python) }}
- ${{ if eq(variables.mesaopengl, 'true') }}:
- bash: git clone --depth 1 https://github.com/vtkiorg/gl-ci-helpers.git
displayName: Getting OpenGL helper script
- powershell: gl-ci-helpers\appveyor\install_opengl.ps1
displayName: Installing OpenGL library
- bash: rm -r gl-ci-helpers
displayName: Cleaning up OpenGL helper script
- ${{ if eq(variables.xvfb, 'true') }}:
- bash: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid \
--make-pidfile --background --exec /usr/bin/Xvfb \
-- :99 -screen 0 1920x1200x24 -ac \
+extension GLX +render -noreset
displayName: Starting Xvfb
- ${{ if contains(env_pair.value, 'conda') }}:
- ${{ if eq(env_pair.key, 'macos') }}:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
- bash: sudo chown -R $USER $CONDA
displayName: Take ownership of conda installation
- ${{ if eq(env_pair.key, 'linux') }}:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
- ${{ if eq(env_pair.key, 'windows') }}:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Add conda to PATH
- script: |
conda create --yes --quiet --name testenv
${{ variables.source }} activate testenv
conda install --yes --quiet --name testenv python=${{ variables.python }} pip
displayName: Create and activate conda env
- bash: python -m pip install --upgrade 'tox-conda!=0.8.0' ${{ variables.toxdeps }}
displayName: install tox-conda
- ${{ if variables.docker_image }}:
- script: docker exec -i -w /project ${{ variables.docker_name }} ${{ variables.setarch }} ${{ variables.docker_python_exec }} -m pip install --upgrade "tox ${{ variables.toxverspec }}" ${{ variables.toxdeps }}
displayName: Install tox
- script: docker exec -i -w /project ${{ variables.docker_name }} ${{ variables.setarch }} ${{ variables.docker_python_exec }} -m tox -e ${{ env_pair.value }} ${{ variables['toxargs'] }} -- ${{ variables['pytest_flag'] }} ${{ variables['posargs'] }}
displayName: Running tox
- ${{ if not(variables.docker_image) }}:
- script: python -m pip install "tox${{ variables.toxverspec }}" ${{ variables.toxdeps }}
displayName: Install tox
- script: python -m tox -e ${{ env_pair.value }} ${{ variables['toxargs'] }} -- ${{ variables['pytest_flag'] }} ${{ variables['posargs'] }}
displayName: Running tox
${{ if eq(variables.xvfb, 'true') }}:
env:
DISPLAY: :99.0
${{ if and(eq(env_pair.key, 'macos'),contains(env_pair.value, 'conda')) }}:
env:
CONDA_BUILD_SYSROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
- ${{ if eq(coalesce(env['coverage'], parameters.coverage), 'codecov') }}:
- ${{ if or(eq(env_pair.key, 'macos'), startsWith(env_pair.key, 'linux'), eq(env_pair.key, 'manylinux')) }}:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://uploader.codecov.io/latest/${OSNAME}/codecov
curl -Os https://uploader.codecov.io/latest/${OSNAME}/codecov.SHA256SUM
curl -Os https://uploader.codecov.io/latest/${OSNAME}/codecov.SHA256SUM.sig
# chain all the following commands so the task exits if any fail
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM && \
shasum -a 256 -c codecov.SHA256SUM && \
chmod +x codecov && \
./codecov -n ${{ variables['friendly_name'] }}
displayName: Running codecov
condition: succeededOrFailed()
env:
${{ if eq(env_pair.key, 'macos') }}:
OSNAME: macos
${{ if or(startsWith(env_pair.key, 'linux'), eq(env_pair.key, 'manylinux')) }}:
OSNAME: linux
${{ if ne(variables.CODECOV_TOKEN, '') }}:
CODECOV_TOKEN: $(CODECOV_TOKEN)
- ${{ if eq(env_pair.key, 'windows') }}:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://keybase.io/codecovsecurity/pgp_keys.asc -OutFile codecov.asc
gpg.exe --import codecov.asc
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM -Outfile codecov.exe.SHA256SUM
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM.sig -Outfile codecov.exe.SHA256SUM.sig
gpg.exe --verify codecov.exe.SHA256SUM.sig codecov.exe.SHA256SUM
If ($(Compare-Object -ReferenceObject $(($(certUtil -hashfile codecov.exe SHA256)[1], "codecov.exe") -join " ") -DifferenceObject $(Get-Content codecov.exe.SHA256SUM)).length -eq 0) { .\codecov.exe -n ${{ variables['friendly_name'] }} } Else {exit 1}
errorActionPreference: 'stop'
displayName: Running codecov
condition: succeededOrFailed()
${{ if ne(variables.CODECOV_TOKEN, '') }}:
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
- ${{ if eq(variables['pytest'], 'true') }}:
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Publish test results for ${{ variables.friendly_name }}'
- ${{ if eq(coalesce(env['coverage'], parameters.coverage), 'azure') }}:
- task: PublishCodeCoverageResults@1
condition: succeededOrFailed()
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'