IAP GITLAB

.gitlab-ci.yml 13 KB
Newer Older
Ralf Ulrich's avatar
Ralf Ulrich committed
1
variables:
2
  GIT_STRATEGY: fetch
Ralf Ulrich's avatar
Ralf Ulrich committed
3
  GIT_SSL_NO_VERIFY: "1"
4 5 6
  GIT_DEPTH: 1
  # 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 14 15 16 17 18 19 20 21 22 23 24
  # location of AirShowerPhysics/corsika-data
  # CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
  # _alternatively_ corsika-data can be downloaded as submodule:
  GIT_SUBMODULE_STRATEGY: normal


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


37 38


39
####### CODE QUALITY CHECK ##############
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
40

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

55
##########################################################
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
56 57 58 59 60 61 62 63 64
check-clang-format:
  image: corsika/devel:u-18.04
  before_script:
  - apt-get update && apt-get install -y -qq clang-format
  stage: quality
  tags:
    - corsika
  script:
    - ./do-clang-format.py --all
65 66 67 68 69
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  allow_failure: true
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
70

71 72


73

74 75 76 77 78 79 80
####### CONFIG ##############

##########################################################
# the generic config template job
# job/stage to just prepare cmake
.config:
  stage: config
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
81 82
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
83
  variables:
84 85
  before_script:
   - cd Data && for F in `find . -name "*.bz2" | grep -v ".git"`; do [ ! -f ${F%%.bz2} ] && bunzip2 -vk $F; done
Ralf Ulrich's avatar
Ralf Ulrich committed
86 87
  script:    
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
88
    - cd build
89 90 91 92 93 94
    - cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_PYTHIA=ON
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  cache: 
Ralf M Ulrich's avatar
Ralf M Ulrich committed
95
    paths:
96
      - build/
97 98
      - Data/
    untracked: true
99
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
100

101 102 103 104 105 106 107 108 109 110
# 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
111
  image: corsika/devel:clang-8
112 113 114 115 116
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



117 118

####### BUILD (only manual) ##############
119 120 121 122 123

##########################################################
# the generic build template job
# normal pipeline for each commit
.build:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
124 125 126 127 128 129
  stage: build
  tags:
    - corsika
  script:
    - cd build
    - cmake --build . -- -j4
130 131
  rules:
    - if: $CI_MERGE_REQUEST_ID
132
      when: manual
133
    - if: $CI_COMMIT_TAG
134
      when: manual
135
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
136 137
      when: manual
  allow_failure: true
138
  cache: 
Ralf M Ulrich's avatar
Ralf M Ulrich committed
139
    paths:
140
      - build/
141 142
      - Data/
    untracked: true
143
    policy: pull-push
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 149
  image: corsika/devel:u-18.04
  dependencies:
150 151 152
    - config-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
153

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


164 165 166


####### TEST (only manual)  ##############
167 168 169 170 171

##########################################################
# generic test template job
# normal pipeline for each commit
.test:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
172
  stage: test
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
173 174 175 176
  tags:
    - corsika
  script:
    - cd build
177
    - set -o pipefail
178
    - ctest -j4 -VV | gzip -v -9 > test.log.gz 
179 180
  rules:
    - if: $CI_MERGE_REQUEST_ID
181
      when: manual
182
    - if: $CI_COMMIT_TAG
183
      when: manual
184
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
185 186
      when: manual
  allow_failure: true
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
187
  artifacts:
188
    when: always
189
    expire_in: 3 days
190 191 192
    reports:
      junit:
        - build/test_outputs/junit*.xml
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
193 194
    paths:
      - build/test.log.gz
195 196 197
  cache: 
    paths:
      - build/
198 199 200
      - Data/
    untracked: true
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
201

202 203 204
# test for gcc
test-u-18_04:
  extends: .test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
205 206 207
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
208 209 210 211 212 213 214 215 216 217 218 219 220 221
  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"



222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278

####### BUILD-TEST (all builds <= WIP, default) ##############

##########################################################
# the generic build_test template job
# normal pipeline for each commit
.build_test:
  stage: build_test
  tags:
    - corsika
  script:
    - cd build
    - cmake --build . -- -j4
    - set -o pipefail
    - ctest -j4 -VV | gzip -v -9 > test.log.gz 
  rules:
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^WIP:/'
    - if: $CI_MERGE_REQUEST_ID
      when: manual
      allow_failure: true
  allow_failure: true
  artifacts:
    when: always
    expire_in: 3 days
    reports:
      junit:
        - build/test_outputs/junit*.xml
    paths:
      - build/test.log.gz
  cache: 
    paths:
      - build/
      - Data/
    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
build_test-clang-8: 
  extends: .build_test
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



####### EXAMPLE (only manual)  ##############
279 280 281 282 283

##########################################################
# generic example template job
# normal pipeline for each commit
.example:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
284 285 286 287 288 289
  stage: example
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
290
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
291
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
292
    - if: $CI_MERGE_REQUEST_ID
293
      when: manual
294
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
295
      when: manual
296 297 298
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual
  allow_failure: true
Ralf M Ulrich's avatar
Ralf M Ulrich committed
299 300
  artifacts:
    when: always
301
    expire_in: 3 days
Ralf M Ulrich's avatar
Ralf M Ulrich committed
302
    paths:
Ralf M Ulrich's avatar
typo  
Ralf M Ulrich committed
303
      - build/examples.log.gz
