Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 11.58 KiB
#####################################################################################
# (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
  tags:
    - cvmfs
  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
  script:
    - 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
    - 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"
    # FIXME: Many tests require AIDA, so we ignore them in that case
    - test "$PRESET" = "no-AIDA" -o "$result" = "success"
  artifacts:
    paths:
      - build.log
      - compile_commands.json
      - Test.xml
    reports:
      junit:
        - results.xml
    when: always
    expire_in: 1 week
  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