forked from rigetti/pyquil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
259 lines (222 loc) · 6.77 KB
/
.gitlab-ci.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
default:
image: python:3.7
tags:
- ec2-docker
stages:
- test
- deploy
- docker
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- .cache/pip
- .venv
.install-dephell: &install-dephell # Install dephell to auto-generate setup.py
- curl -L https://raw.githubusercontent.com/rigetti/dephell/master/install.py | python
.install-npm: &install-npm
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
- apt-get update
- apt-get install -f -y nodejs
- npm i
.publish-pypi-public: &publish-pypi-public
- poetry config http-basic.pypi rigetti $PUBLIC_PYPI_PASSWORD
- poetry publish --build
.publish-pypi-test: &publish-pypi-test
- poetry config repositories.testpypi https://test.pypi.org/legacy/
- poetry config http-basic.testpypi rigetti $TEST_PYPI_PASSWORD
- poetry publish --build -r testpypi
# global build variables
variables:
IMAGE: rigetti/forest
QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL: "http://qvm:5000"
QCS_SETTINGS_APPLICATIONS_PYQUIL_QUILC_URL: "tcp://quilc:5555"
# Docker images to spin up along with the various CI jobs
services:
- name: rigetti/qvm
alias: qvm
command: ["-S"]
- name: rigetti/quilc
alias: quilc
command: ["-R"]
####################################################################################################
# EVERY-COMMIT JOBS
####################################################################################################
Test Docs:
stage: test
script:
- . scripts/ci_install_deps
- apt-get update && apt-get install -y pandoc
- poetry run make docs
Style:
stage: test
script:
- . scripts/ci_install_deps
- poetry run make check-all
Test Unit (3.7):
stage: test
image: python:3.7
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make test
Test e2e QPU (3.7):
stage: test
allow_failure: true
image: python:3.7
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make e2e
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "rc"'
Test e2e QVM (3.7):
stage: test
image: python:3.7
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make e2e TEST_QUANTUM_PROCESSOR=2q-qvm
Test Unit (3.8):
stage: test
image: python:3.8
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make test
Test e2e QPU (3.8):
stage: test
allow_failure: true
image: python:3.8
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make e2e
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "rc"'
Test e2e QVM (3.8):
stage: test
image: python:3.8
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make e2e TEST_QUANTUM_PROCESSOR=2q-qvm
Test Unit (3.9):
stage: test
image: python:3.9
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make test
Test e2e QPU (3.9):
stage: test
allow_failure: true
image: python:3.9
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make e2e
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "rc"'
Test e2e QVM (3.9):
stage: test
image: python:3.9
coverage: '/TOTAL.*?(\d+)\%/'
script:
- . scripts/ci_install_deps
- poetry run make e2e TEST_QUANTUM_PROCESSOR=2q-qvm
Coverage:
stage: test
script:
- . scripts/ci_install_deps
- poetry run make coverage
allow_failure: true
####################################################################################################
# BRANCH-ONLY JOBS
####################################################################################################
# NOTE: Running this job requires the following env vars to be set when triggering:
# - GITHUB_TOKEN
# - TEST_PYPI_PASSWORD
PyPI Publish Branch (TestPyPI):
stage: deploy
allow_failure: true
script:
- . scripts/ci_install_deps
- *install-dephell
- *install-npm
- npx semantic-release --branches $CI_COMMIT_BRANCH --dry-run
- export MOST_RECENT_VERSION=$(git describe --abbrev=0 --tags | sed 's/v//')
- export VERSION_TAG="${MOST_RECENT_VERSION}.dev${CI_JOB_ID}"
- poetry version "$VERSION_TAG"
- dephell deps convert
- *publish-pypi-test
rules:
# Skip this job if running on master or rc
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH != "rc"'
when: manual
####################################################################################################
# RELEASE-ONLY JOBS
####################################################################################################
.pypi-publish:
stage: deploy
script:
- . scripts/ci_install_deps
- *install-dephell
- *install-npm
# This performs the semantic-release configured in package.json.
# Depending on the config, this may add a tag and then publish a GitLab/GitHub release.
- npx semantic-release
# This reads the tag chosen by semantic-release
- *publish-pypi-public
- poetry version -s >> version_tag
artifacts:
paths:
- version_tag
.docker-publish:
image: docker:git
stage: docker
tags:
- dockerd
script:
- export VERSION_TAG=$(cat version_tag)
- echo "Publishing images:"
- echo " ${IMAGE}:${VERSION_TAG}"
- echo " ${IMAGE}:${EXTRA_TAG}"
- docker -v
- echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USERNAME} --password-stdin
- docker build --build-arg pyquil_version=${VERSION_TAG} -t ${IMAGE}:${VERSION_TAG} -t ${IMAGE}:${EXTRA_TAG} .
- docker push ${IMAGE}:${VERSION_TAG} && docker push ${IMAGE}:${EXTRA_TAG}
after_script:
- docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE})
- docker run --rm ${IMAGE}:${VERSION_TAG} python -c "from pyquil import get_qc; qvm = get_qc('9q-qvm')" # simple image verification
- docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep ${IMAGE})
# sometimes pyquil isn't ready on PyPI right away, so add a retry if docker build fails
retry:
max: 2
when: script_failure
# PUBLISH RC
# -------------------------------
PyPI Publish (RC):
extends: .pypi-publish
rules:
- if: '$CI_COMMIT_BRANCH == "rc"'
Docker Publish (RC):
extends: .docker-publish
needs: ["PyPI Publish (RC)"]
rules:
- if: '$CI_COMMIT_BRANCH == "rc"'
variables:
EXTRA_TAG: rc
# PUBLISH FINAL RELEASE
# -------------------------------
PyPI Publish (Final):
extends: .pypi-publish
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
when: manual
Docker Publish (Final):
extends: .docker-publish
needs: ["PyPI Publish (Final)"]
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
variables:
EXTRA_TAG: latest