From ea1dd5cab637ec5938c72635369b8791d132db59 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 25 Apr 2023 16:26:03 +0200 Subject: [PATCH] Update CI Signed-off-by: Evan Lezar --- .gitlab-ci.yml | 131 +++++++++++++++++++------------------------------ 1 file changed, 51 insertions(+), 80 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e377a849..34ffc491 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,11 +18,6 @@ default: - name: docker:dind command: ["--experimental"] -# Build packages for all supported OS / ARCH combinations -stages: - - build-one - - build-all - variables: # We specify the LIB_VERSION, TOOLKIT_VERSION, and TOOLKIT_TAG variable to allow packages # to be built. @@ -31,45 +26,51 @@ variables: TOOLKIT_VERSION: 999.999.999 TOOLKIT_TAG: dummy+toolkit -.build-setup: &build-setup - before_script: - - apk update - - apk upgrade - - apk add coreutils build-base sed git bash make - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes +# Build packages for all supported OS / ARCH combinations +stages: + - trigger + - build -# build-one jobs build packages for a single OS / ARCH combination. -# -# They are run during the first stage of the pipeline as a smoke test to ensure -# that we can successfully build packages on all of our architectures for a -# single OS. They are triggered on any change to an MR. No artifacts are -# produced as part of build-one jobs. -.build-one-setup: &build-one-setup - <<: *build-setup - stage: build-one - only: - - merge_requests +.pipeline-trigger-rules: + rules: + # We trigger the pipeline if started manually + - if: $CI_PIPELINE_SOURCE == "web" + # We trigger the pipeline on the main branch + - if: $CI_COMMIT_BRANCH == "main" + # We trigger the pipeline on the release- branches + - if: $CI_COMMIT_BRANCH =~ /^release-.*$/ + # We trigger the pipeline on tags + - if: $CI_COMMIT_TAG && $CI_COMMIT_TAG != "" + +workflow: + rules: + # We trigger the pipeline on a merge request + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + # We then add all the regular triggers + - !reference [.pipeline-trigger-rules, rules] + +# The main or manual job is used to filter out distributions or architectures that are not required on +# every build. +.main-or-manual: + rules: + - !reference [.pipeline-trigger-rules, rules] + - if: $CI_PIPELINE_SOURCE == "schedule" + when: manual -# build-all jobs build packages for every OS / ARCH combination we support. -# -# They are run under two conditions: -# 1) Automatically whenever a new tag is pushed to the repo (e.g. v1.1.0) -# 2) Manually by a reviewer just before merging a MR. -# -# Unlike build-one jobs, it takes a long time to build the full suite -# OS / ARCH combinations, so this is optimized to only run once per MR -# (assuming it all passes). A full set of artifacts including the packages -# built for each OS / ARCH are produced as a result of these jobs. -.build-all-setup: &build-all-setup - <<: *build-setup - stage: build-all - timeout: 2h 30m +# The trigger-pipeline job adds a manualy triggered job to the pipeline on merge requests. +trigger-pipeline: + stage: trigger + script: + - echo "starting pipeline" rules: - - if: $CI_COMMIT_TAG - when: always - - if: $CI_MERGE_REQUEST_ID + - !reference [.main-or-manual, rules] + - if: $CI_PIPELINE_SOURCE == "merge_request_event" when: manual + allow_failure: false + - when: always +.build-setup: + stage: build variables: ARTIFACTS_NAME: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}-${CI_JOB_NAME}-artifacts-${CI_PIPELINE_ID}" ARTIFACTS_DIR: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}-artifacts-${CI_PIPELINE_ID}" @@ -80,46 +81,16 @@ variables: paths: - ${ARTIFACTS_DIR} -# The full set of build-one jobs organizes to build -# ubuntu18.04 in parallel on each of our supported ARCHs. -build-one-amd64: - <<: *build-one-setup - script: - - make ubuntu18.04-amd64 - -build-one-ppc64le: - <<: *build-one-setup - script: - - make ubuntu18.04-ppc64le - -build-one-arm64: - <<: *build-one-setup - script: - - make ubuntu18.04-arm64 - -# The full set of build-all jobs organized to -# have builds for each ARCH run in parallel. -build-all-amd64: - <<: *build-all-setup - script: - - make docker-amd64 - -build-all-x86_64: - <<: *build-all-setup - script: - - make docker-x86_64 - -build-all-ppc64le: - <<: *build-all-setup - script: - - make docker-ppc64le - -build-all-arm64: - <<: *build-all-setup - script: - - make docker-arm64 + before_script: + - apk update + - apk upgrade + - apk add coreutils build-base sed git bash make -build-all-aarch64: - <<: *build-all-setup +build: + extends: + - .build-setup + parallel: + matrix: + - PACKAGING: [deb, rpm] script: - - make docker-aarch64 + - make ${PACKAGING}