IAP GITLAB

.gitlab-ci.yml 12.9 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
95
    - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Debug -DUSE_PYTHIA8_C8=C8
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
347 348 349 350
    - ctest -j4
    - make install
    - cd install/share/examples
    - make -j4
351 352
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
353
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
354 355
      when: manual
      allow_failure: true
356
    - if: $CI_COMMIT_BRANCH
357 358 359 360 361 362 363 364 365
    - 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
366
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
367
    paths:
368
      - ${CI_PROJECT_DIR}/build/install/share/examples/examples.log.gz
369
  cache:
370
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
371
      - ${CI_PROJECT_DIR}/build/
372 373 374 375
    untracked: true
    policy: pull

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




396 397 398 399 400 401 402
####### INSTALL  ##############

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

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



444

445 446 447 448 449 450
####### OPTIONAL ##############

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

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

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
507

508 509


510 511
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
512

513
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
514 515 516 517 518 519 520 521
  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
522
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_PYTHIA8_C8=C8
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
523
    - cmake --build . -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
524
    - ctest -j4 
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
525 526
    - cmake --build . --target coverage
    - tar czf coverage-report.tar.gz coverage-report
Ralf Ulrich's avatar
Ralf Ulrich committed
527
  coverage: '/^.*functions\.+:\s(.*\%)\s/'
528 529 530 531 532 533 534 535 536
  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
537
  artifacts:
538
    when: always
539
    expire_in: 1 year
540
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
541
      - ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
542
  cache:
543
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
544
      - ${CI_PROJECT_DIR}/build/
545
    untracked: true
546 547
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
Ralf Ulrich committed
548

Ralf Ulrich's avatar
Ralf Ulrich committed
549

550 551


552

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
553

554

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