Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.89 KiB
Newer Older
##############################################################################
# CI for CEPCSW at IHEP GitLab
##############################################################################

lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
workflow:
  rules:
    # These 3 rules from https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Workflows/MergeRequest-Pipelines.gitlab-ci.yml
    # Run on merge requests
    - if: $CI_MERGE_REQUEST_IID
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    # Run on tags
    - if: $CI_COMMIT_TAG
    # Run when called from an upstream pipeline https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html?tab=Multi-project+pipeline#use-rules-to-control-downstream-pipeline-jobs
    - if: $CI_PIPELINE_SOURCE == 'pipeline'
    - if: $CI_PIPELINE_SOURCE == 'parent-child'
    # Run on commits to the default branch
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    # The last rule above blocks manual and scheduled pipelines on non-default branch. The rule below allows them:
    - if: $CI_PIPELINE_SOURCE == "schedule"
    # Run if triggered from Web using 'Run Pipelines'
    - if: $CI_PIPELINE_SOURCE == "web"
    # Run if triggered from WebIDE
    - if: $CI_PIPELINE_SOURCE == "webide"



stages:
  - build

##############################################################################
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
# Template for Build and Test
##############################################################################
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
# Due to cmake/ctest will hardcode the path in build directory,
# the test job will be failed if it is executed on a different nodes.
# Therefore, put the build script and test script together.

.envvar_template:
  variables:
    CEPCSW_LCG_RELEASE: LCG
    CEPCSW_LCG_PLATFORM: x86_64-centos7-gcc11-opt
    CEPCSW_LCG_VERSION: 103.0.2

.build_template:
  stage: build
  script:
    - bash ./.build.ci.sh
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
    - bash ./.test.ci.sh
# for k8s
.build_template_k8s:
  extends: .envvar_template
  stage: build
  tags:
    - k8s # using k8s as runner
  script:
    - sed -i 's%^CVMFS_HTTP_PROXY=.*%CVMFS_HTTP_PROXY=http://squid-01.ihep.ac.cn:3128%' /etc/cvmfs/default.local
    - for repo in sft.cern.ch geant4.cern.ch cepcsw.ihep.ac.cn; do [ -d "/cvmfs/$repo" ] || mkdir /cvmfs/$repo; sudo mount -t cvmfs $repo /cvmfs/$repo; done
    - bash ./.build.ci.sh
    - bash ./.test.ci.sh

##############################################################################
# Build & Test in CentOS 7 (LCG)
##############################################################################
# build:lcg:el7:
#   extends: .build_template
#   tags:
#     - centos7
#   artifacts:
#     paths:
#       - InstallArea
#       - TDR_o1_v01.tgeo.root
#       - TDR_o1_v02.tgeo.root
#     reports:
#       junit: build.${CEPCSW_LCG_VERSION}.${CEPCSW_LCG_PLATFORM}/cepcsw-ctest-result.xml
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed


##############################################################################
# Build & Test in k8s (LCG)
##############################################################################
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
# build:lcg:el7:k8s:
#   extends: .build_template_k8s
#   image: cepc/cepcsw-cvmfs:el7
#   rules:
#     - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
#       when: manual
build:lcg:el9:k8s:
  extends: .build_template_k8s
  image: cepc/cepcsw-cvmfs:el9
  variables:
    CEPCSW_LCG_PLATFORM: x86_64-el9-gcc11-opt
    CEPCSW_LCG_VERSION: 105.0.0
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
      when: manual
  artifacts:
    reports:
      junit: build.${CEPCSW_LCG_VERSION}.${CEPCSW_LCG_PLATFORM}/cepcsw-ctest-result.xml

lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
##############################################################################
# Build the docs
##############################################################################
build:docs:k8s:
  extends: .build_template_k8s
  image: cepc/cepcsw-cvmfs:el9
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
  script:
    - bash ./.build.ci.sh docs
  artifacts:
    paths:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      changes:
      - docs/**/*