-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
577 lines (492 loc) · 17.4 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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
stages:
- build-env-default
- build-env-full
- build-and-test
- compiler-warnings
- package-env
- package-build
- package-build-dev
- package-test
- package-deploy
.execution-conditions: &execution-conditions
only:
refs:
- merge_requests
- master@nektar/nektar
- tags@nektar/nektar
- web
changes:
- "cmake/**/*"
- "docker/**/*"
- "docs/**/*"
- "library/**/*"
- "solvers/**/*"
- "tests/**/*"
- "utilities/**/*"
- ".gitlab-ci/*"
- .dockerignore
- .gitmodules
- .gitlab-ci.yml
- CMakeLists.txt
variables:
- $CI_MERGE_REQUEST_TITLE !~ /^WIP:.*/
.build-env-template: &build-env-template
<<: *execution-conditions
stage: build-env
image: docker:19.03.6
timeout: 1h
.build-and-test-template: &build-and-test-template
<<: *execution-conditions
stage: build-and-test
image: docker:19.03.6
variables:
GIT_STRATEGY: clone
script:
- OS_VERSION=$(echo $CI_JOB_NAME | cut -d- -f 1)
- BUILD_TYPE=$(echo $CI_JOB_NAME | cut -d- -f 2)
- export CCACHE_DIR=/cache/nektar/$OS_VERSION/
- export NUM_CPUS=4
- export CONTAINER_NAME=test-$CI_JOB_ID
- export ENV_NAME=env-${OS_VERSION}-${BUILD_TYPE}
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE:$ENV_NAME
- sed "s %%BASE_IMAGE%% $CI_REGISTRY_IMAGE:$ENV_NAME g" .gitlab-ci/Dockerfile_add_repo > Dockerfile_tmp
- export ENV_IMAGE=$(docker build -q -f Dockerfile_tmp .)
- mkdir -p log
- if [ ! -d $CCACHE_DIR ]; then mkdir -p $CCACHE_DIR && chown 1000:1000 $CCACHE_DIR; fi
- docker run --name $CONTAINER_NAME -v ccache:/cache
-e "BUILD_TYPE=$BUILD_TYPE"
-e "NUM_CPUS=$NUM_CPUS"
-e "CCACHE_DIR=$CCACHE_DIR"
$ENV_IMAGE
bash -x .gitlab-ci/build-and-test.sh |
tee log/${OS_VERSION}_${BUILD_TYPE}.log || true
- exit_code=$(docker wait $CONTAINER_NAME)
- >
echo "Container exit code: $exit_code"
- if [ $exit_code -ne 0 ];
then
export FAIL_IMAGE=$CI_REGISTRY_IMAGE:pipeline_${CI_PIPELINE_ID}_${OS_VERSION}_${BUILD_TYPE};
echo FAIL $FAIL_IMAGE;
docker commit $CONTAINER_NAME $FAIL_IMAGE;
docker push $FAIL_IMAGE;
docker rmi $FAIL_IMAGE;
fi
- docker rm $CONTAINER_NAME
- exit $exit_code;
artifacts:
expire_in: 1 month
paths:
- log/
timeout: 3h
.compiler-warning-template: &compiler-warning-template
<<: *execution-conditions
image: debian:10-slim
stage: compiler-warnings
variables:
WARNING_REGEX: '.*warning[: ].*'
GIT_STRATEGY: none
script:
- export OS=$(echo $CI_JOB_NAME | cut -d- -f 1)
- export BUILD_TYPE=$(echo $CI_JOB_NAME | cut -d- -f 2)
- export LOG_FILE="log/${OS}_${BUILD_TYPE}.log"
- if [ $(grep -c "$WARNING_REGEX" $LOG_FILE) -ne 0 ];
then
grep --colour=always -A 1 -B 1 -0 "$WARNING_REGEX" $LOG_FILE;
exit 1;
fi
allow_failure: true
timeout: 15m
################################################
################### DEBIAN ###################
################################################
.build-env-debian-template-default: &build-env-debian-template-default
<<: *build-env-template
stage: build-env-default
variables:
OS_DISTRO: debian
REMOVE_UCX: 0
script:
- OS_VERSION=$(echo $CI_JOB_NAME | cut -d- -f 1)
- BUILD_TYPE=$(echo $CI_JOB_NAME | cut -d- -f 2)
- sed -e "s %%OS_VERSION%% $OS_VERSION g" -e "s %%REGISTRY%% $CI_REGISTRY_IMAGE g" docker/nektar-env/Dockerfile_${OS_DISTRO}_${BUILD_TYPE} > Dockerfile
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- export IMAGE=$CI_REGISTRY_IMAGE:env-${OS_VERSION}-${BUILD_TYPE}
- docker pull $IMAGE || true
- docker build --pull --build-arg REMOVE_UCX=${REMOVE_UCX} -t $IMAGE .
- docker push $IMAGE
.build-env-debian-template-full: &build-env-debian-template-full
<<: *build-env-debian-template-default
stage: build-env-full
bullseye-default-build-env:
<<: *build-env-debian-template-default
bullseye-full_py3-build-env:
<<: *build-env-debian-template-full
variables:
OS_DISTRO: debian
REMOVE_UCX: 1
needs: ["bullseye-default-build-env"]
buster-default-build-env:
<<: *build-env-debian-template-default
buster-full-build-env:
<<: *build-env-debian-template-full
needs: ["buster-default-build-env"]
stretch-default-build-env:
<<: *build-env-debian-template-default
stretch-full-build-env:
<<: *build-env-debian-template-full
needs: ["stretch-default-build-env"]
bullseye-default-build-and-test:
<<: *build-and-test-template
needs: ["bullseye-default-build-env"]
bullseye-full_py3-build-and-test:
<<: *build-and-test-template
needs: ["bullseye-full_py3-build-env"]
buster-default-build-and-test:
<<: *build-and-test-template
needs: ["buster-default-build-env"]
buster-full-build-and-test:
<<: *build-and-test-template
needs: ["buster-full-build-env"]
variables:
OS_DISTRO: debian
GIT_SUBMODULE_STRATEGY: recursive
stretch-default-build-and-test:
<<: *build-and-test-template
needs: ["stretch-default-build-env"]
stretch-full-build-and-test:
<<: *build-and-test-template
needs: ["stretch-full-build-env"]
# COMPILER WARNINGS
bullseye-default-warnings:
<<: *compiler-warning-template
needs: ["bullseye-default-build-and-test"]
bullseye-full_py3-warnings:
<<: *compiler-warning-template
needs: ["bullseye-full_py3-build-and-test"]
buster-default-warnings:
<<: *compiler-warning-template
needs: ["buster-default-build-and-test"]
buster-full-warnings:
<<: *compiler-warning-template
needs: ["buster-full-build-and-test"]
stretch-default-warnings:
<<: *compiler-warning-template
needs: ["stretch-default-build-and-test"]
stretch-full-warnings:
<<: *compiler-warning-template
needs: ["stretch-full-build-and-test"]
buster-documentation-build-env:
<<: *execution-conditions
image: docker:19.03.6
stage: build-env-full
script:
- export IMAGE=$CI_REGISTRY_IMAGE:env-documentation
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- sed -e "s %%BASE_IMAGE%% $CI_REGISTRY_IMAGE g" docker/nektar-env/Dockerfile_debian_documentation > Dockerfile
- docker pull $IMAGE || true
- docker build --pull -t $IMAGE .
- docker push $IMAGE
needs: ["buster-default-build-env"]
.build-documentation-template: &build-documentation-template
<<: *build-and-test-template
image: $CI_REGISTRY_IMAGE:env-documentation
needs: ["buster-documentation-build-env"]
user-guide-build:
<<: *build-documentation-template
script:
- cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=Release -DNEKTAR_BUILD_LIBRARY:BOOL=OFF -DNEKTAR_BUILD_SOLVERS:BOOL=OFF -DNEKTAR_BUILD_UTILITIES:BOOL=OFF -DNEKTAR_BUILD_TESTS:BOOL=OFF -DNEKTAR_BUILD_DOC:BOOL=ON .
- make -C build -j 4 user-guide-pdf user-guide-html developer-guide-pdf developer-guide-html
artifacts:
expire_in: 1 month
paths:
- build/docs/user-guide/user-guide.pdf
- build/docs/user-guide/html
- build/docs/developer-guide/developers-guide.pdf
- build/docs/developer-guide/html
doxygen-build:
<<: *build-documentation-template
script:
- cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=Release -DNEKTAR_BUILD_LIBRARY:BOOL=OFF -DNEKTAR_BUILD_SOLVERS:BOOL=OFF -DNEKTAR_BUILD_UTILITIES:BOOL=OFF -DNEKTAR_BUILD_TESTS:BOOL=OFF -DNEKTAR_BUILD_DOC:BOOL=ON .
- make -C build doc
artifacts:
expire_in: 1 month
paths:
- build/docs/doxygen/html/
tutorials-build:
<<: *build-documentation-template
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=Release .
- make -C build -j 2 tutorials-pdf tutorials-html
artifacts:
expire_in: 1 month
paths:
- build/docs/tutorial/
################################################
################### UBUNTU ###################
################################################
.build-env-ubuntu-template-default: &build-env-ubuntu-template-default
<<: *build-env-debian-template-default
variables:
OS_DISTRO: ubuntu
.build-env-ubuntu-template-full: &build-env-ubuntu-template-full
<<: *build-env-ubuntu-template-default
stage: build-env-full
focal-default-build-env:
<<: *build-env-ubuntu-template-default
focal-full_py3-build-env:
<<: *build-env-ubuntu-template-full
needs: ["focal-default-build-env"]
bionic-default-build-env:
<<: *build-env-ubuntu-template-default
bionic-full-build-env:
<<: *build-env-ubuntu-template-full
needs: ["bionic-default-build-env"]
focal-default-build-and-test:
<<: *build-and-test-template
needs: ["focal-default-build-env"]
focal-full_py3-build-and-test:
<<: *build-and-test-template
needs: ["focal-full_py3-build-env"]
bionic-default-build-and-test:
<<: *build-and-test-template
needs: ["bionic-default-build-env"]
bionic-full-build-and-test:
<<: *build-and-test-template
needs: ["bionic-full-build-env"]
# COMPILER WARNINGS
focal-default-warnings:
<<: *compiler-warning-template
needs: ["focal-default-build-and-test"]
focal-full_py3-warnings:
<<: *compiler-warning-template
needs: ["focal-full_py3-build-and-test"]
bionic-default-warnings:
<<: *compiler-warning-template
needs: ["bionic-default-build-and-test"]
bionic-full-warnings:
<<: *compiler-warning-template
needs: ["bionic-full-build-and-test"]
################################################
################### CENTOS ###################
################################################
.build-env-centos-template-default: &build-env-centos-template-default
<<: *build-env-debian-template-default
variables:
OS_DISTRO: centos
.build-env-centos-template-full: &build-env-centos-template-full
<<: *build-env-centos-template-default
stage: build-env-full
centos7-default-build-env:
<<: *build-env-centos-template-default
centos7-full-build-env:
<<: *build-env-centos-template-full
needs: ["centos7-default-build-env"]
centos7-default-build-and-test:
<<: *build-and-test-template
needs: ["centos7-default-build-env"]
centos7-full-build-and-test:
<<: *build-and-test-template
needs: ["centos7-full-build-env"]
# COMPILER WARNINGS
centos7-default-warnings:
<<: *compiler-warning-template
needs: ["centos7-default-build-and-test"]
centos7-full-warnings:
<<: *compiler-warning-template
needs: ["centos7-full-build-and-test"]
# ################################################
# #################### OSX #####################
# ################################################
.build-and-test-osx-template: &build-and-test-osx-template
<<: *build-and-test-template
tags:
- macos
script:
- mkdir -p log
- export OS_VERSION="osx"
- export NUM_CPUS=8
- bash -x ./.gitlab-ci/build-and-test.sh |
tee log/${OS_VERSION}_${BUILD_TYPE}.log
osx-default-build-and-test:
<<: *build-and-test-osx-template
variables:
BUILD_TYPE: "default"
needs: []
osx-full-build-and-test:
<<: *build-and-test-osx-template
variables:
BUILD_TYPE: "full"
needs: []
osx-default-warnings:
<<: *compiler-warning-template
needs: ["osx-default-build-and-test"]
osx-full-warnings:
<<: *compiler-warning-template
needs: ["osx-full-build-and-test"]
# ################################################
# ################# WINDOWS ####################
# ################################################
win10-default-build-and-test:
<<: *build-and-test-template
tags:
- win10
script:
- $Env:path = "$CI_PROJECT_DIR\build\dist\bin;$CI_PROJECT_DIR\ThirdParty;$CI_PROJECT_DIR\build\ThirdParty\dist\bin;" + $Env:path
- echo $Env:path
- mkdir build
- cd build
- cmake.exe -G "Visual Studio 14 2015 Win64" --config Debug ..
- cmake.exe --build . --target ALL_BUILD --config Debug
- cmake.exe --build . --target INSTALL --config Debug
- ctest --output-on-failure -C Debug -j3
after_script:
- Remove-Item -Recurse -Force build
needs: []
timeout: 4h
win10-mpi-default-build-and-test:
<<: *build-and-test-template
tags:
- win10
script:
- $Env:path = "$CI_PROJECT_DIR\build\dist\bin;$CI_PROJECT_DIR\ThirdParty;$CI_PROJECT_DIR\build\ThirdParty\dist\bin;" + $Env:path
- echo $Env:path
- mkdir build
- cd build
- cmake.exe -G "Visual Studio 14 2015 Win64" -DNEKTAR_USE_MPI=ON --config Debug ..
- cmake.exe --build . --target ALL_BUILD --config Debug
- cmake.exe --build . --target INSTALL --config Debug
- ctest --output-on-failure -C Debug -j3
after_script:
- Remove-Item -Recurse -Force build
needs: []
timeout: 4h
# ##################################################
# ################# DOCKERHUB ####################
# ##################################################
# Docker Hub build template. We build images and push them into the gitlab
# container registry first; this way, we can test the images before they are
# deployed, modify images or test adjustments to the CI by using docker/*
# branches on gitlab, and test the images before they are deployed.
#
# Images are tagged with both :latest and the short SHA commit, so that the
# correct image version can be grabbed from the container registry.
.dockerhub_build_template: &dockerhub_build_template
image: docker:stable
only:
- master@nektar/nektar
- /^docker\/.*$/@nektar/nektar
- tags@nektar/nektar
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- IMAGE=$CI_REGISTRY_IMAGE/${image_name}
- docker pull $IMAGE || true
- docker build ${args} --pull -t $IMAGE -f ${dockerfile} .
- docker tag $IMAGE $IMAGE:$CI_COMMIT_SHORT_SHA
- docker tag $IMAGE $IMAGE:latest
- docker push $IMAGE:$CI_COMMIT_SHORT_SHA
- docker push $IMAGE:latest
# Docker Hub test template, which runs an image from the gitlab container
# registry on a particular SHA commit.
.dockerhub-test-template: &dockerhub_test_template
image: ${CI_REGISTRY_IMAGE}/${image_name}:$CI_COMMIT_SHORT_SHA
stage: package-test
only:
- master@nektar/nektar
- /^docker\/.*$/@nektar/nektar
- tags@nektar/nektar
# Docker Hub deployment template. Only builds for master or tags on the main
# Nektar repository. The strategy is to login to the container registry and pull
# an image onto the runner; we then tag the image as appropriate (with :latest
# and SHA commit, as well as the git tag if this happens to be a tagged commit),
# then push the image up to Docker Hub. Note that cleanup of images on the
# runners can be difficult if they are tagged multiple times, so we also perform
# a quick rmi to make sure we only keep the images from the registry.
.dockerhub-deploy-template: &dockerhub_deploy_template
image: docker:stable
stage: package-deploy
only:
- master@nektar/nektar
- tags@nektar/nektar
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- CI_IMAGE=$CI_REGISTRY_IMAGE/${image_name}:$CI_COMMIT_SHORT_SHA
- DH_IMAGE=${DOCKERIO_REGISTRY}/nektarpp/${image_name}
- docker pull $CI_IMAGE
- docker logout
- docker login -u "$DOCKERIO_REGISTRY_USER" -p "$DOCKERIO_REGISTRY_PASSWORD" $DOCKERIO_REGISTRY
- if [ ! -z $CI_COMMIT_TAG ]; then docker tag $CI_IMAGE $DH_IMAGE:$CI_COMMIT_TAG; docker push $DH_IMAGE:$CI_COMMIT_TAG; docker rmi $DH_IMAGE:$CI_COMMIT_TAG; fi
- docker tag $CI_IMAGE $DH_IMAGE:$CI_COMMIT_SHORT_SHA
- docker tag $CI_IMAGE $DH_IMAGE:latest
- docker push $DH_IMAGE:$CI_COMMIT_SHORT_SHA
- docker push $DH_IMAGE:latest
- docker rmi $DH_IMAGE:$CI_COMMIT_SHORT_SHA $DH_IMAGE:latest
# nektarpp/nektar-env image
dockerhub-build-env:
<<: *dockerhub_build_template
stage: package-env
variables:
image_name: nektar-env
dockerfile: docker/nektar-env/Dockerfile
# nektarpp/nektar image
dockerhub-build-nektar:
<<: *dockerhub_build_template
stage: package-build
needs: [ "dockerhub-build-env" ]
variables:
image_name: nektar
dockerfile: docker/nektar/Dockerfile
args: --build-arg ENV_IMAGE=$CI_REGISTRY_IMAGE/nektar-env:$CI_COMMIT_SHORT_SHA
GIT_SUBMODULE_STRATEGY: normal
# nektarpp/nektar image
dockerhub-build-workbook:
<<: *dockerhub_build_template
stage: package-build
needs: []
variables:
image_name: nektar-workbook
dockerfile: docker/nektar-workbook/Dockerfile
# nektarpp/nektar-dev image
dockerhub-build-dev:
<<: *dockerhub_build_template
stage: package-build-dev
needs: [ "dockerhub-build-nektar" ]
variables:
image_name: nektar-dev
args: --build-arg ENV_IMAGE=$CI_REGISTRY_IMAGE/nektar-env:$CI_COMMIT_SHORT_SHA --build-arg NEKTAR_IMAGE=$CI_REGISTRY_IMAGE/nektar:$CI_COMMIT_SHORT_SHA
dockerfile: docker/nektar-dev/Dockerfile
# Test the dockerhub images
dockerhub-test-nektar:
<<: *dockerhub_test_template
needs: [ "dockerhub-build-nektar" ]
variables:
image_name: nektar
script:
- mpirun -n 3 IncNavierStokesSolver $CI_PROJECT_DIR/solvers/IncNavierStokesSolver/Tests/ChanFlow_m3_par.xml
dockerhub-test-nektar-dev:
<<: *dockerhub_test_template
needs: [ "dockerhub-build-dev" ]
variables:
image_name: nektar-dev
script:
- cd $CI_PROJECT_DIR/templates/executable
- ./test.sh /usr/local/lib64/nektar++/cmake 3
# Deployment
dockerhub-deploy-nektar:
<<: *dockerhub_deploy_template
variables:
image_name: nektar
dockerhub-deploy-nektar-env:
<<: *dockerhub_deploy_template
variables:
image_name: nektar-env
dockerhub-deploy-nektar-dev:
<<: *dockerhub_deploy_template
variables:
image_name: nektar-dev
dockerhub-deploy-nektar-workbook:
<<: *dockerhub_deploy_template
variables:
image_name: nektar-workbook