IAP GITLAB

.gitlab-ci.yml 12.4 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
#
25
# Mote: "Draft/WIP:" merge request, non-Draft/non-WIP 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
####### 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
Ralf M Ulrich's avatar
Ralf M Ulrich committed
107

108 109 110 111 112 113 114 115
# config for gcc
config-u-18_04:
  extends: .config
  image: corsika/devel:u-18.04

# config for clang
config-clang-8:
  extends: .config
Ralf M Ulrich's avatar
Ralf M Ulrich committed
116
  image: corsika/devel:clang-8
117 118 119



120 121

####### BUILD (only manual) ##############
122 123 124 125 126

##########################################################
# the generic build template job
# normal pipeline for each commit
.build:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
127 128 129 130
  stage: build
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
131
    - mkdir -p build
Ralf M Ulrich's avatar
Ralf M Ulrich committed
132
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
133
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
Ralf M Ulrich's avatar
Ralf M Ulrich committed
134
    - cmake --build . -- -j4
135 136
  rules:
    - if: $CI_MERGE_REQUEST_ID
137
      when: manual
138
    - if: $CI_COMMIT_TAG
139
      when: manual
140
    - if: $CI_COMMIT_BRANCH
141 142
      when: manual
  allow_failure: true
Ralf M Ulrich's avatar
Ralf M Ulrich committed
143

144 145 146
# build for gcc
build-u-18_04:
  extends: .build
Ralf M Ulrich's avatar
Ralf M Ulrich committed
147
  image: corsika/devel:u-18.04
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
148

149
# build for clang
150
build-clang-8:
151
  extends: .build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
152
  image: corsika/devel:clang-8
153

154 155 156


####### TEST (only manual)  ##############
157 158 159 160 161

##########################################################
# generic test template job
# normal pipeline for each commit
.test:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
162
  stage: test
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
163 164 165
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
166
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
167
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
168
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
169
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
170
    - ctest -j4 
171 172
  rules:
    - if: $CI_MERGE_REQUEST_ID
173
      when: manual
174
    - if: $CI_COMMIT_TAG
175
      when: manual
176
    - if: $CI_COMMIT_BRANCH
177 178
      when: manual
  allow_failure: true
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
179
  artifacts:
180
    when: always
181
    expire_in: 3 days
182 183
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
184
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
Ralf M Ulrich's avatar
Ralf M Ulrich committed
185

186 187 188
# test for gcc
test-u-18_04:
  extends: .test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
189
  image: corsika/devel:u-18.04
190 191 192 193 194 195 196 197

# test for clang
test-clang-8:
  extends: .test
  image: corsika/devel:clang-8



198

199
####### BUILD-TEST (all builds <= Draft/WIP, default) ##############
200 201 202 203 204 205 206 207 208

##########################################################
# the generic build_test template job
# normal pipeline for each commit
.build_test:
  stage: build_test
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
209
    - mkdir -p build
210
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
211
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
Ralf Ulrich's avatar
Ralf Ulrich committed
212
    - cmake --build . -- -j4
213
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
214
    - ctest -j4 
215
  rules:
216
    - if: '$CI_MERGE_REQUEST_ID && ($CI_MERGE_REQUEST_TITLE =~ /^Draft:/ || $CI_MERGE_REQUEST_TITLE =~ /^WIP:/)'
Ralf M Ulrich's avatar
failure  
Ralf M Ulrich committed
217
      allow_failure: false
218 219 220 221 222 223
    - if: $CI_MERGE_REQUEST_ID
      when: manual
      allow_failure: true
  artifacts:
    when: always
    expire_in: 3 days
Ralf Ulrich's avatar
Ralf Ulrich committed
224 225
    paths:
      - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
226 227
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
228
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
229 230 231 232 233

# build_test for gcc
build_test-u-18_04:
  extends: .build_test
  image: corsika/devel:u-18.04
