Skip to content
Snippets Groups Projects
.gitlab-ci.yml 11.6 KiB
Newer Older
#####################################################################################
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
#                                                                                   #
# This software is distributed under the terms of the Apache version 2 licence,     #
# copied verbatim in the file "LICENSE".                                            #
#                                                                                   #
# In applying this licence, CERN does not waive the privileges and immunities       #
# granted to it by virtue of its status as an Intergovernmental Organization        #
# or submit itself to any jurisdiction.                                             #
#####################################################################################
variables:
  CMAKE_GENERATOR: 'Ninja' # default build system
  TARGET_BRANCH: master

# Job templates
.build: &template_build
  image: gitlab-registry.cern.ch/lhcb-docker/os-base/centos7-devel:latest
  before_script:
    # Add Ninja and CMake to the PATH
    - export PATH="/cvmfs/sft.cern.ch/lcg/contrib/CMake/3.20.0/Linux-$(uname -m)/bin:/cvmfs/sft.cern.ch/lcg/contrib/ninja/1.11.1/Linux-$(uname -m)/bin:$PATH"
    - export CCACHE_DIR=$PWD/.ccache
    - "export LCG_VERSION=$(cut -d: -f2 <<< $CI_JOB_NAME)"
    - "export platform=$(cut -d: -f3 <<< $CI_JOB_NAME)"
    - "export PRESET=$(cut -d: -f4 <<< $CI_JOB_NAME)"
    - if [ -z "$PRESET" ] ; then PRESET=full ; fi
    - git clone https://gitlab.cern.ch/lhcb-core/lcg-toolchains.git
    - cmake --version
    - cmake -S . -B build -Wno-dev -DCMAKE_TOOLCHAIN_FILE=lcg-toolchains/LCG_${LCG_VERSION}/${platform}.cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DGAUDI_TEST_PUBLIC_HEADERS_BUILD=yes -C ci-utils/preset-${PRESET}.cmake
    - ccache -z
    # pre-heat ccache cache for GaudiKernel
    - jobs=$(nproc)
    - while [[ $jobs -ge 1 ]] ; do
    -   cmake --build build -j $jobs --target GaudiKernel && break || true
    -   jobs=$(( $jobs / 2 ))
    - done
    # build from scratch
    - cmake --build build --target clean
    - cmake --build build 2>&1 | tee build.log
    - ccache -s
    - cp build/compile_commands.json .
    # run the tests
    - if ctest -T test -j $(nproc) --repeat until-pass:3 --no-compress-output ; then result=success ; else result=failure ; fi
    - cp Testing/$(head -1 Testing/TAG)/Test.xml ..
    - cd ..
    - xsltproc ci-utils/CTest2JUnit.xslt Test.xml > results.xml
    - echo "Test results can be browsed at https://lhcb-nightlies.web.cern.ch/utils/test_report?url=${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/Test.xml"
    # FIXME: Many tests require AIDA, so we ignore them in that case
    - test "$PRESET" = "no-AIDA" -o "$result" = "success"
      - build.log
      - compile_commands.json
      - Test.xml
    reports:
      junit:
        - results.xml
  cache:
    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
    paths:
      - .ccache
      - build/Testing
.warnings-check: &template_warnings_check
  image: gitlab-registry.cern.ch/linuxsupport/alma9-base:latest
  variables:
    LOG: build.log
  script:
    - ci-utils/build-check ${LOG}
  allow_failure: true
lcg:103:x86_64-centos7-gcc12-opt:
  <<: *template_build
lcg:103:x86_64-centos7-gcc12-dbg:
  <<: *template_build

lcg:103:x86_64-centos9-gcc12-opt:
  image: gitlab-registry.cern.ch/lhcb-docker/os-base/alma9-devel:latest
lcg:103:x86_64-centos9-gcc12-dbg:
  <<: *template_build
  image: gitlab-registry.cern.ch/lhcb-docker/os-base/alma9-devel:latest
Rosen Matev's avatar
Rosen Matev committed

lcg:103:x86_64-centos7-gcc11-opt:minimal:
  <<: *template_build
lcg:103:x86_64-centos7-gcc11-opt:no-AIDA:
  <<: *template_build
lcg:103:x86_64-centos7-gcc12-opt:no-GaudiAlg:
  <<: *template_build

