Skip to content
Snippets Groups Projects
.gitlab-ci.yml 7.88 KiB
Newer Older
# to use the env-var "GIT_CLONE_PATH", set the following in
# ./gitlab-runner/config.toml under [[runners]]:
#   [runners.custom_build_dir]
#     enabled = true
# This will prevent git clone conflicts for jobs ran in parallel

variables:
  GIT_DEPTH: 10
  GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME/$CI_CONCURRENT_ID
  MAKE_FLAGS: -j 4
  - deploy
workflow:
  rules:
    - if: $CI_COMMIT_REF_NAME =~ /-wip$/
      when: never
    - when: always

#############
### INFOS ###
#############

show-env-vars:
  stage: info
  variables:
    SEP: "##################################################################"
    S00: "commit date - "
    S01: "project: ${CI_PROJECT_PATH}"
    S02: "branch: ${CI_COMMIT_REF_NAME}"
    S03: "commit: ${CI_COMMIT_SHA}"
    S04: "commit msg: ${CI_COMMIT_MESSAGE}"
    S05: "clone base path: "
    S06: "runner token: ${CI_RUNNER_SHORT_TOKEN}"
  script:
    - echo -e "${SEP}\n${S00}$(date)\n${SEP}\n${S01}\n${S02}\n${S03}\n${S04}\n${SEP}\n${S05}${GIT_CLONE_PATH}\n${S06}\n${SEP}"

###############
### CONFIGS ###
###############
# doc stable variables
.doc_stable_vars: &doc_stable_vars
  GIT_DEPTH: 0
  DOC_TYPE: stable

# doc latest variables
.doc_latest_vars: &doc_latest_vars
  DOC_TYPE: latest
# debug variables
.debug_vars: &debug_vars
  BUILD_DIR: build_debug
  CMAKE_FLAGS: '-DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug'
  BUILD_TARGET: test
  ARTIFACT_PATH: Testing/Temporary

# release variables
.release_vars: &release_vars
  BUILD_DIR: build_release
  CMAKE_FLAGS: '-DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release'
  BUILD_TARGET: test
  ARTIFACT_PATH: Testing/Temporary
# coverage variables
.coverage_vars: &coverage_vars
  BUILD_DIR: build_debug
  CMAKE_FLAGS: '-DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_WITH_COVERAGE=ON'
  BUILD_TARGET: coverage
  ARTIFACT_PATH: coverage
  POST_RUN_CMD: 'lcov_cobertura build_debug/coverage.info'

# module loads for intel fortran compiler
.intel_vars_2020b: &intel_vars_2020b
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.intel2020b
.intel_vars_2023b-classic: &intel_vars_2023b-classic
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.intel2023b-classic
.intel_vars_2023b-llvm: &intel_vars_2023b-llvm
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.intel2023b-llvm

# module loads for gfortran compiler
.gnu_vars_102: &gfortran_vars_102
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.gfortran102
.gnu_vars_122: &gfortran_vars_122
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.gfortran122
# module loads for conda+gfortran
.conda_vars_01: &conda_vars_01
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.chs-conda01
.conda_vars_02: &conda_vars_02
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.chs-conda02
.conda_vars_03: &conda_vars_03
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.chs-conda03
.conda_vars_04: &conda_vars_04
  MODULE_LOAD_SCRIPT: hpc-module-loads/eve.chs-conda04
# #################
# ### TEMPLATES ###
# #################

# template for documentation
.doc_template: &doc_template
  when: always
  stage: doc
  needs: []
  script:
    - source hpc-module-loads/eve.chs-conda04
    # checkout latest tag if there is at least one (and only for stable docs)
    - if [ $(git rev-list --tags --max-count=1) ] && [ $DOC_TYPE == "stable" ]; then git checkout $(git describe --tags $(git rev-list --tags --max-count=1)); fi
    - export PROJECT_NUMBER="$(cat version.txt)"
    # create html documentation
Sebastian Müller's avatar
Sebastian Müller committed
    - sed -i '/GENERATE_LATEX.*=/s/^.*$/GENERATE_LATEX = NO/'         doc/doxygen.config
    - doxygen doc/doxygen.config > doxygen_log_${DOC_TYPE}_html.txt 2>&1
    # create pdf documentation (no files and namespaces there)
    - sed -i '/GENERATE_HTML.*=/s/^.*$/GENERATE_HTML = NO/'           doc/doxygen.config
    - sed -i '/GENERATE_LATEX.*=/s/^.*$/GENERATE_LATEX = YES/'        doc/doxygen.config
    - sed -i '/SHOW_FILES.*=/s/^.*$/SHOW_FILES = NO/'                 doc/doxygen.config
    - sed -i '/SHOW_NAMESPACES.*=/s/^.*$/SHOW_NAMESPACES = NO/'       doc/doxygen.config