Ralf Ulrich's avatar
Ralf Ulrich committed
234 235 236
  needs:
    - job: config-u-18_04
      artifacts: false
237 238

# build_test for clang
239
build_test-clang-8:
240 241
  extends: .build_test
  image: corsika/devel:clang-8
Ralf Ulrich's avatar
Ralf Ulrich committed
242 243 244
  needs:
    - job: config-clang-8
      artifacts: false
245 246 247



248

249

250
####### BUILD-TEST-EXAMPLE (only non-Draft/non-WIP)  ##############
251 252 253 254

##########################################################
# generic example template job
# normal pipeline for each commit
Ralf Ulrich's avatar
Ralf Ulrich committed
255
# artefacts are needed as input for python jobs
256 257 258 259 260
.build_test_example:
  stage: build_test_example
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
261
    - mkdir -p build
262
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
263
    - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
Ralf Ulrich's avatar
Ralf Ulrich committed
264
    - cmake --build . -- -j4
265
    - set -o pipefail
266
    - ctest -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
267
    - cmake --install .
Ralf Ulrich's avatar
Ralf Ulrich committed
268 269
    - mkdir -p build_examples
    - cd build_examples
Ralf Ulrich's avatar
Ralf Ulrich committed
270
    - cmake -DCMAKE_BUILD_TYPE=Debug ../install/share/corsika/examples
Ralf Ulrich's avatar
Ralf Ulrich committed
271
    - cmake --build . -- -j2
Ralf Ulrich's avatar
Ralf Ulrich committed
272
    - cmake --build . --target run_examples -- -j2 
273
  rules:
274
    - if: '$CI_MERGE_REQUEST_ID && ($CI_MERGE_REQUEST_TITLE =~ /^Draft:/ || $CI_MERGE_REQUEST_TITLE =~ /^WIP:/)'
275 276
      when: manual
      allow_failure: true
277
    - if: $CI_COMMIT_BRANCH
278 279 280 281 282 283 284 285 286
    - 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
287
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
288
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
289
      - ${CI_PROJECT_DIR}/build/build_examples/example_outputs
Ralf Ulrich's avatar
Ralf Ulrich committed
290
      - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
291 292

# build_test_example for gcc
293
build_test_example-u-18_04:
294 295
  extends: .build_test_example
  image: corsika/devel:u-18.04
Ralf Ulrich's avatar
Ralf Ulrich committed
296 297 298 299
  needs:
    - job: config-u-18_04
      artifacts: false

300 301 302 303 304

# build_test_example for clang
build_test_example-clang-8:
  extends: .build_test_example
  image: corsika/devel:clang-8
Ralf Ulrich's avatar
Ralf Ulrich committed
305 306 307
  needs:
    - job: config-clang-8
      artifacts: false
308 309 310 311




312
####### INSTALL (only manual)  ##############
313 314 315 316 317 318

##########################################################
# generic install template job
# make install
.install:
  stage: install
Ralf M Ulrich's avatar
Ralf M Ulrich committed
319 320 321
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
322
    - mkdir -p build
Ralf M Ulrich's avatar
Ralf M Ulrich committed
323
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
324
    - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
Ralf M Ulrich's avatar
Ralf M Ulrich committed
325
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
326
    - cmake --install .
327
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
328
    - if: $CI_MERGE_REQUEST_ID
329
      when: manual
330
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
331
      when: manual
332 333 334
    - if: $CI_COMMIT_BRANCH
      when: manual
  allow_failure: true
Ralf M Ulrich's avatar
Ralf M Ulrich committed
335

336
# install for gcc
337
install-u-18_04:
338
  extends: .install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
339
  image: corsika/devel:u-18.04
340 341 342 343 344 345 346 347

# install for clang
install-clang-8:
  extends: .install
  image: corsika/devel:clang-8



348

349 350 351 352 353 354
####### OPTIONAL ##############

##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
355
  stage: optional
356 357 358
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
359
    - mkdir -p build
