From 32c7e21e1723e210c170e51dd80cebb1c94a51ee Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Thu, 23 Nov 2023 15:02:07 +0100 Subject: [PATCH 1/4] CI: allow to enable merge trains --- .gitlab-ci.yml | 36 +++++++++++++++++++++++++--------- .gitlab/ci/pipelines/phony.yml | 14 +++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 .gitlab/ci/pipelines/phony.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24a81bfd8d50..c9910cd4cb73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,10 +12,14 @@ workflow: # with the corresponding 'if'-rules on the pipeline includes # below. - # Allow 'Before merging' pipelines - - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event"' + # Allow manual 'Before merging' pipelines on MRs in progress + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && ( $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/ || $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train" )' variables: - PIPELINE_TYPE: 'before_merging' + PIPELINE_TYPE: 'before_merging-not-ready' + # Allow 'phony-always-succeed' pipelines on ready MRs + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/' + variables: + PIPELINE_TYPE: 'before_merging-ready' # Allow 'Latest release' pipelines - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "latest-release"' variables: @@ -136,7 +140,7 @@ stages: # Trigger # -# §1: The purpose of this job is to launch the CI manually in certain cases. +# §1: The purpose of this job is to launch the CI manually in certain cases and run a full pipeline. # The objective is not to run computing when it is not # necessary and the decision to do so belongs to the developer # @@ -147,10 +151,6 @@ trigger: - .default_settings_template - .image_template__alpine stage: trigger - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/' - when: manual - - when: always allow_failure: false timeout: "10m" script: @@ -158,6 +158,16 @@ trigger: # Check that the Alpine version of the trigger job's image # corresponds to the value in scripts/version.sh. - ./scripts/ci/check_alpine_version.sh + rules: + # Manual pipelines on MRs that are not ready + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" && $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/' + when: manual + # We do not want to trigger anything for merged_result pipelines as + # the phony always succeed job will run instead. + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result"' + when: never + # Automatic trigger in all other pipelines types, that is "detached" and "merge_train" + - when: always include: # /!\ These rules should be be mutually exclusive and kept in sync @@ -167,9 +177,17 @@ include: - local: .gitlab/ci/jobs/shared/templates.yml # Before merging + # This rule is triggered if the MR is NOT in a ready state (therefore we want a manual pipeline) - local: .gitlab/ci/pipelines/before_merging.yml rules: - - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event"' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && ( $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/ || $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train" )' + + # This rule is triggered if the MR is in a ready state and it is necessary using the merge train + # workflow to be able to add the MR to the train + # without manual trigger. + - local: .gitlab/ci/pipelines/phony.yml + rules: + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && ( $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/ && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" )' # Latest release - local: .gitlab/ci/pipelines/latest_release.yml diff --git a/.gitlab/ci/pipelines/phony.yml b/.gitlab/ci/pipelines/phony.yml new file mode 100644 index 000000000000..38a819a89f84 --- /dev/null +++ b/.gitlab/ci/pipelines/phony.yml @@ -0,0 +1,14 @@ +# Phony merged_result pipeline to make sure the CI is green in order to add +# the MR to the merge train +phony-ready-for-merge: + extends: .image_template__alpine + variables: + # No need to fetch a working copy for this job. + GIT_STRATEGY: "none" + allow_failure: false + stage: trigger + timeout: "10m" + script: + - 'echo "The MR is ready and not await to be merged."' + - 'echo "Remove the label MR_IS_READY to get back to a manual trigger"' + - 'echo "Trigger pipeline 🤠. Always succeed."' -- GitLab From 93cccb404984a32738b593f54dce7086815d8995 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Wed, 29 Nov 2023 10:10:34 +0100 Subject: [PATCH 2/4] detached --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9910cd4cb73..59962455695d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -164,7 +164,7 @@ trigger: when: manual # We do not want to trigger anything for merged_result pipelines as # the phony always succeed job will run instead. - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result"' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && ( $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" || $CI_MERGE_REQUEST_EVENT_TYPE == "detached" )' when: never # Automatic trigger in all other pipelines types, that is "detached" and "merge_train" - when: always -- GitLab From d844989be099df8d86e75c2dfc43da15b712cbee Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 30 Nov 2023 10:54:16 +0100 Subject: [PATCH 3/4] new version --- .gitlab-ci.yml | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59962455695d..ae8cc9536ff6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,14 +12,26 @@ workflow: # with the corresponding 'if'-rules on the pipeline includes # below. - # Allow manual 'Before merging' pipelines on MRs in progress - - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && ( $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/ || $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train" )' + # Before merging types + ## Allow manual 'Before merging' pipelines on MRs in progress + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "detached"' variables: PIPELINE_TYPE: 'before_merging-not-ready' - # Allow 'phony-always-succeed' pipelines on ready MRs - - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/' + variables: + PIPELINE_TYPE: 'before_merging-not-ready' + ## Allow automatic 'Before merging' pipelines for Marge-bot and merge trains + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES =~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train"' + variables: + PIPELINE_TYPE: 'before_merging-merging' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"' + variables: + PIPELINE_TYPE: 'before_merging-merging' + ## Allow 'phony-always-succeed' pipelines on ready MRs + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/' variables: PIPELINE_TYPE: 'before_merging-ready' + # Allow 'Latest release' pipelines - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "latest-release"' variables: @@ -159,12 +171,13 @@ trigger: # corresponds to the value in scripts/version.sh. - ./scripts/ci/check_alpine_version.sh rules: - # Manual pipelines on MRs that are not ready - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" && $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "detached"' + when: manual + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/' when: manual # We do not want to trigger anything for merged_result pipelines as # the phony always succeed job will run instead. - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_PROJECT_NAMESPACE == "tezos" && ( $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" || $CI_MERGE_REQUEST_EVENT_TYPE == "detached" )' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/' when: never # Automatic trigger in all other pipelines types, that is "detached" and "merge_train" - when: always @@ -176,18 +189,22 @@ include: # Common templates - local: .gitlab/ci/jobs/shared/templates.yml - # Before merging - # This rule is triggered if the MR is NOT in a ready state (therefore we want a manual pipeline) + # Before merging types + + # This rule is triggered if the MR is NOT in a ready state (therefore we want a manual/automatic pipeline) - local: .gitlab/ci/pipelines/before_merging.yml rules: - - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && ( $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/ || $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train" )' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "detached"' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES =~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train"' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"' # This rule is triggered if the MR is in a ready state and it is necessary using the merge train # workflow to be able to add the MR to the train # without manual trigger. - local: .gitlab/ci/pipelines/phony.yml rules: - - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && ( $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/ && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" )' + - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/' # Latest release - local: .gitlab/ci/pipelines/latest_release.yml -- GitLab From 126fe25961d6e372aa92ab493dfcba4202ae3bbd Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Thu, 30 Nov 2023 14:16:12 +0000 Subject: [PATCH 4/4] Apply 1 suggestion(s) to 1 file(s) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae8cc9536ff6..02d3bcec155b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -175,7 +175,7 @@ trigger: when: manual - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS !~ /MR_IS_READY/' when: manual - # We do not want to trigger anything for merged_result pipelines as + # We do not want to trigger anything for merged_result pipelines that are ready as # the phony always succeed job will run instead. - if: '$CI_PROJECT_NAMESPACE == "tezos" && $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/ && $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result" && $CI_MERGE_REQUEST_LABELS =~ /MR_IS_READY/' when: never -- GitLab