This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrun-tox-env.yml
188 lines (173 loc) · 8.83 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
parameters:
jobs: []
tox_version: "tox"
coverage:
with_toxenv: ""
for_envs: []
dependsOn: []
jobs:
- ${{ each job in parameters.jobs }}:
- job: ${{ coalesce(job.value.name, job.key) }}
dependsOn: ${{ coalesce(job.value.dependsOn, parameters.dependsOn) }}
strategy:
matrix:
${{ if job.value.image }}:
${{ each image in job.value.image }}:
${{ image }}:
${{ if eq(image, 'linux') }}:
image: "ubuntu-latest"
image_name: "linux"
${{ if eq(image, 'windows') }}:
# stay on windows-2019 since windows-latest (2022) has
# problems with building C-extensions
image: "windows-2019"
image_name: "windows"
${{ if eq(image, 'macOs') }}:
image: "macOS-latest"
image_name: "macOs"
${{ if notIn(image, 'macOs', 'linux', 'windows') }}:
image: ${{ coalesce(image, 'ubuntu-latest') }}
image_name: ${{ coalesce(image, 'linux') }}
${{ if not(job.value.image) }}:
linux:
image: "ubuntu-latest"
image_name: "linux"
pool:
vmImage: $[ variables['image'] ]
variables:
TMPDIR: $(Agent.TempDirectory)
PIP_NO_WARN_SCRIPT_LOCATION: "0"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
TOXENV: ${{ coalesce(job.value.toxenv, job.key) }}
PYTHONWARNINGS: "ignore:::pip._internal.cli.base_command"
steps:
# checkout with submodules please
- checkout: self
displayName: checkout source code (with submodules)
submodules: true
# load tox
- task: UsePythonVersion@0
displayName: "tox: get python"
inputs:
versionSpec: "3.8"
addToPath: false
name: toxPython
- script: $(toxPython.pythonLocation)/python -m pip install -U --user pip
displayName: "tox: upgrade pip"
- ${{ if parameters.tox_version }}:
- script:
${{ format('$(toxPython.pythonLocation)/python -m pip install -U --user --force-reinstall {0}',
parameters.tox_version) }}
displayName: "${{ format('tox: install {0} from PyPi', parameters.tox_version) }}"
- ${{ if not(parameters.tox_version) }}:
- script: $(toxPython.pythonLocation)/python -m pip install -U --user --force-reinstall . -v
displayName: "tox: install inline"
# acquire target test Python
- ? ${{ if or(eq(job.key, 'py310'), startsWith(job.key, 'py310-'),
eq(job.key, 'py39'), startsWith(job.key, 'py39-'),
eq(job.key, 'py38'), startsWith(job.key, 'py38-'),
eq(job.key, 'py37'), startsWith(job.key, 'py37-'),
eq(job.key, 'py36'), startsWith(job.key, 'py36-'),
eq(job.key, 'py27'), startsWith(job.key, 'py27-'),
eq(job.key, 'pypy'), startsWith(job.key, 'pypy-'),
eq(job.key, 'pypy3'), startsWith(job.key, 'pypy3-'),
eq(job.value.py, '2.7'), eq(job.value.py, '3.6'), eq(job.value.py, '3.7'),
eq(job.value.py, 'pypy2'), eq(job.value.py, 'pypy3')) }}
: - task: UsePythonVersion@0
displayName: ${{ format('provision target test python {0}', job.key) }}
inputs:
${{ if job.value.py }}:
versionSpec: ${{ job.value.py }}
${{ if not(job.value.py) }}:
${{ if or(eq(job.key, 'py27'), startsWith(job.key, 'py27-')) }}:
versionSpec: "2.7"
${{ if or(eq(job.key, 'py36'), startsWith(job.key, 'py36-')) }}:
versionSpec: "3.6"
${{ if or(eq(job.key, 'py37'), startsWith(job.key, 'py37-')) }}:
versionSpec: "3.7"
${{ if or(eq(job.key, 'py38'), startsWith(job.key, 'py38-')) }}:
versionSpec: "3.8"
${{ if or(eq(job.key, 'py39'), startsWith(job.key, 'py39-')) }}:
versionSpec: "3.9"
${{ if or(eq(job.key, 'py310'), startsWith(job.key, 'py310-')) }}:
versionSpec: "3.10"
${{ if or(eq(job.key, 'pypy'), startsWith(job.key, 'pypy-')) }}:
versionSpec: "pypy2"
${{ if or(eq(job.key, 'pypy3'), startsWith(job.key, 'pypy3-')) }}:
versionSpec: "pypy3"
architecture: ${{ coalesce(job.value.architecture, 'x64') }}
- ${{ if eq(job.value.py, 'brew@python3') }}:
- script: "brew install python@3"
displayName: "provision target test python via homebrew python@3"
- script: echo "##vso[task.setvariable variable=PATH]/usr/local/opt/python@3:$(PATH)"
displayName: add python@3 to PATH
- ${{ if or(eq(job.key, 'jython'), startsWith(job.key, 'jython-')) }}:
- script:
wget
http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7.2/jython-installer-2.7.2.jar
-O $(Agent.ToolsDirectory)/jython.jar
displayName: download jython
- script: java -jar $(Agent.ToolsDirectory)/jython.jar -sd $(Agent.ToolsDirectory)/jython -e demo src doc
displayName: install jython
- script: echo "##vso[task.setvariable variable=PATH]$(Agent.ToolsDirectory)/jython/bin:$(PATH)"
displayName: add to PATH jython
- script: 'jython -c "import sys; print(sys.version_info); print(sys.platform)'
displayName: show jython information
# allow user to run global before
- ${{ if parameters.before }}:
- ${{ parameters.before }}
# allow user to run per job setup
- ${{ if job.value.before }}:
- ${{ job.value.before }}
- script:
'python -c "import sys; import os; print(\"\n\".join(os.environ[\"PATH\"].split(os.pathsep)));
print(sys.version); print(sys.executable);"'
displayName: show python information
- script: $(toxPython.pythonLocation)/python -m tox -av
displayName: "tox: provision and show envs"
# run tests
- script: "$(toxPython.pythonLocation)/python -m tox --notest -vv --skip-missing-interpreters false"
displayName: generate tox test environment
- script: "$(toxPython.pythonLocation)/python -m tox"
displayName: run tox test environment
# upload junit result if present
- bash:
'printf "##vso[task.setVariable variable=junit]" && ([ -f junit.$(TOXENV).xml ] && printf yes || printf
no) && echo ""'
condition: always()
displayName: check if junit file present
workingDirectory: "$(System.DefaultWorkingDirectory)/.tox"
- task: PublishTestResults@2
displayName: publish test results via junit
condition: eq(variables.junit, 'yes')
inputs:
testResultsFormat: "JUnit"
testResultsFiles: ".tox/junit.$(TOXENV).xml"
testRunTitle: "junit-$(Agent.OS)-$(Agent.OSArchitecture)-$(TOXENV)"
# upload coverage artifacts if present
- ${{ if and(parameters.coverage.with_toxenv, containsValue(parameters.coverage.for_envs, job.key)) }}:
- script:
${{ format('$(toxPython.pythonLocation)/python -m tox -e {0} --skip-missing-interpreters false',
parameters.coverage.with_toxenv) }}
displayName: create coverage report
- task: CopyFiles@2
displayName: move coverage files into staging area
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/.tox
contents: |
.coverage
coverage.xml
targetFolder: $(Build.StagingDirectory)
- task: PublishBuildArtifacts@1
displayName: publish coverage file
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
ArtifactName: "coverage-$(Agent.OS)-$(Agent.OSArchitecture)-$(TOXENV)"
- ${{ if job.value.after }}:
- ${{ job.value.after }}
- ${{ if and(parameters.coverage.with_toxenv, parameters.coverage.for_envs) }}:
- template: merge-coverage.yml
parameters:
tox_version: ${{ parameters.tox_version }}
toxenv: ${{ parameters.coverage.with_toxenv }}
dependsOn: ${{ parameters.coverage.for_envs }}