From 7c01ac7933369dcc22a3c9beaa7ccd05e3da2ab6 Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Sun, 28 Jan 2024 23:32:15 +0800 Subject: [PATCH] ci: Utilize `before_script` in GitLab CI/CD. (#283) --- .gitlab-ci.yml | 2 ++ .gitlab/ci/ci.yml | 1 - .gitlab/ci/release.yml | 6 ++---- ... 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja | 2 ++ .../ci/ci.yml.jinja | 1 - .../ci/release.yml | 6 ++---- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fca30561..dd7c640a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,5 +3,7 @@ stages: - ci - release default: + before_script: + - env | sort image: ${CI_REGISTRY_IMAGE}:dev-py3.12 include: .gitlab/ci/**.yml diff --git a/.gitlab/ci/ci.yml b/.gitlab/ci/ci.yml index e39093ee..7bab9cc2 100644 --- a/.gitlab/ci/ci.yml +++ b/.gitlab/ci/ci.yml @@ -19,7 +19,6 @@ ci: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - - env | sort - make dev - make lint test doc build stage: ci diff --git a/.gitlab/ci/release.yml b/.gitlab/ci/release.yml index d4d27c15..beacf89d 100644 --- a/.gitlab/ci/release.yml +++ b/.gitlab/ci/release.yml @@ -7,7 +7,6 @@ doc: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort - make dev-doc - make doc - make release-notes > release-notes.md @@ -18,7 +17,6 @@ package: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort - make publish stage: release pages: @@ -31,7 +29,7 @@ pages: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort + - echo "Running the pages job." stage: release release: image: registry.gitlab.com/gitlab-org/release-cli:latest @@ -43,5 +41,5 @@ release: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort + - echo "Running the release job." stage: release diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja index 6ddd0c1d..3129949b 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja @@ -3,5 +3,7 @@ stages: - ci - release default: + before_script: + - env | sort image: ${CI_REGISTRY_IMAGE}:dev-py{{ default_py }} include: .gitlab/ci/**.yml diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/ci.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/ci.yml.jinja index 0ee4188c..2da1dfb9 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/ci.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/ci.yml.jinja @@ -30,7 +30,6 @@ ci: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - - env | sort - make dev - make lint test doc build stage: ci diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/release.yml b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/release.yml index d4d27c15..beacf89d 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/release.yml +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/ci/release.yml @@ -7,7 +7,6 @@ doc: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort - make dev-doc - make doc - make release-notes > release-notes.md @@ -18,7 +17,6 @@ package: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort - make publish stage: release pages: @@ -31,7 +29,7 @@ pages: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort + - echo "Running the pages job." stage: release release: image: registry.gitlab.com/gitlab-org/release-cli:latest @@ -43,5 +41,5 @@ release: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort + - echo "Running the release job." stage: release