IAP GITLAB

.gitlab-ci.yml 12 KB
Newer Older
Ralf Ulrich's avatar
Ralf Ulrich committed
1
variables:
Ralf Ulrich's avatar
Ralf Ulrich committed
2
  GIT_STRATEGY: fetch # clone: fresh clone, fetch: update
Ralf Ulrich's avatar
Ralf Ulrich committed
3
  GIT_SSL_NO_VERIFY: "1"
4
  GIT_DEPTH: "1"
5 6
  # to re-use clones also in different forks
  GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_NAME
7 8 9 10 11 12
  ## 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"
13
  # location of AirShowerPhysics/corsika-data
Ralf Ulrich's avatar
Ralf Ulrich committed
14
  CORSIKA_DATA: "${CI_PROJECT_DIR}/modules/data" # the git submodule
15
  # _alternatively_ corsika-data can be downloaded as submodule:
Ralf Ulrich's avatar
Ralf Ulrich committed
16 17
  GIT_SUBMODULE_STRATEGY: normal # none: we get the submodules in before_script,
                                 # normal: get submodules automatically
18 19 20 21 22


#
# multi-step pipeline for each commit
#
Ralf Ulrich's avatar
Ralf Ulrich committed
23
# Mote: "Draft:" merge request, non-Draft merge requests and "Ready for Code Review" MR are all
24 25
#       handled explicitly
#
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
26
stages:
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
27
  - quality
28
  - config
Ralf M Ulrich's avatar
Ralf M Ulrich committed
29 30
  - build
  - test
31
  - build_test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
32
  - example
33
  - build_test_example
34
  - install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
35 36 37
  - optional


38 39


40
####### CODE QUALITY CHECK ##############
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
41

42
##########################################################
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
43 44 45 46 47 48 49
check-copyrights:
  image: corsika/devel:u-18.04
  stage: quality
  tags:
    - corsika
  script:
    - ./do-copyright.py
50 51 52
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
53
    - if: $CI_COMMIT_BRANCH
54
  allow_failure: true
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
55

56
##########################################################
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
57
check-clang-format:
58
  image: corsika/devel:clang-8
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
59 60 61 62 63
  stage: quality
  tags:
    - corsika
  script:
    - ./do-clang-format.py --all
64 65 66
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
67
    - if: $CI_COMMIT_BRANCH
68
  allow_failure: true
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
69

70 71


72

73 74 75 76 77 78 79
####### CONFIG ##############

##########################################################
# the generic config template job
# job/stage to just prepare cmake
.config:
  stage: config
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
80 81
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
82
  script:    
Ralf Ulrich's avatar
Ralf Ulrich committed
83
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
84
    - cd build
85 86 87 88
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_PYTHIA=ON
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
89
    - if: $CI_COMMIT_BRANCH
90
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
91
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
92
      - ${CI_PROJECT_DIR}/build/
93
    untracked: true
94
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
95

96 97 98 99 100 101 102 103 104 105
# 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
Ralf M Ulrich's avatar
Ralf M Ulrich committed
106
  image: corsika/devel:clang-8
107 108 109 110 111
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



112 113

####### BUILD (only manual) ##############
114 115 116 117 118

##########################################################
# the generic build template job
# normal pipeline for each commit
.build:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
119 120 121 122 123 124
  stage: build
  tags:
    - corsika
  script:
    - cd build
    - cmake --build . -- -j4
125 126
  rules:
    - if: $CI_MERGE_REQUEST_ID
127
      when: manual
128
    - if: $CI_COMMIT_TAG
129
      when: manual
130
    - if: $CI_COMMIT_BRANCH
131 132
      when: manual
  allow_failure: true
133
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
134
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
135
      - ${CI_PROJECT_DIR}/build/
136
    untracked: true
137
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
138

139 140 141
# build for gcc
build-u-18_04:
  extends: .build
Ralf M Ulrich's avatar
Ralf M Ulrich committed
142 143
  image: corsika/devel:u-18.04
  dependencies:
144 145 146
    - config-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
147

148
# build for clang
149
build-clang-8:
150
  extends: .build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
151 152
  image: corsika/devel:clang-8
  dependencies:
153 154 155 156 157
    - config-clang-8
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


158 159 160


####### TEST (only manual)  ##############
161 162 163 164 165

##########################################################
# generic test template job
# normal pipeline for each commit
.test:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
166
  stage: test
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
167 168 169 170
  tags:
    - corsika
  script:
    - cd build
171
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
172
    - ctest -j4 
173 174
  rules:
    - if: $CI_MERGE_REQUEST_ID
175
      when: manual
176
    - if: $CI_COMMIT_TAG
177
      when: manual
178
    - if: $CI_COMMIT_BRANCH
179 180
      when: manual
  allow_failure: true
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
181
  artifacts:
182
    when: always
183
    expire_in: 3 days
184 185
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
186
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
187
  cache:
188
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
189
      - ${CI_PROJECT_DIR}/build/
190 191
    untracked: true
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
192

193 194 195
# test for gcc
test-u-18_04:
  extends: .test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
196 197 198
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
199 200 201 202 203 204 205 206 207 208 209 210 211 212
  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"



213

Ralf Ulrich's avatar
Ralf Ulrich committed
214
####### BUILD-TEST (all builds <= Draft, default) ##############
215 216 217 218 219 220 221 222 223 224 225 226

##########################################################
# 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
Ralf Ulrich's avatar
Ralf Ulrich committed
227
    - ctest -j4 
228
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
229
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
Ralf M Ulrich's avatar
failure  
Ralf M Ulrich committed
230
      allow_failure: false