Sebastian Müller's avatar
Sebastian Müller committed
    - sed -i '/ALPHABETICAL_INDEX.*=/s/^.*$/ALPHABETICAL_INDEX = NO/' doc/doxygen.config
    - doxygen doc/doxygen.config > doxygen_log_${DOC_TYPE}_latex.txt 2>&1
    # doxygen_latex_stable.txt
    - cd latex/ && tectonic -r 10 -Z continue-on-errors refman.tex > ../doxygen_latex_${DOC_TYPE}.txt 2>&1
    - cp refman.pdf ../html/forces_doc.pdf                          # same name always
    - cp refman.pdf ../forces_doc_${DOC_TYPE}.pdf                   # ../forces_doc_stable.pdf
    - cd .. && mv html html_${DOC_TYPE}                             # html_stable
    - mv doxygen_warn.txt doxygen_warn_${DOC_TYPE}.txt              # doxygen_warn_stable.txt
  artifacts:
    name: "$CI_COMMIT_REF_NAME"
    paths:
      - html_*
      - forces_doc_*.pdf
      - doxygen_*.txt

# template for test jobs
.job_template: &job_template
  stage: test
  script:
    - source $MODULE_LOAD_SCRIPT
    - cmake -B $BUILD_DIR $CMAKE_FLAGS
    - cmake --build $BUILD_DIR --parallel
    - cmake --build $BUILD_DIR --parallel --target $BUILD_TARGET
    - $BUILD_DIR/$ARTIFACT_PATH

# #################
# ### TEST JOBS ###
# #################

test-conda01-release:
  variables:
    <<: [*release_vars, *conda_vars_01]
  <<: *job_template

test-conda02-release:
  variables:
    <<: [*release_vars, *conda_vars_02]
  <<: *job_template

test-conda03-release:
  variables:
    <<: [*release_vars, *conda_vars_03]
  <<: *job_template

test-conda04-release:
  variables:
    <<: [*release_vars, *conda_vars_04]
  <<: *job_template

test-gfortran102-release:
    <<: [*release_vars, *gfortran_vars_102]
  <<: *job_template
test-gfortran102-debug:
    <<: [*debug_vars, *gfortran_vars_102]
  <<: *job_template
test-gfortran122-release:
Robert Schweppe's avatar
Robert Schweppe committed
  variables:
    <<: [*release_vars, *gfortran_vars_122]
  <<: *job_template
test-gfortran122-debug:
Robert Schweppe's avatar
Robert Schweppe committed
  variables:
    <<: [*debug_vars, *gfortran_vars_122]
  <<: *job_template
Robert Schweppe's avatar
Robert Schweppe committed
  variables:
    <<: [*release_vars, *intel_vars_2020b]
  <<: *job_template
test-intel2023b-classic-release:
    <<: [*release_vars, *intel_vars_2023b-classic]
  <<: *job_template
test-intel2023b-llvm-release:
    <<: [*release_vars, *intel_vars_2023b-llvm]
  <<: *job_template
coverage:
  coverage: '/lines[\.]+\: (\d+\.\d+)\%/'
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml
    paths:
    - $BUILD_DIR/$ARTIFACT_PATH
    <<: [*coverage_vars, *conda_vars_02]
    CMAKE_FLAGS: '-DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_WITH_COVERAGE=ON -DFORCES_WITH_OPTIMIZATION=OFF -DFORCES_WITH_NETCDF=OFF'
  <<: *job_template

################
### DOC JOBS ###
################

documentation_stable:
  only:
    - main
  variables:
    <<: *doc_stable_vars
  <<: *doc_template

documentation:
  variables:
    <<: *doc_latest_vars
  <<: *doc_template

# ###################
# ### DEPLOY JOBS ###
# ###################
  when: always
  stage: deploy
    - job: documentation_stable
      artifacts: true
    - job: documentation
      artifacts: true
    - job: coverage
      artifacts: true
  script:
    # create public dir (remove if already present)
    - test -d public && rm -rf public
    - mkdir -p public
    # create the subdir
    - mkdir public/stable/
    - mkdir public/latest/
    # copy the doxygen generated html page to the public site
    - cp html_stable/* public/stable/ -R
    - cp html_latest/* public/latest/ -R
    # create an index.html that redirects to the stable documentation (in stable folder)
    - cp doc/html_files/index.html public/
    # create the coverage site
    - mkdir -p public/coverage
    - cp  build_debug/coverage/* public/coverage/ -R
  artifacts:
    name: "$CI_COMMIT_REF_NAME"
    paths:
      - public