304 305 306
  cache: 
    paths:
      - build/
307 308
      - Data/
    untracked: true
309
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
310

311 312 313 314 315 316 317 318 319 320 321 322
# example for gcc
example-u-18_04: 
  extends: .example
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"

# example for clang
example-clang-8:
  extends: .example
Ralf M Ulrich's avatar
Ralf M Ulrich committed
323 324 325
  image: corsika/devel:clang-8
  dependencies:
    - build-clang-8
326 327 328 329
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391

####### BUILD-TEST-EXAMPLE (only non-WIP)  ##############

##########################################################
# generic example template job
# normal pipeline for each commit
.build_test_example:
  stage: build_test_example
  tags:
    - corsika
  script:
    - cd build
    - cmake --build . -- -j4
    - set -o pipefail
    - ctest -j4 -VV | gzip -v -9 > test.log.gz 
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
  rules:
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^WIP:/'
      when: manual
      allow_failure: true
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
      when: manual
      allow_failure: true
  artifacts:
    when: always
    expire_in: 3 days
    reports:
      junit:
        - build/test_outputs/junit*.xml
    paths:
      - build/examples.log.gz
      - build/test.log.gz
  cache: 
    paths:
      - build/
      - Data/
    untracked: true
    policy: pull

# build_test_example for gcc
build_test_example-u-18_04: 
  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"




392 393 394 395 396 397 398
####### INSTALL  ##############

##########################################################
# generic install template job
# make install
.install:
  stage: install
Ralf M Ulrich's avatar
Ralf M Ulrich committed
399 400 401 402 403
  tags:
    - corsika
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
404
    - make -j2 install
405
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
406
    - if: $CI_MERGE_REQUEST_ID
407
      when: manual
408
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
409
      when: manual
410 411 412
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual
  allow_failure: true
413
  cache: 
Ralf M Ulrich's avatar
Ralf M Ulrich committed
414
    paths:
415
      - build/
416 417
      - Data/
    untracked: true
418
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
419

420 421 422
# install for gcc
install-u-18_04: 
  extends: .install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
423 424
  image: corsika/devel:u-18.04
  dependencies:
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
    - 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"



440

441 442 443 444 445 446
####### OPTIONAL ##############

##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
447
  stage: optional
448 449 450
  tags:
    - corsika
  script:
451
    - cd build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
452
    - cmake .. -DCMAKE_BUILD_TYPE=Release
453
    - cmake --build . -- -j4
454
    - set -o pipefail
455
    - ctest -j4 -VV | gzip -v -9 > test.log.gz 
Ralf Ulrich's avatar
Ralf Ulrich committed
456
    - make -j4 run_examples
457 458 459 460 461 462 463 464 465 466 467 468 469 470
  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
  cache: 
    paths:
      - build/
471 472
      - Data/
    untracked: true
473
    policy: pull
474
  artifacts:
475
    when: always
476
    expire_in: 3 days
477 478 479 480 481
    reports:
      junit:
        - build/test_outputs/junit*.xml
    paths:
      - build/test.log.gz
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
482

483 484 485 486 487 488 489 490 491 492
# 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
Ralf M Ulrich's avatar
Ralf M Ulrich committed
493
release-full-clang-8: 
494
  extends: .release
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
495 496 497
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
498 499 500
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
501

502 503


504 505
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
506

507
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
508 509 510 511 512 513 514 515 516 517 518 519 520
  image: corsika/devel:u-18.04
  dependencies:
    - config-u-18_04
  stage: optional
  tags:
    - corsika
  script:
    - cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage
    - cmake --build . -- -j4
    - ctest -j4 -V > test.log 
    - cmake --build . --target coverage
    - tar czf coverage-report.tar.gz coverage-report
Ralf Ulrich's avatar
Ralf Ulrich committed
521
  coverage: '/^.*functions\.+:\s(.*\%)\s/'
522 523 524 525 526 527 528 529 530
  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
531
  artifacts:
532
    when: always
533
    expire_in: 1 year
534
    paths:
535
      - build/coverage-report.tar.gz
536 537 538
  cache: 
    paths:
      - build/
539 540
      - Data/
    untracked: true
541 542
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
Ralf Ulrich committed
543

Ralf Ulrich's avatar
Ralf Ulrich committed
544

545 546


547
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
548 549 550
documentation:
  image: corsika/devel:u-18.04
  dependencies:
551
    - config-u-18_04
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
552
  stage: optional
Ralf Ulrich's avatar
Ralf Ulrich committed
553
  tags:
Lukas Nellen's avatar
Lukas Nellen committed
554
    - corsika
555
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
556
    - cd build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
557
    - cmake --build . --target doxygen -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
558
    - mkdir -p .public
559
    - cp -r Documentation/Doxygen/html .public/
Ralf Ulrich's avatar
Ralf Ulrich committed
560
    - mv .public ../public
561 562 563 564 565 566 567 568 569 570 571
  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
572
  artifacts:
573
    expire_in: 3 weeks
574 575
    paths:
      - public
576 577 578
  cache: 
    paths:
      - build/
579 580
      - Data/
    untracked: true
581 582 583
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
584

585

586
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
587 588 589 590 591 592 593 594 595 596 597
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
598 599 600 601 602 603 604 605 606 607 608 609 610 611
  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
  cache: 
    paths:
      - build/
612 613
      - Data/
    untracked: true
614 615
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"