-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
325 lines (308 loc) · 11.8 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
variables:
LIGO_REGISTRY_IMAGE_BASE_NAME: "${CI_PROJECT_PATH}/${CI_PROJECT_NAME}"
LIGO_IMAGE_TAG: "ligo:${CI_COMMIT_SHORT_SHA}-${CI_PIPELINE_ID}"
LIGO_CI_IMAGE_TAG: "ligo-ci:${CI_COMMIT_SHORT_SHA}-${CI_PIPELINE_ID}"
stages:
- pretooling # changelog
- build # build, test, produces binaries/.deb/doc within docker
- post-build-action # Post build action
- docker-extract # extract what have been built and expose them as artifact
- tools-precheck # preliminary checks done for projects from 'tools'
- tools-build # build projects from 'tools'
- tools-check # run tests for projects from 'tools'
- tooling # build miscellaneous tooling-related things (website, changelog..)
- test # e2e tests
- push # deploy docker images, pages, releases (tag)
- deploy # deploy web IDE, website preview
- release # Manage branch matching ^release/*
include:
# jobs for managing process around changelog generation
- "/.ci/.gitlab-ci-changelog.yml"
# jobs for managing process around release
- "/.ci/.gitlab-ci-release.yml"
# Manage pipeline related to webide
- "/.ci/.gitlab-ci-webide.yml"
# CI jobs for projects from 'tools'
- "/.ci/.gitlab-ci-vscode-extension.yml"
- "/.ci/.gitlab-ci-debugger.yml"
# CI manage notification
- "/.ci/.gitlab-ci-notify.yml"
.submodule-clone:
before_script:
- git submodule sync --recursive
- git submodule update --init --recursive --remote
.nix:
extends: .submodule-clone
before_script:
- find "$CI_PROJECT_DIR" -path "$CI_PROJECT_DIR/.git" -prune -o "(" -type d -a -not -perm -u=w ")" -exec chmod --verbose u+w {} ";"
- export COMMIT_DATE="$(git show --no-patch --format=%ci)"
changelog:
stage: pretooling
tags:
- gcp-ubuntu
script:
- FORCE_GENERATION=$([ -n "$CI_COMMIT_TAG" ] && echo "false" || echo "true")
- ./scripts/changelog-generation.sh ${FORCE_GENERATION}
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^release/ && $CI_PROJECT_PATH == "ligolang/ligo" && $TRIGGER_DOC_UPDATE != null'
when: always
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
artifacts:
paths:
- changelog.md
- changelog.txt
- release-notes.md
- release-notes.txt
# TODO: https://docs.gitlab.com/ee/ci/yaml/#onlychangesexceptchanges ?
docker_build:
stage: build
tags:
- gcp-ubuntu
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^release/ && $CI_PROJECT_PATH == "ligolang/ligo" && $TRIGGER_DOC_UPDATE != null'
when: always
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
needs:
- job: changelog
artifacts: true
script:
- git submodule sync --recursive
- git submodule update --init --recursive # because of a gitlab caching issue
- .ci/scripts/pipeline_optimization/mr_dockerfile_pre_process.sh
- VERSION=$(./scripts/version.sh)
- DOCKER_BUILDKIT=1 docker build .
--build-arg=ligo_version="$VERSION"
--target ligo-builder
-t ${LIGO_IMAGE_TAG}-builder
- DOCKER_BUILDKIT=1 docker build .
--build-arg=ligo_version="$VERSION"
-t ${LIGO_IMAGE_TAG} --target ligo
- DOCKER_BUILDKIT=1 docker build .
--build-arg=ligo_version="$VERSION"
-t ${LIGO_CI_IMAGE_TAG} --target ligo-ci
- docker save -o ligo.tar.gz ${LIGO_IMAGE_TAG}
- docker save -o ligo_ci.tar.gz ${LIGO_CI_IMAGE_TAG}
after_script:
- docker image rm --force "${LIGO_IMAGE_TAG}" >/dev/null 2>&1 || true
- docker image rm --force "${LIGO_IMAGE_TAG}-builder" >/dev/null 2>&1 || true
- docker image rm --force "${LIGO_CI_IMAGE_TAG}" >/dev/null 2>&1 || true
artifacts:
expose_as: "Ligo docker image - light -"
paths:
- ligo.tar.gz
- ligo_ci.tar.gz
docker_extract:
stage: docker-extract
tags:
- gcp-ubuntu
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^release/ && $CI_PROJECT_PATH == "ligolang/ligo" && $TRIGGER_DOC_UPDATE != null'
when: always
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
needs:
- job: docker_build
artifacts: true
script:
- docker load -i ligo.tar.gz
- docker cp $(docker create ${LIGO_IMAGE_TAG}):/root/ligo .
- chmod +rwx ligo
# Check that the binary is truly static and has 0 dependencies
# previous command, but it seems statically meant something a bit different.
# - ldd ligo | grep 'statically' # TODO: there is maybe a better way to do that ?
# the string depends on ldd...
- if ! ldd ligo; then echo "ldd failed, i.e. expecting that it is statically linked."; else echo "Expected ldd ligo to fail (not a dynamic executable)."; fi
- docker cp -La $(docker create ${LIGO_IMAGE_TAG}):/root/doc .
- docker cp $(docker create ${LIGO_IMAGE_TAG}):/root/highlighting ./highlighting
# Generate ligo.deb
- ./scripts/create-package-deb-file.sh
after_script:
- docker image rm -f "${LIGO_IMAGE_TAG}-builder" >/dev/null 2>&1 || true
- docker image rm -f "${LIGO_IMAGE_TAG}" >/dev/null 2>&1 || true
artifacts:
paths:
- ligo
- ligo.deb
- doc
- highlighting
check-generated-highlighting:
stage: tooling
tags:
- gcp-ubuntu
dependencies:
- docker_extract
script:
- scripts/diff_dir.sh highlighting/emacs tools/emacs
- scripts/diff_dir.sh highlighting/vim/ftdetect tools/vim/ligo/start/ligo/ftdetect
- scripts/diff_dir.sh highlighting/vim/plugin tools/vim/ligo/start/ligo/plugin
- scripts/diff_dir.sh highlighting/vim/syntax tools/vim/ligo/start/ligo/syntax
- scripts/diff_dir.sh highlighting/vscode tools/vscode/syntaxes
- scripts/diff_dir.sh highlighting/textmate tools/ligo-syntax-highlighting/textmate
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- tools/ligo-syntax-highlighting/**/*
when: always
.docker-image:
stage: push
tags:
- gcp-ubuntu
image: docker:19.03.5
services:
- docker:19.03.5-dind
docker_push_ligo:
stage: push
tags:
- gcp-ubuntu
extends: .docker-image
dependencies:
- docker_build
needs:
- docker_build
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
script:
- echo ${LIGO_REGISTRY_PASSWORD} | docker login -u ${LIGO_REGISTRY_USER} --password-stdin
- docker load -i=./ligo.tar.gz
- if test "$CI_COMMIT_REF_NAME" = "dev"; then export LIGO_TAG=next; else if echo "$CI_COMMIT_TAG" | grep -E "[0-9]+\.[0-9]+\.[0-9]+"; then export LIGO_TAG="$CI_COMMIT_TAG"; else export LIGO_TAG=next-attempt; fi; fi
- export LIGO_REGISTRY_FULL_NAME="ligolang/ligo:$LIGO_TAG"
- docker tag "${LIGO_IMAGE_TAG}" "${LIGO_REGISTRY_FULL_NAME}"
- docker push "${LIGO_REGISTRY_FULL_NAME}"
after_script:
- docker image rm "${LIGO_IMAGE_TAG}" >/dev/null 2>&1 || true
docker_push_ligo_ci:
stage: push
tags:
- gcp-ubuntu
extends: .docker-image
dependencies:
- docker_build
needs:
- docker_build
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
script:
- echo ${LIGO_REGISTRY_PASSWORD} | docker login -u ${LIGO_REGISTRY_USER} --password-stdin
- docker load -i=./ligo_ci.tar.gz
- if test "$CI_COMMIT_REF_NAME" = "dev"; then export LIGO_TAG=next; else if echo "$CI_COMMIT_TAG" | grep -E "[0-9]+\.[0-9]+\.[0-9]+"; then export LIGO_TAG="$CI_COMMIT_TAG"; else export LIGO_TAG=next-attempt; fi; fi
- export LIGO_REGISTRY_FULL_NAME="ligolang/ligo_ci:$LIGO_TAG"
- docker tag "${LIGO_CI_IMAGE_TAG}" "${LIGO_REGISTRY_FULL_NAME}"
- docker push "${LIGO_REGISTRY_FULL_NAME}"
after_script:
- docker image rm "${LIGO_CI_IMAGE_TAG}" >/dev/null 2>&1 || true
xrefcheck:
stage: tooling
tags:
- gcp-ubuntu
needs:
- job: changelog
artifacts: true
script:
- wget https://github.com/serokell/xrefcheck/releases/download/v0.2.2/xrefcheck-x86_64-linux --no-verbose -O xrefcheck
- chmod 777 ./xrefcheck
- ./xrefcheck
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
allow_failure: true
.website:
stage: push
tags:
- gcp-docker
image: node:20.2.0-buster
needs:
- job: changelog
artifacts: true
script:
- export DOC_PATH=./gitlab-pages/docs
- export WEBSITE_PATH=./gitlab-pages/website
- cp -f ./changelog.md $DOC_PATH/intro/changelog.md
- export LATEST_VERSION=$(ls -1r $WEBSITE_PATH/versioned_docs | sed -n '1p')
- echo $LATEST_VERSION
- cp -f ./changelog.md $WEBSITE_PATH/versioned_docs/$LATEST_VERSION/intro/changelog.md
- npm --prefix $WEBSITE_PATH ci
- npm --prefix $WEBSITE_PATH run clear
- npm --prefix $WEBSITE_PATH run build
- cp -Lr --no-preserve=mode,ownership,timestamps $WEBSITE_PATH/build public
- touch to-dos.html; cp to-dos.html public/to-dos.html
artifacts:
paths:
- public
pages:
extends: .website
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
changes:
- gitlab-pages/**/*
- changelog/*
pages-attempt:
extends: .website
needs:
- job: changelog
artifacts: true
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- gitlab-pages/**/*
- changelog/*
when: on_success
algolia-crawl:
stage: push
tags:
- gcp-ubuntu
needs:
- job: pages
script:
# We want to trigger the job after page:deploy to reindex the website but job can't depends on page:deploy. So we put a artificial sleep of 10 seconds before triggering algolia crawler to be sure that it'll works
- |
sleep 20
curl -X POST -H "Content-Type: application/json" --user ${ALGOLIA_CRAWLER_ID}:${ALGOLIA_CRAWLER_TOKEN} https://crawler.algolia.com/api/1/crawlers/bb0597ba-5abc-45ba-bdf9-99f8152e87b0/reindex
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
changes:
- gitlab-pages/**/*
when: on_success
deploy_website_preview:
stage: deploy
image: node:20.2.0-buster
tags:
- gcp-docker
needs:
- job: pages-attempt
artifacts: true
script:
- apt-get update
- apt-get install -y --no-install-recommends jq
- npm install [email protected]
- npx netlify deploy --site $NETLIFY_SITE_ID_LIGOLANG --dir=./public --auth $NETLIFY_AUTH_TOKEN --json --alias="$CI_MERGE_REQUEST_IID-$CI_COMMIT_SHORT_SHA" > netlify.json
- export NETLIFY_DEPLOY_URL=$(jq -r .deploy_url netlify.json)
- export NETLIFY_DEPLOY_LOGS=$(jq -r .logs netlify.json)
- echo "The URL for this deployment is $NETLIFY_DEPLOY_URL"
- echo "Logs for this deployment can be found at $NETLIFY_DEPLOY_LOGS"
- ./.ci/scripts/publish_preview_as_MR_comment.sh $CI_PROJECT_ID $CI_MERGE_REQUEST_IID $GITLAB_PERSONAL_API_PRIVATE_TOKEN "A new deploy preview is available on Netlify at $NETLIFY_DEPLOY_URL, you can view the logs at $NETLIFY_DEPLOY_LOGS" "ligolang-bot" "ligolang.netlify"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- gitlab-pages/**/*
- changelog/*
when: on_success