IAP GITLAB

.gitlab-ci.yml 12.7 KB
Newer Older
Ralf Ulrich's avatar
Ralf Ulrich committed
1
variables:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
2
  GIT_STRATEGY: $CORSIKA8_GIT_STRATEGY # 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

Ralf Ulrich's avatar
Ralf Ulrich committed
70
### CodeQuality tool ####
Ralf Ulrich's avatar
Ralf Ulrich committed
71 72 73 74 75 76 77 78 79 80 81
#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
82

83 84 85 86 87 88 89
####### CONFIG ##############

##########################################################
# the generic config template job
# job/stage to just prepare cmake
.config:
  stage: config
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
90 91
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
92
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
93
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
94
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
95
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_PYTHIA8_C8=SYSTEM
96 97 98
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
99
    - if: $CI_COMMIT_BRANCH
Ralf Ulrich's avatar
Ralf Ulrich committed
100 101 102 103 104
  artifacts:
    when: on_failure
    expire_in: 3 days
    paths:
      - ${CI_PROJECT_DIR}/build/CMakeFiles/CMakeOutput.log
105
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
106
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
107
      - ${CI_PROJECT_DIR}/build/
108
    untracked: true
Ralf Ulrich's avatar
ci file  
Ralf Ulrich committed
109
    policy: pull-push    
Ralf M Ulrich's avatar
Ralf M Ulrich committed
110

111 112 113 114 115 116 117 118 119 120
# 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
121
  image: corsika/devel:clang-8
122 123 124 125 126
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



127 128

####### BUILD (only manual) ##############
129 130 131 132 133

##########################################################
# the generic build template job
# normal pipeline for each commit
.build:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
134 135 136 137 138 139
  stage: build
  tags:
    - corsika
  script:
    - cd build
    - cmake --build . -- -j4
140 141
  rules:
    - if: $CI_MERGE_REQUEST_ID
142
      when: manual
143
    - if: $CI_COMMIT_TAG
144
      when: manual
145
    - if: $CI_COMMIT_BRANCH
146 147
      when: manual
  allow_failure: true
148
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
149
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
150
      - ${CI_PROJECT_DIR}/build/
151
    untracked: true
152
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
153

154 155 156
# build for gcc
build-u-18_04:
  extends: .build
Ralf M Ulrich's avatar
Ralf M Ulrich committed
157 158
  image: corsika/devel:u-18.04
  dependencies:
159 160 161
    - config-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
162

163
# build for clang
164
build-clang-8:
165
  extends: .build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
166 167
  image: corsika/devel:clang-8
  dependencies:
168 169 170 171 172
    - config-clang-8
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


173 174 175


####### TEST (only manual)  ##############
176 177 178 179 180

##########################################################
# generic test template job
# normal pipeline for each commit
.test:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
181
  stage: test
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
182 183 184 185
  tags:
    - corsika
  script:
    - cd build
186
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
187
    - ctest -j4 
188 189
  rules:
    - if: $CI_MERGE_REQUEST_ID
190
      when: manual
191
    - if: $CI_COMMIT_TAG
192
      when: manual
193
    - if: $CI_COMMIT_BRANCH
194 195
      when: manual
  allow_failure: true
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
196
  artifacts:
197
    when: always
198
    expire_in: 3 days
199 200
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
201
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
202
  cache:
203
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
204
      - ${CI_PROJECT_DIR}/build/
205 206
    untracked: true
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
207

208 209 210
# test for gcc
test-u-18_04:
  extends: .test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
211 212 213
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
214 215 216 217 218 219 220 221 222 223 224 225 226 227
  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"



228

Ralf Ulrich's avatar
Ralf Ulrich committed
229
####### BUILD-TEST (all builds <= Draft, default) ##############
230 231 232 233 234 235 236 237 238 239

##########################################################
# the generic build_test template job
# normal pipeline for each commit
.build_test:
  stage: build_test
  tags:
    - corsika
  script:
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
240
    - cmake --build . -- -j4
241
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
242
    - ctest -j4 
243
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
244
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
Ralf M Ulrich's avatar
failure  
Ralf M Ulrich committed
245
      allow_failure: false
246 247 248 249 250 251 252 253 254
    - 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
255
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
256
  cache:
257
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
258
      - ${CI_PROJECT_DIR}/build/
259 260 261 262 263 264 265 266 267 268 269 270 271
    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
272
build_test-clang-8:
273 274 275 276 277 278 279 280 281 282
  extends: .build_test
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



####### EXAMPLE (only manual)  ##############
283 284 285 286 287

##########################################################
# generic example template job
# normal pipeline for each commit
.example:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
288 289 290 291 292 293
  stage: example
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
294
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
295
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
296
    - if: $CI_MERGE_REQUEST_ID
