image: corsika/devel:u-18.04

variables:
  GIT_SSL_NO_VERIFY: "1"
  ## 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"

build: # normal pipeline for each commit, except for commits to the master
  stage: build
  tags:
    - corsika
  script:
    - mkdir build
    - cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Debug
    - cmake --build . -- -j4
    - ctest -j4 -V >& test.log || gzip -v -9 -S .gz test.log
  artifacts:
    expire_in: 1 year
    paths:
      - build/test.log.gz
    reports:
      junit:
        - build/test_outputs/junit*.xml
  except:
    - master

coverage: # special pipeline for master with coverage report
  stage: build
  tags:
    - corsika
  script:
    - mkdir -p build
    - cd build
    - cmake .. -DCMAKE_BUILD_TYPE=Coverage
    - cmake --build . -- -j4
    - ctest -j4 
    - cmake --build . --target coverage && tar czf coverage-report.tar.gz coverage-report
  artifacts:
    expire_in: 1 year
    paths:
      - build/coverage-report.tar.gz
  only:
    - master

pages:
  stage: build
  tags:
    - corsika
  script:
    - mkdir build
    - cd build
    - cmake ..
    - cmake --build . --target doxygen
    - mkdir .public
    - cp -r Documentation/Doxygen/html .public/
    - mv .public ../public
  artifacts:
    paths:
      - public
  only:
    - tags
    - triggers
    - schedules
