summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
diff options
context:
space:
mode:
authorJordan Petridis <jordan@centricular.com>2022-07-26 22:36:22 +0300
committerMarge Bot <marge-bot@gnome.org>2022-08-17 11:46:45 +0000
commit5d81f6d89d1daff4a1b433c3f4270f32fe74b288 (patch)
tree43c6638635789beef064eb585c9170fc9a758b72 /.gitlab-ci.yml
parent642791673c345bd1432f97d6b7c5e4632e01f2fd (diff)
downloadmutter-5d81f6d89d1daff4a1b433c3f4270f32fe74b288.tar.gz
ci: Avoid duplicate pipelines vol 2
This is a followup to GNOME/mutter!1578 This commit does a couple of things to avoid creating multiple pipelines per commit. First, it avoid catch all `when: manual` rules, which might end up matching custom variables set which might potentially not be handled. Secondly it reworks the `workflow:rules:` and the pipeline guard rules to avoid duplicate pipelines as the gitlab documentation suggests. Last, it switches from yaml anchors to the new `reference` gitlab keyword which is more flexible. https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2534>
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r--.gitlab-ci.yml31
1 files changed, 24 insertions, 7 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 77eb14ee4..94c161cd4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -146,17 +146,31 @@ default:
workflow:
rules:
- - if: '$CI_MERGE_REQUEST_IID'
- - if: '$CI_COMMIT_TAG'
+ # Allow to switch from branch pipelines to MR pipelines seamlessly
+ # https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
+ when: never
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+ # Don't trigger a branch pipeline if there is an open MR
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
+ when: never
- if: '$CI_COMMIT_BRANCH'
+ - if: '$CI_COMMIT_TAG'
-.pipline-guard: &pipline-guard
+.pipeline-guard:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_TAG'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_COMMIT_BRANCH =~ /^gnome-[0-9-]+$/'
- - when: 'manual'
+ # Avoid catchall `when: manual` rule which might
+ # cause duplicate pipelines to be triggered.
+ # https://docs.gitlab.com/ee/ci/jobs/job_control.html#avoid-duplicate-pipelines
+ #
+ # Also make it so pipelines without MR need to be started
+ # manually, since their state will most likely be WIP
+ - if: '$CI_COMMIT_BRANCH'
+ when: 'manual'
check-commit-log:
extends:
@@ -177,7 +191,8 @@ check-commit-log:
- commit-message-junit-report.xml
reports:
junit: commit-message-junit-report.xml
- <<: *pipline-guard
+ rules:
+ - !reference [.pipeline-guard, rules]
check-merge-request:
extends:
@@ -198,7 +213,8 @@ check-merge-request:
- check-merge-request-report.xml
reports:
junit: check-merge-request-report.xml
- <<: *pipline-guard
+ rules:
+ - !reference [.pipeline-guard, rules]
build-fedora-container@x86_64:
extends:
@@ -447,7 +463,8 @@ test-mutter-coverity:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $MUTTER_SCHEDULED_JOB == "coverity"'
when: always
- - when: manual
+ - if: '$CI_COMMIT_BRANCH'
+ when: 'manual'
extends:
- .fdo.distribution-image@fedora
- .mutter.fedora:35@x86_64