lhcb:103:x86_64_v2-el9-gcc12-opt:
  <<: *template_build
  image: gitlab-registry.cern.ch/lhcb-docker/os-base/alma9-devel:latest
    - shopt -s expand_aliases
    - . /cvmfs/lhcb.cern.ch/lib/LbEnv
    - cmake --version
    - lb-set-platform $platform
    - lb-project-init --overwrite
    - ccache -z
    - mkdir build.${BINARY_TAG}
    - if [ -e build/Testing ] ; then mv build/Testing build.${BINARY_TAG} ; fi
    # pre-heat ccache cache for GaudiKernel
    - jobs=$(nproc)
    - while [[ $jobs -ge 1 ]] ; do
    -   make BUILDFLAGS=-j$jobs GaudiKernel && break || true
    -   jobs=$(( $jobs / 2 ))
    - done
    # build from scratch
    - make clean
    - make 2>&1 | tee build.log
    # run the tests
    - if make test ARGS="-j $(nproc) --repeat until-pass:3 --no-compress-output" ; then result=success ; else result=failure ; fi
    - cp build.${BINARY_TAG}/Testing/$(head -1 build.${BINARY_TAG}/Testing/TAG)/Test.xml .
    - mkdir -p build && mv build.${BINARY_TAG}/Testing build
    - cp build.${BINARY_TAG}/compile_commands.json .
    - mv build.${BINARY_TAG}/html .
    - xsltproc ci-utils/CTest2JUnit.xslt Test.xml > results.xml
    - echo "Test results can be browsed at https://lhcb-nightlies.web.cern.ch/utils/test_report?url=${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/Test.xml"
    - test "$result" = "success"
      - build.log
      - compile_commands.json
      - Test.xml
      - html
    reports:
      junit:
        - results.xml
    when: always
    expire_in: 1 week

lcg-view:102b:x86_64-centos7-gcc11-opt:
  <<: *template_build
  script:
    - . /cvmfs/sft.cern.ch/lcg/views/LCG_${LCG_VERSION}/${platform}/setup.sh
    - export CONFIGURABLE_DB_IGNORE=/cvmfs/sft.cern.ch/lcg/views/LCG_${LCG_VERSION}/${platform}/lib/Gaudi.confdb
    - cmake --version
    - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
    - ccache -z
    # pre-heat ccache cache for GaudiKernel
    - jobs=$(nproc)
    - while [[ $jobs -ge 1 ]] ; do
    -   cmake --build build -j $jobs --target GaudiKernel && break || true
    -   jobs=$(( $jobs / 2 ))
    - done
    # build from scratch
    - cmake --build build --target clean
    - cmake --build build 2>&1 | tee build.log
    - ccache -s
    - cp build/compile_commands.json .
    # run the tests
    - cd build
    - if ctest -T test -j $(nproc) --repeat until-pass:3 --no-compress-output ; then result=success ; else result=failure ; fi
    - cp Testing/$(head -1 Testing/TAG)/Test.xml ..
    - cd ..
    - xsltproc ci-utils/CTest2JUnit.xslt Test.xml > results.xml
    - echo "Test results can be browsed at https://lhcb-nightlies.web.cern.ch/utils/test_report?url=${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/Test.xml"
    - test "$result" = "success"

### Check build outputs
warnings-check:lcg:103:x86_64-centos7-gcc12-opt:
  <<: *template_warnings_check
    - job: "lcg:103:x86_64-centos7-gcc12-opt"
      artifacts: true
warnings-check:lcg:103:x86_64-centos7-gcc12-dbg:
  <<: *template_warnings_check
    - job: "lcg:103:x86_64-centos7-gcc12-dbg"
      artifacts: true
warnings-check:lcg:103:x86_64-centos9-gcc12-opt:
  <<: *template_warnings_check
    - job: "lcg:103:x86_64-centos9-gcc12-opt"
warnings-check:lcg:103:x86_64-centos9-gcc12-dbg:
  <<: *template_warnings_check
    - job: "lcg:103:x86_64-centos9-gcc12-dbg"
warnings-check:lcg:103:x86_64-centos7-gcc11-opt:minimal:
  <<: *template_warnings_check
    - job: "lcg:103:x86_64-centos7-gcc11-opt:minimal"
      artifacts: true

warnings-check:lcg:103:x86_64-centos7-gcc12-opt:no-GaudiAlg:
  <<: *template_warnings_check
  needs:
    - job: "lcg:103:x86_64-centos7-gcc12-opt:no-GaudiAlg"
      artifacts: true

warnings-check:lhcb:103:x86_64_v2-el9-gcc12-opt:
  <<: *template_warnings_check
    - job: "lhcb:103:x86_64_v2-el9-gcc12-opt"
      artifacts: true

