IAP GITLAB

.gitlab-ci.yml 10.3 KB
Newer Older
Ralf Ulrich's avatar
Ralf Ulrich committed
1 2
variables:
  GIT_SSL_NO_VERIFY: "1"
3
  GIT_DEPTH: 10
4 5 6 7 8 9
  ## 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"
Ralf Ulrich's avatar
Ralf Ulrich committed
10

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
11 12
# normal multi-step pipeline for each commit
stages:
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
13
  - quality
14
  - config
Ralf M Ulrich's avatar
Ralf M Ulrich committed
15 16
  - build
  - test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
17
  - example
18
  - install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
19 20 21
  - optional


22
####### CODE QUALITY CHECK ##############
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
23

24
##########################################################
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
25 26 27 28 29 30 31
check-copyrights:
  image: corsika/devel:u-18.04
  stage: quality
  tags:
    - corsika
  script:
    - ./do-copyright.py
32 33 34 35 36
  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
37

38
##########################################################
Ralf M Ulrich's avatar
quality  
Ralf M Ulrich committed
39 40 41 42 43 44 45 46 47
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
48 49 50 51 52
  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
53

54 55 56 57 58 59 60 61 62


####### CONFIG ##############

##########################################################
# the generic config template job
# job/stage to just prepare cmake
.config:
  stage: config
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
63 64
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
65 66
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
Ralf Ulrich's avatar
Ralf Ulrich committed
67 68
  script:    
    - mkdir -p build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
69
    - cd build
70 71 72 73 74 75
    - 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
76
    paths:
77 78
      - build/
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
79

80 81 82 83 84 85 86 87 88 89
# 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
90
  image: corsika/devel:clang-8
91 92 93 94 95 96 97 98 99 100 101
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"



####### BUILD  ##############

##########################################################
# the generic build template job
# normal pipeline for each commit
.build:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
102 103 104 105 106 107 108 109
  stage: build
  tags:
    - corsika
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
  script:
    - cd build
    - cmake --build . -- -j4
110 111 112 113 114
  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
115
    paths:
116 117
      - build/
    policy: pull-push
Ralf M Ulrich's avatar
Ralf M Ulrich committed
118

119 120 121
# build for gcc
build-u-18_04:
  extends: .build
Ralf M Ulrich's avatar
Ralf M Ulrich committed
122 123
  image: corsika/devel:u-18.04
  dependencies:
124 125 126
    - config-u-18_04
  cache:
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
127

128 129 130
# build for clang
build-clang-8: 
  extends: .build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
131 132
  image: corsika/devel:clang-8
  dependencies:
133 134 135 136 137 138 139 140 141 142 143
    - config-clang-8
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


####### TEST  ##############

##########################################################
# generic test template job
# normal pipeline for each commit
.test:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
144
  stage: test
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
145 146
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
147 148
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
149
  script:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
150
    - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
151
    - cd build
152
    - set -o pipefail
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
153
    - ctest -VV | gzip -v -9 > test.log.gz 
154 155 156 157
  rules:
    - if: $CI_MERGE_REQUEST_ID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
158
  artifacts:
159
    when: always
160
    expire_in: 3 days
161 162 163
    reports:
      junit:
        - build/test_outputs/junit*.xml
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
164 165
    paths:
      - build/test.log.gz
166 167 168 169
  cache: 
    paths:
      - build/
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
170

171 172 173
# test for gcc
test-u-18_04:
  extends: .test
Ralf M Ulrich's avatar
Ralf M Ulrich committed
174 175 176
  image: corsika/devel:u-18.04
  dependencies:
    - build-u-18_04
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  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"



####### EXAMPLE  ##############

##########################################################
# generic example template job
# normal pipeline for each commit
.example:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
197 198 199 200 201 202 203 204 205
  stage: example
  tags:
    - corsika
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
  script:
    - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
206
    - make -j4 run_examples | gzip -v -9 > examples.log.gz
207
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
208
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Ralf Ulrich's avatar
Ralf Ulrich committed
209
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^WIP:/'
Ralf Ulrich's avatar
Ralf Ulrich committed
210 211
      when: manual
      allow_failure: true
Ralf Ulrich's avatar
Ralf Ulrich committed
212
    - if: $CI_MERGE_REQUEST_ID
213
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
214 215
      when: manual
      allow_failure: true
Ralf M Ulrich's avatar
Ralf M Ulrich committed
216 217
  artifacts:
    when: always
218
    expire_in: 3 days
Ralf M Ulrich's avatar
Ralf M Ulrich committed
219
    paths:
Ralf M Ulrich's avatar
typo  
Ralf M Ulrich committed
220
      - build/examples.log.gz
221 222 223 224
  cache: 
    paths:
      - build/
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
225

226 227 228 229 230 231 232 233 234 235 236 237
# 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
238 239 240
  image: corsika/devel:clang-8
  dependencies:
    - build-clang-8
241 242 243 244 245 246 247 248 249 250 251
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"


####### INSTALL  ##############

