forked from rigetti/pyquil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
212 lines (184 loc) · 5.21 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
default:
image: python:3.7
tags:
- ec2-docker
stages:
- test
- deploy
- docker
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- .cache/pip
- .venv
.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
####################################################################################################
# RELEASE-ONLY JOBS
####################################################################################################
.pypi-publish:
stage: deploy
script:
- pip install --upgrade poetry
- *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
PyPI Publish:
services: []
extends: .pypi-publish
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+(-rc\.\d+)?$/
Docker Publish (RC):
extends: .docker-publish
needs: ["PyPI Publish"]
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+-rc\.\d+$/
variables:
EXTRA_TAG: rc
Docker Publish (Final):
services: []
extends: .docker-publish
needs: ["PyPI Publish"]
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
variables:
EXTRA_TAG: latest