forked from math-comp/math-comp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
435 lines (382 loc) · 10.9 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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# Design:
# - build stage (e.g. docker build -t mathcomp-dev:$IID_$SLUG_coq-8.12 .)
# - all branches (not tags) => push on GitLab registry
# - GitHub PRs => push on GitLab and report back thanks to @coqbot
# - test stage (image: mathcomp-dev:$IID_$SLUG_coq-8.7)
# - script template foreach project (custom CONTRIB_URL, script)
# - jobs foreach project and Coq version (custom COQ_VERSION, CONTRIB_VERSION)
# - deploy stage (only branch "master" and environment deployments "mathcomp/*")
# - pull each built image from GitLab registry => push to Docker Hub
# + scheduled build & deploy for mathcomp/mathcomp-dev:coq-dev
#
# Config for protected environment deployments "mathcomp/*":
# - set vars HUB_REGISTRY, HUB_REGISTRY_USER, HUB_REGISTRY_IMAGE, HUB_TOKEN
#
# Remark:
# - The name chosen for branches should ideally yield different values
# of CI_COMMIT_REF_SLUG.
# - But this is not mandatory as image tags start with "${CI_PIPELINE_IID}_".
# cf. doc:
# - CI_COMMIT_REF_NAME: The branch or tag name for which project is built.
# - CI_COMMIT_REF_SLUG: $CI_COMMIT_REF_NAME lowercased, shortened to 63 bytes,
# and with everything except 0-9 and a-z replaced with -.
# No leading / trailing -. Use in URLs, host names and domain names.
# - CI_PIPELINE_IID: The unique id of the current pipeline scoped to project.
stages:
- build
- deploy
- test
################
#### build stage
################
# set var OPAM_SWITCH (if need be) and COQ_VERSION when using
.make-build:
stage: build
image: docker:latest
services:
- docker:dind
variables:
# This image will be built locally only (not pushed)
IMAGE: "mathcomp-dev:make_coq-${COQ_VERSION}"
before_script:
- echo "${OPAM_SWITCH}"
- echo "${COQ_VERSION}"
script:
- docker build -f Dockerfile.make --pull --build-arg=coq_image="coqorg/coq:${COQ_VERSION}" -t "${IMAGE}" .
except:
refs:
- tags
- merge_requests
- schedules
variables:
- $CRON_MODE == "nightly"
make-coq-latest:
extends: .make-build
variables:
COQ_VERSION: "latest"
# set var OPAM_SWITCH (if need be) when using
.opam-build:
stage: build
image: docker:latest
services:
- docker:dind
variables:
IMAGE: "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}_${CI_COMMIT_REF_SLUG}_${CI_JOB_NAME}"
before_script:
- echo "${OPAM_SWITCH}"
- echo "${CI_JOB_TOKEN}" | docker login -u "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}"
script:
- docker build --pull --build-arg=coq_image="coqorg/${CI_JOB_NAME//-/:}" --build-arg=compiler="${OPAM_SWITCH}" -t "${IMAGE}" .
- docker push "${IMAGE}"
- docker logout "${CI_REGISTRY}"
except:
refs:
- tags
- merge_requests
.opam-build-once:
extends: .opam-build
except:
refs:
- tags
- merge_requests
- schedules
variables:
- $CRON_MODE == "nightly"
coq-8.13:
extends: .opam-build-once
coq-8.14:
extends: .opam-build-once
coq-8.15:
# to be replaced with .opam-build-once when 8.15.0 available
extends: .opam-build
coq-dev:
extends: .opam-build
################
##### test stage
################
# run "make test-suite" (required variable: COQ_VERSION)
.test:
stage: test
image: "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}_${CI_COMMIT_REF_SLUG}_coq-${COQ_VERSION}"
before_script:
- cat /proc/{cpu,mem}info || true
# don't printenv to avoid cluttering the log
- opam config list
- opam repo list
- opam list
- coqc --version
- echo "${COQ_VERSION}"
- git rev-parse --verify HEAD
- git describe --all --long --abbrev=40 --always --dirty
- pwd
script:
- cd mathcomp
- make test-suite TEST_SKIP_BUILD=1
except:
refs:
- tags
- merge_requests
# run "make test-suite" only for push pipelines (not for scheduled pipelines)
.test-once:
extends: .test
except:
refs:
- tags
- merge_requests
- schedules
variables:
- $CRON_MODE == "nightly"
test-coq-dev:
extends: .test
variables:
COQ_VERSION: "dev"
test-coq-8.15:
# to be replaced with .test-once when 8.15.0 available
extends: .test
variables:
COQ_VERSION: "8.15"
test-coq-8.14:
extends: .test-once
variables:
COQ_VERSION: "8.14"
test-coq-8.13:
extends: .test-once
variables:
COQ_VERSION: "8.13"
# set CONTRIB_URL, script, COQ_VERSION, CONTRIB_VERSION when using
.ci:
stage: test
image: "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}_${CI_COMMIT_REF_SLUG}_coq-${COQ_VERSION}"
variables:
GIT_STRATEGY: none
before_script:
- cat /proc/{cpu,mem}info || true
# don't printenv to avoid cluttering the log
- opam config list
- opam repo list
- opam list
- coqc --version
- echo "${COQ_VERSION}"
- echo "${CONTRIB_URL}"
- echo "${CONTRIB_VERSION}"
- git clone -b "${CONTRIB_VERSION}" --depth 1 "${CONTRIB_URL}" /home/coq/ci
- cd /home/coq/ci
- git rev-parse --verify HEAD
- git describe --all --long --abbrev=40 --always --dirty
except:
refs:
- tags
- merge_requests
- schedules
variables:
- $CRON_MODE == "nightly"
# Guidelines to add a library to mathcomp CI:
# - Add a hidden job (starting with a .) .ci-lib that extends the .ci job,
# sets var CONTRIB_URL (library Git URL), and defines a dedicated script
# - Add 1 job per Coq version to test, that extends the previous hidden job,
# and sets vars COQ_VERSION, CONTRIB_VERSION (compatible Git branch/tag)
# The Four Color Theorem
.ci-fourcolor:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/fourcolor.git"
CONTRIB_VERSION: master
script:
- make -j "${NJOBS}"
- make install
ci-fourcolor-8.13:
extends: .ci-fourcolor
variables:
COQ_VERSION: "8.13"
ci-fourcolor-dev:
extends: .ci-fourcolor
variables:
COQ_VERSION: "dev"
# The Odd Order Theorem
.ci-odd-order:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/odd-order.git"
CONTRIB_VERSION: master
script:
- make -j "${NJOBS}"
- make install
ci-odd-order-8.13:
extends: .ci-odd-order
variables:
COQ_VERSION: "8.13"
ci-odd-order-dev:
extends: .ci-odd-order
variables:
COQ_VERSION: "dev"
# The Lemma Overloading library
.ci-lemma-overloading:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/coq-community/lemma-overloading.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-lemma-overloading .
- opam install -y -v -j "${NJOBS}" coq-lemma-overloading
ci-lemma-overloading-8.13:
extends: .ci-lemma-overloading
variables:
COQ_VERSION: "8.13"
ci-lemma-overloading-dev:
extends: .ci-lemma-overloading
variables:
COQ_VERSION: "dev"
# The bigenough library (will be later subsumed by near)
.ci-bigenough:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/bigenough.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-mathcomp-bigenough .
- opam install -y -v -j "${NJOBS}" coq-mathcomp-bigenough
ci-bigenough-8.13:
extends: .ci-bigenough
variables:
COQ_VERSION: "8.13"
ci-bigenough-dev:
extends: .ci-bigenough
variables:
COQ_VERSION: "dev"
# The real-closed library
.ci-real-closed:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/real-closed.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-mathcomp-real-closed .
- opam install -y -v -j "${NJOBS}" --deps-only coq-mathcomp-real-closed
- opam install -y -v -j "${NJOBS}" coq-mathcomp-real-closed
ci-real-closed-8.13:
extends: .ci-real-closed
variables:
COQ_VERSION: "8.13"
ci-real-closed-dev:
extends: .ci-real-closed
variables:
COQ_VERSION: "dev"
# The finmap library
.ci-finmap:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/finmap.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-mathcomp-finmap .
- opam install -y -v -j "${NJOBS}" --deps-only coq-mathcomp-finmap
- opam install -y -v -j "${NJOBS}" coq-mathcomp-finmap
ci-finmap-8.13:
extends: .ci-finmap
variables:
COQ_VERSION: "8.13"
ci-finmap-dev:
extends: .ci-finmap
variables:
COQ_VERSION: "dev"
# The multinomials library
.ci-multinomials:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/multinomials.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-mathcomp-multinomials .
- opam install -y -v -j "${NJOBS}" --deps-only coq-mathcomp-multinomials
- opam install -y -v -j "${NJOBS}" coq-mathcomp-multinomials
ci-multinomials-8.13:
extends: .ci-multinomials
variables:
COQ_VERSION: "8.13"
ci-multinomials-dev:
extends: .ci-multinomials
variables:
COQ_VERSION: "dev"
# The analysis library
.ci-analysis:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/math-comp/analysis.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-mathcomp-analysis .
- opam install -y -v -j "${NJOBS}" --deps-only coq-mathcomp-analysis
- opam install -y -v -j "${NJOBS}" coq-mathcomp-analysis
ci-analysis-8.13:
extends: .ci-analysis
variables:
COQ_VERSION: "8.13"
ci-analysis-8.14:
extends: .ci-analysis
variables:
COQ_VERSION: "8.14"
# The FCSL-PCM library
.ci-fcsl-pcm:
extends: .ci
variables:
CONTRIB_URL: "https://github.com/imdea-software/fcsl-pcm.git"
CONTRIB_VERSION: master
script:
- opam pin add -n -k path coq-fcsl-pcm .
- opam install -y -v -j "${NJOBS}" coq-fcsl-pcm
ci-fcsl-pcm-8.13:
extends: .ci-fcsl-pcm
variables:
COQ_VERSION: "8.13"
ci-fcsl-pcm-dev:
extends: .ci-fcsl-pcm
variables:
COQ_VERSION: "dev"
################
### deploy stage
################
# Changes below (or jobs extending .docker-deploy) should be carefully
# reviewed to avoid leaks of HUB_TOKEN
.docker-deploy:
stage: deploy
image: docker:latest
services:
- docker:dind
environment:
# here, CI_JOB_NAME must not contain any ':', hence the use of '_'
name: "mathcomp/${CI_JOB_NAME}"
url: https://hub.docker.com/r/mathcomp/mathcomp-dev
variables:
GIT_STRATEGY: none
IMAGE_PREFIX: "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}_${CI_COMMIT_REF_SLUG}"
script:
- export IMAGE="${IMAGE_PREFIX}_${CI_JOB_NAME##*_}"
- export HUB_IMAGE="mathcomp/${CI_JOB_NAME/_/:}"
- echo "${IMAGE}"
- docker pull "${IMAGE}"
- echo "${HUB_IMAGE}"
- docker tag "${IMAGE}" "${HUB_IMAGE}"
- test -n "${HUB_REGISTRY}"
- test -n "${HUB_REGISTRY_USER}"
- echo "${HUB_TOKEN}" | docker login -u "${HUB_REGISTRY_USER}" --password-stdin "${HUB_REGISTRY}"
- docker push "${HUB_IMAGE}"
- docker logout "${HUB_REGISTRY}"
only:
refs:
- master
.docker-deploy-once:
extends: .docker-deploy
except:
refs:
- schedules
variables:
- $CRON_MODE == "nightly"
mathcomp-dev_coq-8.13:
extends: .docker-deploy-once
mathcomp-dev_coq-8.14:
extends: .docker-deploy-once
mathcomp-dev_coq-8.15:
# to be replaced with .docker-deploy-once when 8.15.0 available
extends: .docker-deploy
mathcomp-dev_coq-dev:
extends: .docker-deploy