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
  CTEST_OUTPUT_ON_FAILURE: 1
20 21 22 23 24


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


40 41


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

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

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

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

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

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

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



129 130

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

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

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

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


175 176 177


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

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

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



230

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

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



284

285

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

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

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




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

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

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



398

399 400 401 402 403 404
####### OPTIONAL ##############

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

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

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
463

464 465


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

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

Ralf Ulrich's avatar
Ralf Ulrich committed
505

506 507


508

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
509

510

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