IAP GITLAB

.gitlab-ci.yml 12.5 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


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
Ralf M Ulrich's avatar
Ralf M Ulrich committed
108

109 110 111 112 113 114 115 116
# 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
117
  image: corsika/devel:clang-8
118 119 120



121 122

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

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

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

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

155 156 157


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

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

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

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



199

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

##########################################################
# 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
210
    - mkdir -p build
211
    - cd build
Ralf Ulrich's avatar
Ralf Ulrich committed
212
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_Pythia8_C8=C8
Ralf Ulrich's avatar
Ralf Ulrich committed
213
    - cmake --build . -- -j4
214
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
215
    - ctest -j4 
216
  rules:
217
    - 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
218
      allow_failure: false
219 220 221 222 223 224
    - if: $CI_MERGE_REQUEST_ID
      when: manual
      allow_failure: true
  artifacts:
    when: always
    expire_in: 3 days
Ralf Ulrich's avatar
Ralf Ulrich committed
225 226
    paths:
      - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
227 228
    reports:
      junit:
Ralf Ulrich's avatar
Ralf Ulrich committed
229
        - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
230 231 232 233 234

# 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
235 236 237
  needs:
    - job: config-u-18_04
      artifacts: false
238 239

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



249

250

251
####### BUILD-TEST-EXAMPLE (only non-Draft/non-WIP)  ##############
252 253 254 255 256 257 258 259 260

##########################################################
# generic example template job
# normal pipeline for each commit
.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
install  
Ralf Ulrich committed
267
    - cmake --install . -- -j4
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_BUILT_TYPE=Debug ../install/share/corsika/examples
Ralf Ulrich's avatar
Ralf Ulrich committed
271 272
    - cmake --build . -- -j4
    - cmake --build --target run_examples . -- -j4 | gzip -v -9 > examples.log.gz
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/examples.log.gz
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 . -- -j4
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 . -- -j4
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_BUILT_TYPE=Release ../install/share/corsika/examples
Ralf Ulrich's avatar
Ralf Ulrich committed
369 370
    - cmake --build . -- -j4
    - cmake --build --target run_examples . -- -j4 | gzip -v -9 > examples.log.gz
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/build_examples/examples.log.gz
Ralf Ulrich's avatar
Ralf Ulrich committed
390
      - ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
391

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

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

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
408

409 410


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

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

Ralf Ulrich's avatar
Ralf Ulrich committed
446

447 448


449

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
450

451

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

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

479 480 481 482 483 484 485 486
##########################################################
# template for all Python jobs
.python:
  stage: python
  tags:
    - corsika
  before_script:
    - apt-get update && apt-get install -y python3-pip
Ralf Ulrich's avatar
Ralf Ulrich committed
487
    - pip3 install --upgrade cython
488
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
489
    - cd ${CI_PROJECT_DIR}/python  # change into the Python directory
490 491 492 493 494 495 496 497 498 499 500 501 502 503
    - 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
Ralf Ulrich's avatar
Ralf Ulrich committed
504 505 506
  needs:
    - job: build-u-18_04
      artifacts: false
507 508 509 510 511 512
  artifacts:
    when: always
    expire_in: 1 year
    paths:
      - ${CI_PROJECT_DIR}/Python/python-test.log
  allow_failure: true