forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
263 lines (233 loc) · 9.66 KB
/
azure-pipelines.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
# Trigger types. This needs to include all the triggers for the different
# pipelines we might want to run.
#
# Each of these individually triggers the pipeline compilation step, but it's
# the templating expressions in the `stages` list that actually set what runs.
trigger:
branches:
include:
- 'main'
- 'stable/*'
tags:
include:
- '*'
pr:
autoCancel: true
branches:
include:
- '*'
schedules:
- cron: "20 6 * * *"
displayName: "Complete matrix test"
branches:
include: [ "main", "stable/*" ]
always: false # Only run if the code changed since the last cron sync.
# Configuration. In theory a manual trigger on the Azure website or embedding
# this pipeline as a template can override these, but we're not interested in
# that. We just want to give names to things to make it easier to read.
parameters:
- name: "supportedPythonVersions"
displayName: "All supported versions of Python"
type: object
default: ["3.7", "3.8", "3.9", "3.10"]
- name: "minimumPythonVersion"
displayName: "Minimum supported version of Python"
type: string
default: "3.7"
- name: "maximumPythonVersion"
displayName: "Maximum supported version of Python"
type: string
default: "3.10"
- name: "minimumRustVersion"
displayName: "Minimum supported version of Rust"
type: string
default: "1.56.1"
# These two versions of Python can be chosen somewhat arbitrarily, but we get
# slightly better coverage per PR if they're neither the maximum nor minimum
# supported versions.
- name: "branchPushPythonVersion"
displayName: "Version of Python to run simple tests on pushes to protected branches"
type: string
default: "3.9"
- name: "tutorialsPythonVersion"
displayName: "Version of Python to use to run the tutorials job"
type: string
default: "3.8"
- name: "documentationPythonVersion"
displayName: "Version of Python to use to build Sphinx documentation"
type: string
default: "3.9"
# Conditional compilation logic. This is all the logic for "what to run"; each
# stage in turn delegates to various templates in ".azure" that provide the
# information on "how to run" them.
#
# The conditional conditions use the template-expression syntax `${{ }}` so only
# the relevant stages even appear in the job list. The documentation on the
# expression syntax is here:
#
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops
#
# Not all variables are available at template-expansion time - this happens
# before any machine is provisioned, so mostly you can access things from
# GitHub, but nothing about the actual machine. This is the list of variables
# (look in the "available in templates" column):
#
# https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
#
# The main differentiator is `variables['Build.Reason']`, which contains the
# trigger type:
# - cron (`Schedule`)
# - push to a git reference like a branch or tag (`IndividualCI`)
# - push to a pull request (`PullRequest`)
# For `IndividualCI` (push/merge to a branch/tag on Qiskit/qiskit-terra), you
# need to examine `variables['Build.SourceBranch']` to determine whether it's a
# branch or a tag.
stages:
# Nightly cron job.
- ${{ if eq(variables['Build.Reason'], 'Schedule') }}:
- stage: "Nightly"
displayName: "Nightly complete matrix tests"
jobs:
- ${{ each version in parameters.supportedPythonVersions }}:
- template: ".azure/test-linux.yml"
parameters:
pythonVersion: ${{ version }}
testQPY: false
testImages: false
- template: ".azure/test-macos.yml"
parameters:
pythonVersion: ${{ version }}
- template: ".azure/test-windows.yml"
parameters:
pythonVersion: ${{ version }}
- stage: "Nightly_Failure"
displayName: "Comment on nightly failure"
dependsOn: "Nightly"
condition: failed()
pool: {vmImage: 'ubuntu-latest'}
jobs:
- job: "Comment"
steps:
- task: GitHubComment@0
inputs:
gitHubConnection: Qiskit
repositoryName: ${{ variables['Build.Repository.Name'] }}
id: 7864
comment: Nightly test job failed at commit $(Build.SourceVersion). View the logs at $(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId).
# Full PR suite.
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
# The preliminary stage should be small in both total runtime (including
# provisioning) and resources required. About half of PR commits result in
# a CI failure, and over 90% of these are in linting, documention or a test
# failure that would affect _any_ OS or Python version. The goal in the
# first stage is to catch the vast majority of failures with minimal cost.
- stage: "Lint_Docs_Prelim_Tests"
displayName: "Preliminary tests"
jobs:
- template: ".azure/lint-linux.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
- template: ".azure/docs-linux.yml"
parameters:
pythonVersion: ${{ parameters.documentationPythonVersion }}
- template: ".azure/test-linux.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
testQPY: false
testImages: false
rustVersion: ${{ parameters.minimumRustVersion }}
# The rest of the PR pipeline is to test the oldest and newest supported
# versions of Python, along with the integration tests (via the tutorials).
# It's very rare for a failure to be specific to an intermediate version of
# Python, so we just catch those in the cron-job pipeline to reduce the
# amount of resources used.
- stage: "Tutorials_and_Tests"
displayName: "Main tests"
dependsOn: "Lint_Docs_Prelim_Tests"
jobs:
- template: ".azure/tutorials-linux.yml"
parameters:
pythonVersion: ${{ parameters.tutorialsPythonVersion }}
- template: ".azure/test-linux.yml"
parameters:
pythonVersion: ${{ parameters.maximumPythonVersion }}
testQPY: true
testImages: true
installFromSdist: true
- template: ".azure/test-macos.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
- template: ".azure/test-macos.yml"
parameters:
pythonVersion: ${{ parameters.maximumPythonVersion }}
- template: ".azure/test-windows.yml"
parameters:
pythonVersion: ${{ parameters.minimumPythonVersion }}
- template: ".azure/test-windows.yml"
parameters:
pythonVersion: ${{ parameters.maximumPythonVersion }}
# Push to main or the stable branches. The triggering branches are set in the
# triggers at the top of this file.
- ${{ if and(eq(variables['Build.Reason'], 'IndividualCI'), startsWith(variables['Build.SourceBranch'], 'refs/heads/')) }}:
- stage: "Push"
jobs:
- template: ".azure/test-linux.yml"
parameters:
pythonVersion: ${{ parameters.branchPushPythonVersion }}
testQPY: true
testImages: true
# Push to a tag. The triggering tags are set in the triggers at the top of
# this file.
- ${{ if and(eq(variables['Build.Reason'], 'IndividualCI'), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) }}:
- stage: "Deploy"
jobs:
- template: ".azure/wheels.yml"
parameters:
jobName: "linux"
pool: {vmImage: 'ubuntu-latest'}
- template: ".azure/wheels.yml"
parameters:
jobName: "macos"
pool: {vmImage: 'macOS-11'}
- template: ".azure/wheels.yml"
parameters:
jobName: "macos_arm"
pool: {vmImage: 'macOS-11'}
env:
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_ARCHS_MACOS: arm64 universal2
CIBW_ENVIRONMENT: >-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
PYO3_CROSS_LIB_DIR="/Library/Frameworks/Python.framework/Versions/$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')"
- template: ".azure/wheels.yml"
parameters:
jobName: "windows"
pool: {vmImage: 'windows-latest'}
setupPython:
- ${{ each version in parameters.supportedPythonVersions }}:
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ version }}
architecture: x86
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ version }}
architecture: x64
- job: 'sdist'
pool: {vmImage: 'ubuntu-latest'}
steps:
- task: UsePythonVersion@0
- bash: |
set -e
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools_rust
python setup.py sdist
- task: PublishBuildArtifacts@1
inputs: {pathtoPublish: 'dist'}
condition: succeededOrFailed()
- bash: |
python -m pip install --upgrade twine
twine upload dist/*
env:
TWINE_USERNAME: "qiskit"
TWINE_PASSWORD: $(TWINE_PASSWORD)