297
      when: manual
298
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
299
      when: manual
300
    - if: $CI_COMMIT_BRANCH
301 302
      when: manual
  allow_failure: true
Ralf M Ulrich's avatar
Ralf M Ulrich committed
303 304
  artifacts:
    when: always
305
    expire_in: 3 days
Ralf M Ulrich's avatar
Ralf M Ulrich committed
306
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
307
      - ${CI_PROJECT_DIR}/build/examples.log.gz
308
  cache:
309
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
310
      - ${CI_PROJECT_DIR}/build/
311
    untracked: true
312
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
313

314
# example for gcc
315
example-u-18_04:
316 317 318 319 320 321 322 323 324 325
  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
326 327 328
  image: corsika/devel:clang-8
  dependencies:
    - build-clang-8
329 330 331 332
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


333

Ralf Ulrich's avatar
Ralf Ulrich committed
334
####### BUILD-TEST-EXAMPLE (only non-Draft)  ##############
335 336 337 338 339 340 341 342 343 344

##########################################################
# 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
345
    - cmake --build . -- -j4
346
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
347
    - ctest -j4 
348 349
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
350
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
351 352
      when: manual
      allow_failure: true
353
    - if: $CI_COMMIT_BRANCH
354 355 356 357 358 359 360 361 362
    - 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
363
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
364
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
365
      - ${CI_PROJECT_DIR}/build/examples.log.gz
366
  cache:
367
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
368
      - ${CI_PROJECT_DIR}/build/
369 370 371 372
    untracked: true
    policy: pull

# build_test_example for gcc
373
build_test_example-u-18_04:
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
  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"




393 394 395 396 397 398 399
####### INSTALL  ##############

##########################################################
# generic install template job
# make install
.install:
  stage: install
Ralf M Ulrich's avatar
Ralf M Ulrich committed
400 401 402 403 404
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
405
    - make -j2 install
406
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
407
    - if: $CI_MERGE_REQUEST_ID
408
      when: manual
409
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
410
      when: manual
411
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
412
    - if: $CI_COMMIT_BRANCH
413 414
      when: manual
  allow_failure: true
415
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
416
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
417
      - ${CI_PROJECT_DIR}/build/
418
    untracked: true
419
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
420

421
# install for gcc
422
install-u-18_04:
423
  extends: .install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
424 425
  image: corsika/devel:u-18.04
  dependencies:
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
    - 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"



441

442 443 444 445 446 447
####### OPTIONAL ##############

##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
448
  stage: optional
449 450 451
  tags:
    - corsika
  script:
452
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
453
    - cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHIA8_C8=SYSTEM
454
    - cmake --build . -- -j4
455
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
456
    - ctest -j4 
Ralf Ulrich's avatar
Ralf Ulrich committed
457
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
458 459 460 461 462 463 464 465 466 467 468
  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
469
  cache:
470
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
471
      - ${CI_PROJECT_DIR}/build/
472
    untracked: true
473
    policy: pull
474
  artifacts:
475
    when: always
476
    expire_in: 3 days
477 478
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
479
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
480
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
481
      - ${CI_PROJECT_DIR}/build/examples.log.gz
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
482

483 484 485 486 487 488 489 490 491 492
# 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
493
release-full-clang-8:
494
  extends: .release
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
495 496 497
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
498 499 500
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
501

502 503


504 505
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
506

507
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
508 509 510 511 512 513 514 515
  image: corsika/devel:u-18.04
  dependencies:
    - config-u-18_04
  stage: optional
  tags:
    - corsika
  script:
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
516
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_PYTHIA8_C8=SYSTEM
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
517
    - cmake --build . -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
518
    - ctest -j4 
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
519 520
    - cmake --build . --target coverage
    - tar czf coverage-report.tar.gz coverage-report
Ralf Ulrich's avatar
Ralf Ulrich committed
521
  coverage: '/^.*functions\.+:\s(.*\%)\s/'
522 523 524 525 526 527 528 529 530
  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
531
  artifacts:
532
    when: always
533
    expire_in: 1 year
534
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
535
      - ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
536
  cache:
537
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
538
      - ${CI_PROJECT_DIR}/build/
539
    untracked: true
540 541
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
Ralf Ulrich committed
542

Ralf Ulrich's avatar
Ralf Ulrich committed
543

544 545


546

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
547

548

549
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
550 551 552 553 554 555 556 557 558 559 560
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
561 562 563 564 565 566 567 568 569 570 571
  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
572
  cache:
573
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
574
      - ${CI_PROJECT_DIR}/build/
575
    untracked: true
576 577
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Remy Prechelt's avatar
Remy Prechelt committed
578 579