##########################################################
# generic install template job
# make install
.install:
  stage: install
Ralf M Ulrich's avatar
Ralf M Ulrich committed
252 253 254 255 256 257 258
  tags:
    - corsika
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
  script:
    - cd build
    - set -o pipefail
Ralf Ulrich's avatar
Ralf Ulrich committed
259
    - make -j2 install
260
  rules:
Ralf Ulrich's avatar
Ralf Ulrich committed
261
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Ralf Ulrich's avatar
Ralf Ulrich committed
262
    - if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^WIP:/'
Ralf Ulrich's avatar
Ralf Ulrich committed
263 264
      when: manual
      allow_failure: true
Ralf Ulrich's avatar
Ralf Ulrich committed
265
    - if: $CI_MERGE_REQUEST_ID
266
    - if: $CI_COMMIT_TAG
Ralf Ulrich's avatar
Ralf Ulrich committed
267 268
      when: manual
      allow_failure: true
269
  cache: 
Ralf M Ulrich's avatar
Ralf M Ulrich committed
270
    paths:
271 272
      - build/
    policy: pull
Ralf M Ulrich's avatar
Ralf M Ulrich committed
273

274 275 276
# install for gcc
install-u-18_04: 
  extends: .install
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
277 278
  image: corsika/devel:u-18.04
  dependencies:
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
    - 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"



####### OPTIONAL ##############

##########################################################
# generic release template job
# optional release pipeline for each commit
.release:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
300
  stage: optional
301 302
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
303 304
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
305
  script:
Ralf M Ulrich's avatar
Ralf M Ulrich committed
306
    - git clone https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika-data.git
307
    - cd build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
308
    - cmake .. -DCMAKE_BUILD_TYPE=Release
309
    - cmake --build . -- -j4
310 311
    - set -o pipefail
    - ctest -VV | gzip -v -9 > test.log.gz 
Ralf Ulrich's avatar
Ralf Ulrich committed
312
    - make -j4 run_examples
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
  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/
    policy: pull
328
  artifacts:
329
    when: always
330
    expire_in: 3 days
331 332 333 334 335
    reports:
      junit:
        - build/test_outputs/junit*.xml
    paths:
      - build/test.log.gz
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
336

337 338 339 340 341 342 343 344 345 346
# 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
347
release-full-clang-8: 
348
  extends: .release
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
349 350 351
  image: corsika/devel:clang-8
  dependencies:
    - config-clang-8
352 353 354
  cache:
    key: "${CI_COMMIT_REF_SLUG}-clang"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
355

356 357 358
##########################################################
# the coverage generation should either run when manually requested, OR always on the master
coverage:
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
359 360 361 362 363 364
  image: corsika/devel:u-18.04
  dependencies:
    - config-u-18_04
  stage: optional
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
365 366
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
367 368 369 370 371 372 373
  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
374
  coverage: '/^.*functions\.+:\s(.*\%)\s/'
375 376 377 378 379 380 381 382 383
  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
384
  artifacts:
385
    expire_in: 1 year
386
    paths:
387
      - build/coverage-report.tar.gz
388 389 390 391 392
  cache: 
    paths:
      - build/
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"
Ralf Ulrich's avatar
Ralf Ulrich committed
393

Ralf Ulrich's avatar
Ralf Ulrich committed
394

395
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
396 397 398
documentation:
  image: corsika/devel:u-18.04
  dependencies:
399
    - config-u-18_04
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
400
  stage: optional
Ralf Ulrich's avatar
Ralf Ulrich committed
401
  tags:
Lukas Nellen's avatar
Lukas Nellen committed
402
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
403 404
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
405
  script:
Ralf Ulrich's avatar
Ralf Ulrich committed
406
    - cd build
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
407
    - cmake --build . --target doxygen -- -j4
Ralf Ulrich's avatar
Ralf Ulrich committed
408
    - mkdir -p .public
409
    - cp -r Documentation/Doxygen/html .public/
Ralf Ulrich's avatar
Ralf Ulrich committed
410
    - mv .public ../public
411 412 413 414 415 416 417 418 419 420 421
  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
422
  artifacts:
423
    expire_in: 3 weeks
424 425
    paths:
      - public
426 427 428 429 430 431
  cache: 
    paths:
      - build/
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"

Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
432

433
##########################################################
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
434 435 436 437 438 439 440
sanity:
  image: corsika/devel:u-18.04
  dependencies:
    - config-u-18_04
  stage: optional
  tags:
    - corsika
Ralf Ulrich's avatar
Ralf Ulrich committed
441 442
  variables:
    CORSIKA_DATA: "${CI_PROJECT_DIR}/corsika-data/"
Ralf Ulrich's avatar
CI  
Ralf Ulrich committed
443 444 445 446
  script:
    - cd build
    - cmake .. -DWITH_CORSIKA_SANITIZERS_ENABLED=ON
    - cmake --build . -- -j4
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
  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/
    policy: pull
    key: "${CI_COMMIT_REF_SLUG}-gcc"