Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 7.39 KiB
stages:
  - build
  - test
  - deploy

image: gitlab-registry.cern.ch/lhcb-core/lbdocker/centos7-build

variables:
  NO_LBLOGIN: "1"
  CLANG_FORMAT_VERSION: "3.9"
  BINARY_TAG: "x86_64-centos7-gcc7-opt"
  LCG_hostos: "x86_64-centos7"
  LCG_release_area: "/cvmfs/sft.cern.ch/lcg/releases"
  BUILDDIR: "build"
  TESTS_REPORT: "test_report"

before_script:
  - export PATH=/cvmfs/sft.cern.ch/lcg/contrib/CMake/3.8.1/Linux-x86_64/bin:/cvmfs/sft.cern.ch/lcg/contrib/ninja/1.7.1/x86_64-slc6:/cvmfs/sft.cern.ch/lcg/releases/Python/2.7.13-597a5/${BINARY_TAG}/bin:${PATH}
  - export PATH=/cvmfs/lhcb.cern.ch/lib/lhcb/LBSCRIPTS/dev/InstallArea/scripts:${PATH}
  - export PYTHONPATH=/cvmfs/lhcb.cern.ch/lib/lhcb/LBSCRIPTS/dev/InstallArea/python:${PYTHONPATH}
  - export CMAKE_PREFIX_PATH=${LCG_release_area}:/cvmfs/projects.cern.ch/intelsw/psxe/linux/x86_64/2017/vtune_amplifier_xe
  - export CCACHE_DIR=${PWD}/.ccache

build:
  tags:
    - cvmfs
  stage: build
  script:
    - curl -o artifacts.zip --location ${CI_PROJECT_URL}/-/jobs/artifacts/master/download?job=${CI_JOB_NAME}
    - unzip -q artifacts.zip '.ccache/*' || true
    - /cvmfs/sft.cern.ch/lcg/releases/ccache/3.3.4-e92e5/${BINARY_TAG}/bin/ccache -z
    - echo 'set(CMAKE_USE_CCACHE ON CACHE BOOL "")' >> cache_preload.cmake
    - echo 'set(clang_format_cmd "'$(which lcg-clang-format-${CLANG_FORMAT_VERSION})'" CACHE FILEPATH "")' >> cache_preload.cmake
    - make BUILDDIR=${BUILDDIR}
    - /cvmfs/sft.cern.ch/lcg/releases/ccache/3.3.4-e92e5/${BINARY_TAG}/bin/ccache -s
  artifacts:
    paths:
      - ${BUILDDIR}
      - .ccache
    expire_in: 1 week

build-gcc62:
  tags:
    - cvmfs
  stage: build
  variables:
    BINARY_TAG: x86_64-centos7-gcc62-opt
    BUILDDIR: build-gcc62
  script:
    - curl -o artifacts.zip --location ${CI_PROJECT_URL}/-/jobs/artifacts/master/download?job=${CI_JOB_NAME}
    - unzip -q artifacts.zip '.ccache/*' || true
    - /cvmfs/sft.cern.ch/lcg/releases/ccache/3.3.4-e92e5/${BINARY_TAG}/bin/ccache -z
    - echo 'set(CMAKE_USE_CCACHE ON CACHE BOOL "")' >> cache_preload.cmake
    - echo 'set(clang_format_cmd "'$(which lcg-clang-format-${CLANG_FORMAT_VERSION})'" CACHE FILEPATH "")' >> cache_preload.cmake
    - make BUILDDIR=${BUILDDIR}
    - /cvmfs/sft.cern.ch/lcg/releases/ccache/3.3.4-e92e5/${BINARY_TAG}/bin/ccache -s
  artifacts:
    paths:
      - ${BUILDDIR}
      - .ccache
    expire_in: 1 week

test_headers:
  tags:
    - cvmfs
  stage: test
  script:
    - curl -o artifacts.zip --location ${CI_PROJECT_URL}/-/jobs/artifacts/master/download?job=${CI_JOB_NAME}
    - unzip -q artifacts.zip '.ccache/*' || true
    - /cvmfs/sft.cern.ch/lcg/releases/ccache/3.3.4-e92e5/${BINARY_TAG}/bin/ccache -z
    - export LCG_release_area=${LCG_release_area}:/cvmfs/lhcb.cern.ch/lib/lcg/external
    - make BUILDDIR=${BUILDDIR} test_public_headers_build
    - /cvmfs/sft.cern.ch/lcg/releases/ccache/3.3.4-e92e5/${BINARY_TAG}/bin/ccache -s
  artifacts:
    paths:
      - .ccache
    expire_in: 1 week