360
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
361
    - cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Release -DUSE_Pythia8_C8=C8
362
    - cmake --build . -- -j4
363
    - set -o pipefail
364
    - ctest -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
365
    - cmake --install .
Ralf Ulrich's avatar
Ralf Ulrich committed
366 367
    - mkdir -p build_examples
    - cd build_examples
Ralf Ulrich's avatar
Ralf Ulrich committed
368
    - cmake -DCMAKE_BUILD_TYPE=Release ../install/share/corsika/examples
Ralf Ulrich's avatar
Ralf Ulrich committed
369
    - cmake --build . -- -j2
Ralf Ulrich's avatar
Ralf Ulrich committed
370
    - cmake --build . --target run_examples -- -j2 
371 372 373 374 375 376 377 378 379 380 381
  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
382
  artifacts:
383
    when: always
384
    expire_in: 3 days
385 386
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
387
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
388
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
389
      - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
390

391 392 393 394
# release for gcc
release-full-u-18_04:
  extends: .release
  image: corsika/devel:u-18.04
Ralf Ulrich's avatar
Ralf Ulrich committed
395 396 397
  needs:
    - job: config-u-18_04
      artifacts: false
398 399

# release for clang
400
release-full-clang-8:
401
  extends: .release
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
402
  image: corsika/devel:clang-8
Ralf Ulrich's avatar
Ralf Ulrich committed
403 404 405
  needs:
    - job: config-clang-8
      artifacts: false
406

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
407

408 409


410 411
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
412

413
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
414
  image: corsika/devel:u-18.04
Ralf Ulrich's avatar
Ralf Ulrich committed
415 416 417
  needs:
    - job: config-u-18_04
      artifacts: false
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
418 419 420 421
  stage: optional
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
422
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
423
    - cd build
424
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_Pythia8_C8=C8
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
425
    - cmake --build . -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
426
    - ctest -j4 
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
427 428
    - cmake --build . --target coverage
    - tar czf coverage-report.tar.gz coverage-report
429
  coverage: '/^.*lines\.+:\s(.*\%)\s/'
430 431 432 433 434 435 436 437 438
  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
439
  artifacts:
440
    when: always
441
    expire_in: 3 month
442
    paths:
Ralf Ulrich's avatar
Ralf Ulrich committed
443
      - ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
Ralf Ulrich's avatar
Ralf Ulrich committed
444

Ralf Ulrich's avatar
Ralf Ulrich committed
445

446 447


448

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
449

450

451
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
452 453
sanity:
  image: corsika/devel:u-18.04
Ralf Ulrich's avatar
Ralf Ulrich committed
454 455 456 457
  needs:
    - job: config-u-18_04
      artifacts: false

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
458 459 460 461
  stage: optional
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
462
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
463
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
464
    - cmake .. -DWITH_CORSIKA_SANITIZERS_ENABLED=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
465
    - cmake --build . -- -j4
466 467 468 469 470 471 472 473 474 475 476
  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
Remy Prechelt's avatar
Remy Prechelt committed
477

Ralf Ulrich's avatar
Ralf Ulrich committed
478 479 480

######  Python ##########

481 482 483 484 485 486 487
##########################################################
# template for all Python jobs
.python:
  stage: python
  tags:
    - corsika
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
488
    - cd ${CI_PROJECT_DIR}/python  # change into the Python directory
489 490 491 492 493 494 495 496 497 498 499 500 501
    - 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
502
  image: corsika/analysis:python-3.9.5
Ralf Ulrich's avatar
Ralf Ulrich committed
503
  needs:
Ralf Ulrich's avatar
Ralf Ulrich committed
504 505
    - job: build_test_example-u-18_04
      artifacts: true
506 507
  artifacts:
    when: always
508
    expire_in: 3 month
509 510 511
    paths:
      - ${CI_PROJECT_DIR}/Python/python-test.log
  allow_failure: true