231 232 233 234 235 236 237 238 239
    - if: $CI_MERGE_REQUEST_ID
      when: manual
      allow_failure: true
  allow_failure: true
  artifacts:
    when: always
    expire_in: 3 days
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
240
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
241
  cache:
242
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
243
      - ${CI_PROJECT_DIR}/build/
244 245 246 247 248 249 250 251 252 253 254 255 256
    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
257
build_test-clang-8:
258 259 260 261 262 263 264 265 266 267
  extends: .build_test
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



####### EXAMPLE (only manual)  ##############
268 269 270 271 272

##########################################################
# generic example template job
# normal pipeline for each commit
.example:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
273 274 275 276 277 278
  stage: example
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
279
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
280
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
281
    - if: $CI_MERGE_REQUEST_ID
282
      when: manual
283
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
284
      when: manual
285
    - if: $CI_COMMIT_BRANCH
286 287
      when: manual
  allow_failure: true
Ralf M Ulrich's avatar
Ralf M Ulrich committed
288 289
  artifacts:
    when: always
290
    expire_in: 3 days
Ralf M Ulrich's avatar
Ralf M Ulrich committed
291
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
292
      - ${CI_PROJECT_DIR}/build/examples.log.gz
293
  cache:
294
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
295
      - ${CI_PROJECT_DIR}/build/
296
    untracked: true
297
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
298

299
# example for gcc
300
example-u-18_04:
301 302 303 304 305 306 307 308 309 310
  extends: .example
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"

# example for clang
example-clang-8:
  extends: .example
Ralf M Ulrich's avatar
Ralf M Ulrich committed
311 312 313
  image: corsika/devel:clang-8
  dependencies:
    - build-clang-8
314 315 316 317
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


318

Ralf Ulrich's avatar
Ralf Ulrich committed
319
####### BUILD-TEST-EXAMPLE (only non-Draft)  ##############
320 321 322 323 324 325 326 327 328 329

##########################################################
# generic example template job
# normal pipeline for each commit
.build_test_example:
  stage: build_test_example
  tags:
    - corsika
  script:
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
330
    - cmake --build . -- -j4
331
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
332
    - ctest -j4 
333 334
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
335
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
336 337
      when: manual
      allow_failure: true
338
    - if: $CI_COMMIT_BRANCH
339 340 341 342 343 344 345 346 347
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
      when: manual
      allow_failure: true
  artifacts:
    when: always
    expire_in: 3 days
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
348
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
349
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
350
      - ${CI_PROJECT_DIR}/build/examples.log.gz
351
  cache:
352
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
353
      - ${CI_PROJECT_DIR}/build/
354 355 356 357
    untracked: true
    policy: pull

# build_test_example for gcc
358
build_test_example-u-18_04:
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
  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"




378 379 380 381 382 383 384
####### INSTALL  ##############

##########################################################
# generic install template job
# make install
.install:
  stage: install
Ralf M Ulrich's avatar
Ralf M Ulrich committed
385 386 387 388 389
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
390
    - make -j2 install
391
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
392
    - if: $CI_MERGE_REQUEST_ID
393
      when: manual
394
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
395
      when: manual
396
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
397
    - if: $CI_COMMIT_BRANCH
398 399
      when: manual
  allow_failure: true
400
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
401
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
402
      - ${CI_PROJECT_DIR}/build/
403
    untracked: true
404
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
405

406
# install for gcc
407
install-u-18_04:
408
  extends: .install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
409 410
  image: corsika/devel:u-18.04
  dependencies:
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
    - 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"



426

427 428 429 430 431 432
####### OPTIONAL ##############

##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
433
  stage: optional
434 435 436
  tags:
    - corsika
  script:
437
    - cd build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
438
    - cmake .. -DCMAKE_BUILD_TYPE=Release
439
    - cmake --build . -- -j4
440
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
441
    - ctest -j4 
Ralf Ulrich's avatar
Ralf Ulrich committed
442
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
443 444 445 446 447 448 449 450 451 452 453
  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
454
  cache:
455
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
456
      - ${CI_PROJECT_DIR}/build/
457
    untracked: true
458
    policy: pull
459
  artifacts:
460
    when: always
461
    expire_in: 3 days
462 463
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
464
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
465
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
466
      - ${CI_PROJECT_DIR}/build/examples.log.gz
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
467

468 469 470 471 472 473 474 475 476 477
# 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
478
release-full-clang-8:
479
  extends: .release
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
480 481 482
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
483 484 485
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
486

487 488


489 490
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
491

492
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
493 494 495 496 497 498 499 500 501 502
  image: corsika/devel:u-18.04
  dependencies:
    - config-u-18_04
  stage: optional
  tags:
    - corsika
  script:
    - cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage
    - cmake --build . -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
503
    - ctest -j4 
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
504 505
    - cmake --build . --target coverage
    - tar czf coverage-report.tar.gz coverage-report
Ralf Ulrich's avatar
Ralf Ulrich committed
506
  coverage: '/^.*functions\.+:\s(.*\%)\s/'
507 508 509 510 511 512 513 514 515
  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
516
  artifacts:
517
    when: always
518
    expire_in: 1 year
519
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
520
      - ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
521
  cache:
522
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
523
      - ${CI_PROJECT_DIR}/build/
524
    untracked: true
525 526
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
Ralf Ulrich committed
527

Ralf Ulrich's avatar
Ralf Ulrich committed
528

529 530


531

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
532

533

534
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
535 536 537 538 539 540 541 542 543 544 545
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
546 547 548 549 550 551 552 553 554 555 556
  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
557
  cache:
558
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
559
      - ${CI_PROJECT_DIR}/build/
560
    untracked: true
561 562
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Remy Prechelt's avatar
Remy Prechelt committed
563 564