coding-conventions:
  tags:
    - cvmfs
  stage: test
  script:
    - export LCG_release_area=${LCG_release_area}:/cvmfs/lhcb.cern.ch/lib/lcg/external
    - sudo pip install autopep8==1.3.5
    - make BUILDDIR=${BUILDDIR} configure
    - git fetch https://gitlab.cern.ch/gaudi/Gaudi.git master
    - git diff --name-only --no-renames --diff-filter MA FETCH_HEAD..HEAD | grep -E '\.(h|i?cpp|py)$' |
      xargs --no-run-if-empty ${BUILDDIR}/apply-formatting || true
    - "echo \"From: Gitlab CI <noreply@cern.ch>\" > apply-formatting.patch"
    - "echo \"Date: $(date -R)\" >> apply-formatting.patch"
    - "echo \"Subject: [PATCH] Fixed formatting\" >> apply-formatting.patch"
    - echo "" >> apply-formatting.patch
    - echo "patch generated by ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}" >> apply-formatting.patch
    - echo "" >> apply-formatting.patch
    - echo "" >> apply-formatting.patch
    - git diff >> apply-formatting.patch
    - git diff --stat --exit-code || (
      echo -e "\n=======================================\n You can fix formatting with:\n\n"
      "  curl ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/apply-formatting.patch | git am"
      "\n\n=======================================" ; false
      )
  artifacts:
    paths:
      - apply-formatting.patch
    when: on_failure
    expire_in: 1 day

doxygen:
  tags:
    - cvmfs
  stage: test
  script:
    - find build -type f -exec touch -d $(date +@%s) \{} \;
    - make BUILDDIR=${BUILDDIR} doc
    - rm -rf public
    - mkdir -p public/doxygen
    - mv ${BUILDDIR}/doxygen/html ${CI_COMMIT_REF_SLUG}
    - zip -r -q public/doxygen/${CI_COMMIT_REF_SLUG}.zip ${CI_COMMIT_REF_SLUG}
  only:
    - master
    - tags
  artifacts:
    paths:
      - public
    expire_in: 1 day

test:
  tags:
    - cvmfs
  stage: test
  script:
    - find ${BUILDDIR} -type f -exec touch -d $(date +@%s) \{} \;
    - mkdir -p ${BUILDDIR}/html
    - ( make BUILDDIR=${BUILDDIR} test ARGS='-j4' || touch ${BUILDDIR}/html/tests_failed ) | tee ${BUILDDIR}/ctest.log
    - mv ${BUILDDIR}/html ${TESTS_REPORT}
    - mv ${BUILDDIR}/ctest.log ${TESTS_REPORT}
    - mv ${BUILDDIR}/Testing ${TESTS_REPORT}
    - if [ -e ${TESTS_REPORT}/tests_failed ] ; then
    # this prints all lines starting with a white space after and including "The following tests...", excluding lines with "Not Run"
    -   echo "================================================================================"
    -   awk '/^[^[:space:]]/{do_print=0}; /The following tests FAILED:/{do_print=1}; do_print&&!/Not Run/{print}' ${TESTS_REPORT}/ctest.log
    -   echo "================================================================================"
    -   exit 1
    - fi
  artifacts:
    paths:
      - ${TESTS_REPORT}
    when: always
    expire_in: 1 week

test-gcc62:
  tags:
    - cvmfs
  stage: test
  variables:
    BINARY_TAG: x86_64-centos7-gcc62-opt
    BUILDDIR: build-gcc62
    TESTS_REPORT: test_report-gcc62
  script:
    - find ${BUILDDIR} -type f -exec touch -d $(date +@%s) \{} \;
    - mkdir -p ${BUILDDIR}/html
    - ( make BUILDDIR=${BUILDDIR} test ARGS='-j4' || touch ${BUILDDIR}/html/tests_failed ) | tee ${BUILDDIR}/ctest.log
    - mv ${BUILDDIR}/html ${TESTS_REPORT}
    - mv ${BUILDDIR}/ctest.log ${TESTS_REPORT}
    - mv ${BUILDDIR}/Testing ${TESTS_REPORT}
    - if [ -e ${TESTS_REPORT}/tests_failed ] ; then
    # this prints all lines starting with a white space after and including "The following tests...", excluding lines with "Not Run"
    -   echo "================================================================================"
    -   awk '/^[^[:space:]]/{do_print=0}; /The following tests FAILED:/{do_print=1}; do_print&&!/Not Run/{print}' ${TESTS_REPORT}/ctest.log
    -   echo "================================================================================"
    -   exit 1
    - fi
  artifacts:
    paths:
      - ${TESTS_REPORT}
    when: always
    expire_in: 1 week

# see https://gitlab.cern.ch/gitlabci-examples/deploy_eos for the details
# of the configuration
deploy-doxygen:
  stage: deploy
  only:
    - master
    - tags
  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
    - deploy-eos
  # do not run any globally defined before_script or after_script for this step
  before_script: []
  after_script: []