IAP GITLAB

.gitlab-ci.yml 12.1 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
Ralf Ulrich's avatar
Ralf Ulrich committed
15
  corsika_DIR: "${CI_PROJECT_DIR}/build/install" # for cmake to find corsikaConfig.cmake
16
  # _alternatively_ corsika-data can be downloaded as submodule:
Ralf Ulrich's avatar
Ralf Ulrich committed
17 18
  GIT_SUBMODULE_STRATEGY: normal # none: we get the submodules in before_script,
                                 # normal: get submodules automatically
19 20 21 22 23


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


39 40


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

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

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

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

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

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

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



128 129

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

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

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

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


174 175 176


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

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

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



229

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

##########################################################
# 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
241
    - cmake --build . -- -j4
242
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
243
    - ctest -j4 
244
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
245
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
Ralf M Ulrich's avatar
failure  
Ralf M Ulrich committed
246
      allow_failure: false
247 248 249 250 251 252 253 254 255
    - 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
256
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
257
  cache:
258
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
259
      - ${CI_PROJECT_DIR}/build/
260 261 262 263 264 265 266 267 268 269 270 271 272
    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
273
build_test-clang-8:
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"



283

284

Ralf Ulrich's avatar
Ralf Ulrich committed
285
####### BUILD-TEST-EXAMPLE (only non-Draft)  ##############
286 287 288 289 290 291 292 293 294 295

##########################################################
# 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
296
    - cmake --build . -- -j4
297
    - set -o pipefail
298 299
    - ctest -j4
    - make install
Ralf Ulrich's avatar
Ralf Ulrich committed
300 301 302
    - mkdir -p build_examples
    - cd build_examples
    - cmake ../install/share/corsika/examples
303
    - make -j4
304 305
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
306
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
307 308
      when: manual
      allow_failure: true
309
    - if: $CI_COMMIT_BRANCH
310 311 312 313 314 315 316 317 318
    - 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
319
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
320
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
321
      - ${CI_PROJECT_DIR}/build/build_examples/examples.log.gz
322
  cache:
323
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
324
      - ${CI_PROJECT_DIR}/build/
325 326 327 328
    untracked: true
    policy: pull

# build_test_example for gcc
329
build_test_example-u-18_04:
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
  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"




349 350 351 352 353 354 355
####### INSTALL  ##############

##########################################################
# generic install template job
# make install
.install:
  stage: install
Ralf M Ulrich's avatar
Ralf M Ulrich committed
356 357 358 359 360
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
361
    - make -j2 install
362
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
363
    - if: $CI_MERGE_REQUEST_ID
364
      when: manual
365
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
366
      when: manual
367
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
368
    - if: $CI_COMMIT_BRANCH
369 370
      when: manual
  allow_failure: true
371
  cache:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
372
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
373
      - ${CI_PROJECT_DIR}/build/
374
    untracked: true
375
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
376

377
# install for gcc
378
install-u-18_04:
379
  extends: .install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
380 381
  image: corsika/devel:u-18.04
  dependencies:
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
    - 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"



397

398 399 400 401 402 403
####### OPTIONAL ##############

##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
404
  stage: optional
405 406 407
  tags:
    - corsika
  script:
408
    - cd build
409
    - cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_Pythia8_C8=C8
410
    - cmake --build . -- -j4
411
    - set -o pipefail
412 413
    - ctest -j4
    - make install
Ralf Ulrich's avatar
Ralf Ulrich committed
414 415 416
    - mkdir -p build_examples
    - cd build_examples
    - cmake ../install/share/corsika/examples
417
    - make -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
418
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
419 420 421 422 423 424 425 426 427 428 429
  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
430
  cache:
431
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
432
      - ${CI_PROJECT_DIR}/build/
433
    untracked: true
434
    policy: pull
435
  artifacts:
436
    when: always
437
    expire_in: 3 days
438 439
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
440
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
441
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
442
      - ${CI_PROJECT_DIR}/build/build_examples/examples.log.gz
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
443

444 445 446 447 448 449 450 451 452 453
# 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
454
release-full-clang-8:
455
  extends: .release
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
456 457 458
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
459 460 461
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
462

463 464


465 466
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
467

468
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
469 470 471 472 473 474 475 476
  image: corsika/devel:u-18.04
  dependencies:
    - config-u-18_04
  stage: optional
  tags:
    - corsika
  script:
    - cd build
477
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_Pythia8_C8=C8
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
478
    - cmake --build . -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
479
    - ctest -j4 
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
480 481
    - cmake --build . --target coverage
    - tar czf coverage-report.tar.gz coverage-report
482
  coverage: '/^.*lines\.+:\s(.*\%)\s/'
483 484 485 486 487 488 489 490 491
  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
492
  artifacts:
493
    when: always
494
    expire_in: 1 year
495
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
496
      - ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
497
  cache:
498
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
499
      - ${CI_PROJECT_DIR}/build/
500
    untracked: true
501 502
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
Ralf Ulrich committed
503

Ralf Ulrich's avatar
Ralf Ulrich committed
504

505 506


507

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
508

509

510
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
511 512 513 514 515 516 517 518 519 520 521
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
522 523 524 525 526 527 528 529 530 531 532
  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
533
  cache:
534
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
535
      - ${CI_PROJECT_DIR}/build/
536
    untracked: true
537 538
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"