Newer
Older
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
578
579
580
581
variables:
GIT_STRATEGY: $CORSIKA8_GIT_STRATEGY # clone: fresh clone, fetch: update
GIT_SSL_NO_VERIFY: "1"
GIT_DEPTH: "1"
# to re-use clones also in different forks
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_NAME
## Runtime options for sanitizers
# (detect_leaks=0 because leak detection doesn't work in CI, but you can
# try to test with leak detection locally by using detect_leaks=1)
UBSAN_OPTIONS: "print_stacktrace=1"
LSAN_OPTIONS: "log_threads=1"
ASAN_OPTIONS: "detect_leaks=0:detect_stack_use_after_return=1"
# location of AirShowerPhysics/corsika-data
CORSIKA_DATA: "${CI_PROJECT_DIR}/modules/data" # the git submodule
corsika_DIR: "${CI_PROJECT_DIR}/build/install" # for cmake to find corsikaConfig.cmake
# _alternatively_ corsika-data can be downloaded as submodule:
GIT_SUBMODULE_STRATEGY: normal # none: we get the submodules in before_script,
# normal: get submodules automatically
CTEST_OUTPUT_ON_FAILURE: 1
#
# multi-step pipeline for each commit
#
# Mote: "Draft:" merge request, non-Draft merge requests and "Ready for Code Review" MR are all
# handled explicitly
#
stages:
- quality
- config
- build
- test
- build_test
- example
- build_test_example
- python
- install
- optional
####### CODE QUALITY CHECK ##############
##########################################################
check-copyrights:
image: corsika/devel:u-18.04
stage: quality
tags:
- corsika
script:
- ./do-copyright.py
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
allow_failure: true
##########################################################
check-clang-format:
image: corsika/devel:clang-8
stage: quality
tags:
- corsika
script:
- ./do-clang-format.py --all
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
allow_failure: true
### CodeQuality tool ####
#include:
# - template: Code-Quality.gitlab-ci.yml
#
#code_quality:
# stage: quality
# rules:
# - if: '$CODE_QUALITY_DISABLED'
# when: never
# - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines
# - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines)
# - if: '$CI_COMMIT_TAG' # Run code quality job in pipelines for tags
####### CONFIG ##############
##########################################################
# the generic config template job
# job/stage to just prepare cmake
.config:
stage: config
tags:
- corsika
script:
- mkdir -p build
- cd build
- cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
artifacts:
when: on_failure
expire_in: 3 days
paths:
- ${CI_PROJECT_DIR}/build/CMakeFiles/CMakeOutput.log
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull-push
# config for gcc
config-u-18_04:
extends: .config
image: corsika/devel:u-18.04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# config for clang
config-clang-8:
extends: .config
image: corsika/devel:clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
####### BUILD (only manual) ##############
##########################################################
# the generic build template job
# normal pipeline for each commit
.build:
stage: build
tags:
- corsika
script:
- cd build
- cmake --build . -- -j4
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
- if: $CI_COMMIT_TAG
when: manual
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull-push
# build for gcc
build-u-18_04:
extends: .build
image: corsika/devel:u-18.04
dependencies:
- config-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# build for clang
build-clang-8:
extends: .build
image: corsika/devel:clang-8
dependencies:
- config-clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
####### TEST (only manual) ##############
##########################################################
# generic test template job
# normal pipeline for each commit
.test:
stage: test
tags:
- corsika
script:
- cd build
- set -o pipefail
- ctest -j4
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
- if: $CI_COMMIT_TAG
when: manual
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
artifacts:
when: always
expire_in: 3 days
reports:
junit:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull-push
# test for gcc
test-u-18_04:
extends: .test
image: corsika/devel:u-18.04
dependencies:
- build-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# test for clang
test-clang-8:
extends: .test
image: corsika/devel:clang-8
dependencies:
- build-clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
####### BUILD-TEST (all builds <= Draft, default) ##############
##########################################################
# the generic build_test template job
# normal pipeline for each commit
.build_test:
stage: build_test
tags:
- corsika
script:
- cd build
- cmake --build . -- -j4
- set -o pipefail
- ctest -j4
rules:
- if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
allow_failure: false
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
artifacts:
when: always
expire_in: 3 days
paths:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
reports:
junit:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull-push
# build_test for gcc
build_test-u-18_04:
extends: .build_test
image: corsika/devel:u-18.04
dependencies:
- config-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# build_test for clang
build_test-clang-8:
extends: .build_test
image: corsika/devel:clang-8
dependencies:
- config-clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
####### BUILD-TEST-EXAMPLE (only non-Draft) ##############
##########################################################
# generic example template job
# normal pipeline for each commit
.build_test_example:
stage: build_test_example
tags:
- corsika
script:
- cd build
- cmake --build . -- -j4
- set -o pipefail
- ctest -j4
- make install
- mkdir -p build_examples
- cd build_examples
- cmake ../install/share/corsika/examples
- make -j4
- make -j4 run_examples | gzip -v -9 > examples.log.gz
rules:
- if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
when: manual
allow_failure: true
- if: $CI_COMMIT_BRANCH
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
artifacts:
when: always
expire_in: 3 days
reports:
junit:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
paths:
- ${CI_PROJECT_DIR}/build/build_examples/examples.log.gz
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull
# build_test_example for gcc
build_test_example-u-18_04:
extends: .build_test_example
image: corsika/devel:u-18.04
dependencies:
- config-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# build_test_example for clang
build_test_example-clang-8:
extends: .build_test_example
image: corsika/devel:clang-8
dependencies:
- config-clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
####### INSTALL ##############
##########################################################
# generic install template job
# make install
.install:
stage: install
tags:
- corsika
script:
- cd build
- set -o pipefail
- make -j2 install
rules:
- if: '$CI_MERGE_REQUEST_LABELS =~ /Ready for code review/' # run on merge requests, if label 'Ready for code review' is set
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull
# install for gcc
install-u-18_04:
extends: .install
image: corsika/devel:u-18.04
dependencies:
- build-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# install for clang
install-clang-8:
extends: .install
image: corsika/devel:clang-8
dependencies:
- build-clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
####### OPTIONAL ##############
##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
stage: optional
tags:
- corsika
script:
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_Pythia8_C8=C8
- cmake --build . -- -j4
- set -o pipefail
- ctest -j4
- make install
- mkdir -p build_examples
- cd build_examples
- cmake ../install/share/corsika/examples
- make -j4
- make -j4 run_examples | gzip -v -9 > examples.log.gz
rules:
- if: '$CI_MERGE_REQUEST_LABELS =~ /Ready for code review/' # run on merge requests, if label 'Ready for code review' is set
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull
artifacts:
when: always
expire_in: 3 days
reports:
junit:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
paths:
- ${CI_PROJECT_DIR}/build/build_examples/examples.log.gz
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
# release for gcc
release-full-u-18_04:
extends: .release
image: corsika/devel:u-18.04
dependencies:
- config-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# release for clang
release-full-clang-8:
extends: .release
image: corsika/devel:clang-8
dependencies:
- config-clang-8
cache:
key: "${CI_COMMIT_REF_SLUG}-clang"
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
coverage:
image: corsika/devel:u-18.04
dependencies:
- config-u-18_04
stage: optional
tags:
- corsika
script:
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_Pythia8_C8=C8
- cmake --build . -- -j4
- ctest -j4
- cmake --build . --target coverage
- tar czf coverage-report.tar.gz coverage-report
coverage: '/^.*lines\.+:\s(.*\%)\s/'
rules:
- if: '$CI_MERGE_REQUEST_LABELS =~ /Ready for code review/' # run on merge requests, if label 'Ready for code review' is set
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
artifacts:
when: always
expire_in: 1 year
paths:
- ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull
key: "${CI_COMMIT_REF_SLUG}-gcc"
##########################################################
sanity:
image: corsika/devel:u-18.04
dependencies:
- config-u-18_04
stage: optional
tags:
- corsika
script:
- cd build
- cmake .. -DWITH_CORSIKA_SANITIZERS_ENABLED=ON
- cmake --build . -- -j4
rules:
- if: '$CI_MERGE_REQUEST_LABELS =~ /Ready for code review/' # run on merge requests, if label 'Ready for code review' is set
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
allow_failure: true
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
cache:
paths:
- ${CI_PROJECT_DIR}/build/
untracked: true
policy: pull
key: "${CI_COMMIT_REF_SLUG}-gcc"
##########################################################
# template for all Python jobs
.python:
stage: python
tags:
- corsika
before_script:
- apt-get update && apt-get install -y python3-pip
- pip3 install --upgrade cython
script:
- cd ${CI_PROJECT_DIR}/python # change into the Python directory
- pip3 install --user -e '.[test]' # install the package + test deps
- python3 --version
- python3 -m mypy corsika
- python3 -m isort --atomic --check-only corsika tests
- python3 -m black -t py37 corsika tests
- python3 -m flake8 corsika tests
- python3 -m pytest --cov=corsika tests
- cd ${CI_PROJECT_DIR} # reset the directory
coverage: '/^TOTAL\s*\d+\s*\d+\s*(.*\%)/'
# the default Python version Ubuntu 18.04 is Python3.8
python-3.8:
extends: .python
image: corsika/devel:u-18.04
dependencies:
- build-u-18_04
cache:
key: "${CI_COMMIT_REF_SLUG}-gcc"
artifacts:
when: always
expire_in: 1 year
paths:
- ${CI_PROJECT_DIR}/Python/python-test.log
allow_failure: true