# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileCopyrightText: 2019 CERN

---

include:
  - project: 'be-cem-edl/evergreen/gitlab-ci'
    ref: master
    file:
      - 'edl-gitlab-ci.yml'

cppcheck:
  stage: analyse
  image:
    name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest
  script:
    - make cppcheck

documentation:
  stage: build
  image:
    name: gitlab-registry.cern.ch/coht/common-containers/documentation:latest
  script:
    - make -C Documentation/fmc html KERNELSRC=$(ls -1dr /linux-* | head -n 1)
    - mkdir -p $EDL_CI_EOS_OUTPUT_DIR
    - cp -a Documentation/fmc/_build/html/* $EDL_CI_EOS_OUTPUT_DIR
  artifacts:
    paths:
      - $EDL_CI_EOS_OUTPUT_DIR

build-centos-7:
  stage: build
  variables:
    KERNELSRC: /usr/src/kernels/*/
  image:
    name: gitlab-registry.cern.ch/coht/common-containers/build-centos-7:latest
  script:
    - make modules

build-kernel:
  stage: build
  allow_failure: true
  image:
    name: gitlab-registry.cern.ch/coht/common-containers/build-kernel:latest
  parallel:
    matrix:
      - VERSION: [5.10.149, 5.15.74]
  script:
    - source /linux-versions.sh
    - fetch $VERSION && prepare $VERSION && export LINUX=$(linux $VERSION) && export KERNELSRC=$(linux $VERSION)
    - make modules

build_dkms_rpm:
  stage: release
  script:
    - yum install -y dkms
    - make -C distribution dkms-rpm

build_srpm:
  stage: release
  script:
    - yum-builddep -y ${DIST_PATH}/*.spec
    - KERNELSRC=/usr/src/kernels/*/ make -C distribution srpm
  artifacts:
    paths:
      - distribution/build/SRPMS/${CI_PROJECT_NAME}*src.rpm
    expire_in: 1 day
