-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
466 lines (417 loc) · 14.3 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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# Testing on multiple platforms and Caml version, but some jobs can share the
# _opam and _build directory.
variables:
IMAGE_WITH_CACHE: "ocaml/opam:debian-testing-opam"
OCAML_COMPILER: "4.14.0"
# A workaround against a bug in gitlab-runner's default
# unzipping implementation, which partially breaks caching for the dune _build cache.
# See https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27496 for more details.
FF_USE_FASTZIP: "true"
.job-with-cache: &job_with_cache
image: ${IMAGE_WITH_CACHE}
cache:
# Make the cache unique per commit
key: opam-cache-$CI_COMMIT_SHORT_SHA
paths:
- _build
- _opam
stages:
# - dependencies-check
- lint
- build
- test-debian
- test-alpine
- install
- doc
- deploy
# FIXME: Some changes have been introduced in commit
# cba740a58bea1a8873a2989d0c12c9e0bd4d2ed4 adding functions to
# blst. We should submit an PR on https://github.com/supranational/blst.
# As soon as it is merged, fix the commit.
# check-blst-version:
# stage: dependencies-check
# image: alpine:3.14
# before_script:
# - apk add --no-cache wget diffutils
# - diff --version
# script:
# - .ci/check_blst_version.sh
# rules:
# - when: always
lint-js:
image: node:lts
stage: lint
before_script:
- cd .ci/js
- npm install -d
script:
- ./node_modules/eslint/bin/eslint.js -c .eslintrc.js ../../src/runtime_helper.js
- ./node_modules/eslint/bin/eslint.js -c .eslintrc.js ../../src/bindings/blst_bindings_stubs.js
- ./node_modules/eslint/bin/eslint.js -c .eslintrc.js ../../src/primitives/poseidon128/caml_poseidon128_stubs.js
- ./node_modules/eslint/bin/eslint.js -c .eslintrc.js ../../src/primitives/rescue/caml_rescue_stubs.js
rules:
- when: always
lint:
stage: lint
image: ocaml/opam:debian-ocaml-4.12
before_script:
- opam install ocamlformat.0.20.1
script:
- dune build @fmt
rules:
- when: always
lint-c:
stage: lint
image: ubuntu:20.04
script:
- apt-get update -y
- apt-get install clang-format-11 git -y
- clang-format-11 --version
- clang-format-11 src/primitives/**/*.c -i
- clang-format-11 src/primitives/**/*.h -i
- clang-format-11 src/bindings/*.c -i
- clang-format-11 src/bindings/*.h -i
# Check if a file has been modified and uncommited
- git diff --exit-code
rules:
- when: always
# Build pipeline for debian
# Keep it close to the one for other distributions
.build-test-debian: &build_definition_debian
stage: test-debian
before_script:
# Always update system package manager + setup OPAM env
- sudo apt-get update
- eval $(opam env)
- opam update
- sudo apt-get install nodejs python3 -y
# Install emsdk to install emcc
- git clone https://github.com/emscripten-core/emsdk.git
- cd emsdk
- ./emsdk install latest
- ./emsdk activate latest
- source "./emsdk_env.sh"
- cd ../
# List versions and environments
- ocaml --version
- opam --version
- cc --version
- emcc --version
- echo $OPAM_SWITCH_PREFIX
script:
- opam install depext --yes
- opam install . --dry-run --deps-only --locked --with-test --with-doc --yes | awk '/-> installed/{print $3}' | xargs opam depext -iy
# For benchmark repository
- opam install "core_bench<=v0.14.1" -y
- dune build
- dune build @install
- dune build @runtest
- dune build @runtest-js
# Check built_with_blst_portable is set to true if libblst built with __BLST_PORTABLE__
- dune clean
- BLST_PORTABLE=y dune exec ./test/check_built_blst_portable_set.exe
- dune clean
- BLST_PORTABLE=y dune build -p bls12-381
- BLST_PORTABLE=y dune exec ./test/check_built_blst_portable_set.exe
- dune exec ./test/check_built_blst_portable_set.exe
# Check built_with_blst_portable is set to false if libblst not built with __BLST_PORTABLE__
- dune clean
- dune exec ./test/check_built_blst_portable_not_set.exe
- dune clean
- dune build -p bls12-381
- BLST_PORTABLE=y dune exec ./test/check_built_blst_portable_not_set.exe
- dune exec ./test/check_built_blst_portable_not_set.exe
rules:
- when: always
build-ocaml-4.08-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.08
build-ocaml-4.09-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.09
build-ocaml-4.10-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.10
build-ocaml-4.11-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.11
build-ocaml-4.12-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.12
build-ocaml-4.13-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.13
build-ocaml-4.14-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-4.14
build-ocaml-5.0-debian-10:
<<: *build_definition_debian
image: ocaml/opam:debian-10-ocaml-5.0
allow_failure: true
build-ocaml-4.08-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.08
build-ocaml-4.09-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.09
build-ocaml-4.10-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.10
build-ocaml-4.11-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.11
build-ocaml-4.12-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.12
build-ocaml-4.13-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.13
build-ocaml-4.14-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-4.14
build-ocaml-5.0-debian-11:
<<: *build_definition_debian
image: ocaml/opam:debian-11-ocaml-5.0
allow_failure: true
# Build and use cache. Useful for other jobs not related to testing.
# Does not run any test
build:
<<: *job_with_cache
stage: build
before_script:
# Always update system package manager + setup OPAM env
- sudo apt-get update
- "[ -d _opam ] || opam switch create --yes --no-install . $OCAML_COMPILER"
- eval $(opam env)
- opam repository set-url default https://opam.ocaml.org
- opam update
- sudo apt-get install nodejs python3 -y
# Install emsdk to install emcc
- git clone https://github.com/emscripten-core/emsdk.git
- cd emsdk
- ./emsdk install latest
- ./emsdk activate latest
- source "./emsdk_env.sh"
- cd ../
# List versions and environments
- ocaml --version
- opam --version
- cc --version
- emcc --version
- echo $OPAM_SWITCH_PREFIX
script:
- opam install depext --yes
- opam install . --dry-run --deps-only --locked --with-test --with-doc --yes | awk '/-> installed/{print $3}' | xargs opam depext -iy
# For benchmark repository. Not included in opam deps
- opam install "core_bench<=v0.14.1" -y
- dune build
# For doc
- opam install odoc -y
- dune build @doc
- cp -r _build/default/_doc/_html _odoc/
artifacts:
paths:
- _odoc
rules:
- when: always
# Build pipeline for alpine
# Keep it close to the one for other distributions
# Keep it close to utils/Dockerfile-alpine to be able to debug alpine on a dev
# machine.
.build-test-alpine: &build_definition_alpine
stage: test-alpine
before_script:
# Always update system package manager + setup OPAM env
- eval $(opam env)
- opam update
- sudo apk add build-base python3
# Install emsdk to install emcc
- git clone https://github.com/emscripten-core/emsdk.git
- cd emsdk
- ./emsdk install latest
- ./emsdk activate latest
- source "./emsdk_env.sh"
- cd ../
# List versions and environments
- emcc --version
- ocaml --version
- opam --version
- cc --version
- echo $OPAM_SWITCH_PREFIX
script:
- opam install depext --yes
- opam install . --dry-run --deps-only --locked --with-test --with-doc --yes | awk '/-> installed/{print $3}' | xargs opam depext -iy
- dune build @install
- dune build @runtest
# - dune build @runtest-js
# Check built_with_blst_portable is set to true if libblst built with __BLST_PORTABLE__
- dune clean
- BLST_PORTABLE=y dune exec ./test/check_built_blst_portable_set.exe
- dune clean
- BLST_PORTABLE=y dune build -p bls12-381
- BLST_PORTABLE=y dune exec ./test/check_built_blst_portable_set.exe
- dune exec ./test/check_built_blst_portable_set.exe
# Check built_with_blst_portable is set to false if libblst not built with __BLST_PORTABLE__
- dune clean
- dune exec ./test/check_built_blst_portable_not_set.exe
- dune clean
- dune build -p bls12-381
- BLST_PORTABLE=y dune exec ./test/check_built_blst_portable_not_set.exe
- dune exec ./test/check_built_blst_portable_not_set.exe
rules:
- when: always
build-ocaml-4.08-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.08
build-ocaml-4.09-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.09
build-ocaml-4.10-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.10
build-ocaml-4.11-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.11
build-ocaml-4.12-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.12
build-ocaml-4.13-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.13
build-ocaml-4.14-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-4.14
build-ocaml-5.0-alpine-3.14:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.14-ocaml-5.0
allow_failure: true
build-ocaml-4.08-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.08
build-ocaml-4.09-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.09
build-ocaml-4.10-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.10
build-ocaml-4.11-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.11
build-ocaml-4.12-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.12
build-ocaml-4.13-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.13
build-ocaml-4.14-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-4.14
build-ocaml-5.0-alpine-3.15:
<<: *build_definition_alpine
image: ocaml/opam:alpine-3.15-ocaml-5.0
allow_failure: true
opam-install-and-remove:
stage: install
image: ocaml/opam:debian-ocaml-4.11
before_script:
# List versions and environments
- ocaml --version
- opam --version
- cc --version
- echo $OPAM_SWITCH_PREFIX
- opam repository set-url default https://opam.ocaml.org
- opam update
script:
- opam pin add bls12-381.dev . --no-action
- opam depext bls12-381.dev -i -y -v
- opam install bls12-381.dev -y -v --deps-only
- opam install bls12-381.dev -y -v
# Check blst headers are installed
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst_extended.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst_aux.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst_misc.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/caml_bls12_381_stubs.h
- opam remove -a -y bls12-381.dev
rules:
- when: always
opam-install-and-remove-local-switch:
stage: install
image: ocaml/opam:debian-ocaml-4.11
before_script:
# Run everything in a local switch
- opam switch create ./ 4.09.1 --no-install
- eval $(opam config env)
# List versions and environments
- ocaml --version
- opam --version
- cc --version
- echo $OPAM_SWITCH_PREFIX
- opam repository set-url default https://opam.ocaml.org
- opam update
script:
- opam pin add bls12-381.dev . --no-action
- opam depext bls12-381.dev -i -y -v
- opam install bls12-381.dev -y -v --deps-only
- opam install bls12-381.dev -y -v
# Check blst headers are installed
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst_extended.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst_aux.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/blst_misc.h
- ls $OPAM_SWITCH_PREFIX/lib/bls12-381/caml_bls12_381_stubs.h
- opam remove -a -y bls12-381.dev
rules:
- when: always
pages:
<<: *job_with_cache
stage: deploy
script:
- cp -r _odoc public/
artifacts:
paths:
- public
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
npm-publish:
<<: *job_with_cache
only:
- tags
stage: deploy
before_script:
- sudo apt-get update -y
- sudo apt-get install git curl jq -y
# Install NVM to publish the package
# Using nodejs/npm from debian registry does not work. Looks like node.12.22
# does not work. Do not know why.
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- . "$NVM_DIR/nvm.sh"
- nvm install 12.16.1
- nvm use 12.16.1
# Print binaries versions
- jq --version
- node --version
- npm --version
- mkdir -p dist
- cp _build/default/src/blst.js dist/blst.js
- cp _build/default/src/blst.wasm dist/blst.wasm
script:
# !! projects/${CI_PROJECT_ID} is required
- echo "@dannywillems:registry=https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
# https://docs.gitlab.com/ee/user/packages/npm_registry/
- echo "//gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${NPM_TOKEN}" >> .npmrc
- echo "//gitlab.com/api/v4/packages/npm/:_authToken=${NPM_TOKEN}" >> .npmrc
# In the case of a tag, git describe outputs only the tag, not tag-NB_COMMIT-HASH
- >
jq --arg version $(git describe) '. + {version: $version}' < package.json > package.json.new
- mv package.json.new package.json
- cat package.json
# Do not publish with the tag `latest` and rely on the SemVer to get the
# latest version.
# See https://docs.npmjs.com/cli/v8/commands/npm-dist-tag
# > Publishing a package sets the latest tag to the published version unless
# > the --tag option is used. For example, npm publish --tag=beta.
# Useful to not rely on the latest tag when there are bugfixes in a previous
# major version
- npm publish --tag tag-$(git describe)