warnings-check:lcg-view:102b:x86_64-centos7-gcc11-opt:
  <<: *template_warnings_check
  needs:
    - job: "lcg-view:102b:x86_64-centos7-gcc11-opt"
      artifacts: true

### Misc checks
lcg:103:x86_64-centos7-gcc12-opt:check-unused:
  image: gitlab-registry.cern.ch/lhcb-docker/os-base/alma9-devel:latest
    - job: "lcg:103:x86_64-centos7-gcc12-opt"
      artifacts: true
  script:
    - ci-utils/check-sources compile_commands.json
  allow_failure: true

  image: registry.cern.ch/docker.io/library/python:3.9
  variables:
    PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
  cache:
    paths:
      - ${PRE_COMMIT_HOME}
  before_script:
    - |
      python -m venv ${CI_PROJECT_DIR}/.cache/pre-commit-venv
      . ${CI_PROJECT_DIR}/.cache/pre-commit-venv/bin/activate
      pip install pre-commit
      git fetch origin $TARGET_BRANCH
      git config user.name "Gitlab CI"
      git config user.email "noreply@cern.ch"
    - |
      if ! pre-commit run --show-diff-on-failure --from-ref FETCH_HEAD --to-ref HEAD ; then
        echo ""
        echo "Generating patch file..."
        git commit -a -m "pre-commit fixes
      patch generated by ${CI_JOB_URL}" > /dev/null
        git format-patch HEAD~
        cat <<EOF
      =======================================
       You can apply these changes with:

          curl ${CI_JOB_URL}/artifacts/raw/0001-pre-commit-fixes.patch | git am

      =======================================
      EOF
        exit 1
      fi
  artifacts:
    paths:
      - 0001-pre-commit-fixes.patch
    when: on_failure

check-copyright:
  image: registry.cern.ch/docker.io/library/python:3.9
    - |
      curl -o lb-check-copyright "https://gitlab.cern.ch/lhcb-core/LbDevTools/-/raw/master/LbDevTools/SourceTools.py?inline=false"
      python lb-check-copyright \
        --exclude lhcbproject.yml \
        --exclude ci-utils/preset-default.cmake \
        --exclude ci-utils/preset-full.cmake \
        --exclude ci-utils/preset-minimal.cmake \
        --exclude ci-utils/preset-no-AIDA.cmake \
        --exclude ci-utils/preset-no-GaudiAlg.cmake \
        --exclude ci-utils/preset-no-test.cmake \
        origin/${TARGET_BRANCH}

  image: registry.cern.ch/docker.io/library/python:3.9
  script:
    - rm -rf public
    - mkdir -p public
    - cd docs
    - pip install -r source/requirements.txt
    - make html
    - cp -a build/html/. ../public/.
  artifacts:
    paths:
      - public
    expire_in: 1 day

doxygen:103:x86_64-centos7-gcc12-opt:
  <<: *template_build
    - . /cvmfs/sft.cern.ch/lcg/views/LCG_${LCG_VERSION}/${platform}/setup.sh
    - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
    - cmake --build build --target doc
    - rm -rf public
    - mkdir -p public/doxygen
    - cp -r GaudiRelease/web_helpers/. public/doxygen/.
    - mv build/doxygen/html ${CI_COMMIT_REF_SLUG}
    - zip -r -q public/doxygen/${CI_COMMIT_REF_SLUG}.zip ${CI_COMMIT_REF_SLUG}
  artifacts:
    paths:
      - public
    expire_in: 1 day

# see https://gitlab.cern.ch/gitlabci-examples/deploy_eos for the details
# of the configuration
deploy-website:
  needs:
    - job: "website"
      artifacts: true
    - job: "doxygen:103:x86_64-centos7-gcc12-opt"
      artifacts: true
  rules:
    - if: $CI_COMMIT_BRANCH == "master"
    - if: $CI_COMMIT_TAG
  image: gitlab-registry.cern.ch/ci-tools/ci-web-deployer:latest
  script:
    - test -z "$EOS_ACCOUNT_USERNAME" -o -z "$EOS_ACCOUNT_PASSWORD" -o -z "$EOS_PATH" && exit 0 || true
    # Script that performs the deploy to EOS. Makes use of the variables defined in the project
    # It will copy the generated content to the folder in EOS
    - export CI_OUTPUT_DIR=public/
    - deploy-eos
  # do not run any globally defined before_script or after_script for this step
  before_script: []
  after_script: []