IAP GITLAB

.gitlab-ci.yml 13.3 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
Remy Prechelt's avatar
Remy Prechelt committed
36
  - python
37
  - install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
38 39 40
  - optional


41 42


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

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

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

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

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

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

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



130 131

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

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

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

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


176 177 178


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

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

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



231

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

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



287

288

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

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

# build_test_example for gcc
335
build_test_example-u-18_04:
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
  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"




355 356 357 358 359 360 361
####### INSTALL  ##############

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

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



403

404 405 406 407 408 409
####### OPTIONAL ##############

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

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

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
469

470 471


472 473
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
474

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

Ralf Ulrich's avatar
Ralf Ulrich committed
511

512 513


514

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
515

516

517
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
518 519 520 521 522 523 524 525 526 527 528
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
529 530 531 532 533 534 535 536 537 538 539
  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
540
  cache:
541
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
542
      - ${CI_PROJECT_DIR}/build/
543
    untracked: true
544 545
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Remy Prechelt's avatar
Remy Prechelt committed
546

547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
##########################################################
# template for all Python jobs
.python:
  stage: python
  tags:
    - corsika
  before_script:
    - apt-get update && apt-get install -y python3-pip
  script:
    - cd ${CI_PROJECT_DIR}/Python  # change into the Python directory
    - pip3 install --user -e '.[test]'  # install the package + test deps
    - python3 --version
    - python3 -m mypy corsika
    - python3 -m isort --atomic --check-only corsika tests
    - python3 -m black -t py37 corsika tests
    - python3 -m flake8 corsika tests
    - python3 -m pytest --cov=corsika tests
    - cd ${CI_PROJECT_DIR}  # reset the directory
  coverage: '/^TOTAL\s*\d+\s*\d+\s*(.*\%)/'

# the default Python version Ubuntu 18.04 is Python3.8
python-3.8:
  extends: .python
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"
  artifacts:
    when: always
    expire_in: 1 year
    paths:
      - ${CI_PROJECT_DIR}/Python/python-test.log
  allow_failure: true