-
Notifications
You must be signed in to change notification settings - Fork 13
317 lines (307 loc) · 10.7 KB
/
build_and_test.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
name: Build and test
on:
pull_request:
branches:
- main
push:
branches:
- main
- 'wheel/**'
- 'runci/**'
release:
types:
- created
- edited
schedule:
# 04:00 every Tuesday morning
- cron: '0 4 * * 2'
workflow_dispatch:
inputs:
run-integration-tests:
description: "Please type 'yes' to run also the integration tests (default 'no')."
required: true
default: "no"
env:
PYTKET_REMOTE_QUANTINUUM_USERNAME: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD }}
PYTKET_REMOTE_QUANTINUUM_USERNAME_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME_QA }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA }}
jobs:
quantinuum-checks:
name: Quantinuum - Build and test module
strategy:
matrix:
os: ['ubuntu-latest', 'macos-14', 'windows-latest']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
submodules: true
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*
- name: Set up Python 3.10
if: github.event_name == 'push' || github.event_name == 'schedule'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build and test (3.10)
if: github.event_name == 'push' || github.event_name == 'schedule'
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build and test (3.11) mypy
shell: bash
if: |
matrix.os == 'macos-14' &&
(
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) ||
github.event_name == 'release' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'no'
)
)
run: |
./.github/workflows/build-test mypy
- name: Build and test (3.11) nomypy
if: |
matrix.os != 'macos-14' &&
(
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) ||
github.event_name == 'release' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'no'
)
)
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Build and test including integration (3.11) nomypy
if: |
matrix.os == 'ubuntu-latest' &&
(
(
github.event_name == 'push' &&
(
contains(github.ref_name, 'main') ||
contains(github.ref_name, 'runci/')
)
) ||
github.event_name == 'schedule' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'yes'
)
)
shell: bash
run: |
./.github/workflows/build-test nomypy integration
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Set up Python 3.12
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build and test (3.12)
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
shell: bash
run: |
./.github/workflows/build-test nomypy
- uses: actions/upload-artifact@v4
if: github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel')
with:
name: artefact-${{ matrix.os }}
path: wheelhouse/
- name: Install poetry
run: pip install poetry
- name: Install docs dependencies
if: (matrix.os == 'ubuntu-latest') && (github.event_name == 'pull_request' || github.event_name == 'schedule' )
run: |
cd docs && bash ./install.sh
for w in `find wheelhouse/ -type f -name "*.whl"` ; do poetry run pip install $w ; done
- name: Build docs
if: (matrix.os == 'ubuntu-latest') && (github.event_name == 'pull_request' || github.event_name == 'schedule' )
timeout-minutes: 20
run: |
cd docs && poetry run bash ./build-docs.sh
pecos_checks:
name: Run local-emulator tests
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install module
run: python -m pip install -v -e .[pecos]
- name: Install test requirements
run: python -m pip install --pre -r tests/test-requirements.txt
- name: Run local-emulator tests
env:
PYTKET_RUN_REMOTE_TESTS: 1
working-directory: ./tests
run: |
pytest integration/local_emulator_test.py
pytest integration/local_emulator_multithreading_test.py
qa_checks:
name: Run backend tests with QA endpoint
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install module
run: python -m pip install -v -e .
- name: Install test requirements
run: python -m pip install --pre -r tests/test-requirements.txt
- name: Run tests with QA and prod endpoint
env:
PYTKET_RUN_REMOTE_TESTS: 1
PYTKET_REMOTE_QUANTINUUM_USERNAME_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME_QA }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA }}
PYTKET_REMOTE_QUANTINUUM_EMULATORS_ONLY: 1
working-directory: ./tests
run: pytest integration/
calendar_visualisation_tests:
name: Run calendar visualisation test
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install module
run: python -m pip install -v -e .
- name: Install test requirements
run: |
python -m pip install --pre -r tests/test-requirements.txt
pip install pytest-mpl
- name: Run tests with mpl test
env:
PYTKET_RUN_MPL_TESTS: 1
PYTKET_REMOTE_QUANTINUUM_USERNAME_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME_QA }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA }}
working-directory: ./tests
run: |
pytest --mpl-generate-path=integration/baseline
pytest integration/ --mpl
prod_checks:
name: Run backend tests with QA and prod endpoint
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || contains(github.ref_name, 'runci/prod/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install module
run: python -m pip install -v -e .
- name: Install test requirements
run: python -m pip install --pre -r tests/test-requirements.txt
- name: Run tests with QA and prod endpoint
env:
PYTKET_RUN_REMOTE_TESTS: 1
PYTKET_RUN_REMOTE_TESTS_PROD: 1
PYTKET_REMOTE_QUANTINUUM_USERNAME: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD }}
PYTKET_REMOTE_QUANTINUUM_USERNAME_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME_QA }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA }}
PYTKET_REMOTE_QUANTINUUM_EMULATORS_ONLY: 1
working-directory: ./tests
run: pytest integration/
- name: Run tests with mpl test
env:
PYTKET_RUN_MPL_TESTS: 1
PYTKET_REMOTE_QUANTINUUM_USERNAME: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME }}
PYTKET_REMOTE_QUANTINUUM_PASSWORD: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD }}
working-directory: ./tests
run: |
pip install pytest-mpl
pytest integration/ --mpl
publish_to_pypi:
name: Publish to pypi
if: github.event_name == 'release'
needs: quantinuum-checks
runs-on: ubuntu-latest
steps:
- name: Download all wheels
# downloading all three files into the wheelhouse
# all files are identical, so there will only be one file
uses: actions/download-artifact@v4
with:
path: wheelhouse
pattern: artefact-*
merge-multiple: true
- name: Put them all in the dist folder
run: |
mkdir dist
for w in `find wheelhouse/ -type f -name "*.whl"` ; do cp $w dist/ ; done
- name: Publish wheels
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PYTKET_QUANTINUUM_API_TOKEN }}
verbose: true
build_docs:
name: Build docs
if: github.event_name == 'release'
needs: publish_to_pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
submodules: true
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: wheelhouse
- name: Install pip, wheel
run: pip install -U pip wheel
- name: Install poetry
run: pip install poetry
- name: Install extension
run: for w in `find wheelhouse/ -type f -name "*.whl"` ; do poetry run pip install $w ; done
- name: Install docs dependencies
run: |
cd docs
bash ./install.sh
- name: Build docs
timeout-minutes: 20
run: |
cd docs
poetry run bash ./build-docs.sh