From 4986a9eaf15f40470ece28f7baafe197f232930f Mon Sep 17 00:00:00 2001
From: Vignesh Raman <vignesh.raman@collabora.com>
Date: Mon, 21 Apr 2025 10:19:35 +0530
Subject: [PATCH] Workflow

Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com>
---
 tools/ci/gitlab-ci/gitlab-ci.yml | 64 ++++++++++++++------------------
 1 file changed, 28 insertions(+), 36 deletions(-)

diff --git a/tools/ci/gitlab-ci/gitlab-ci.yml b/tools/ci/gitlab-ci/gitlab-ci.yml
index c71c25016a0eb..71eeed63faecf 100644
--- a/tools/ci/gitlab-ci/gitlab-ci.yml
+++ b/tools/ci/gitlab-ci/gitlab-ci.yml
@@ -2,43 +2,35 @@
 #
 # Copyright (C) 2024 Collabora, Helen Koike <helen.koike@collabora.com>
 
-# YAML anchors for rule conditions
-# --------------------------------
-.rules-anchors:
+workflow:
+  name: $PIPELINE_NAME
   rules:
-    # do not duplicate pipelines on merge pipelines
-    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
-      when: never
-    # merge pipeline
-    - if: &is-merge-attempt $GITLAB_USER_LOGIN == "marge-bot" && $CI_PIPELINE_SOURCE == "merge_request_event"
-    # post-merge pipeline
-    - if: &is-post-merge $GITLAB_USER_LOGIN == "marge-bot" && $CI_PIPELINE_SOURCE == "push"
-    # Pre-merge pipeline
-    - if: &is-pre-merge $CI_PIPELINE_SOURCE == "merge_request_event"
-    # Push to a branch on a fork
-    - if: &is-fork-push $CI_PIPELINE_SOURCE == "push"
-    # nightly pipeline
-    - if: &is-scheduled-pipeline $CI_PIPELINE_SOURCE == "schedule"
-    # pipeline for direct pushes that bypassed the CI
-    - if: &is-direct-push $CI_PIPELINE_SOURCE == "push" && $GITLAB_USER_LOGIN != "marge-bot"
-
-.container+build-rules:
-  rules:
-    # Build everything in merge pipelines
-    - if: *is-merge-attempt
-      when: on_success
-    # Same as above, but for pre-merge pipelines
-    - if: *is-pre-merge
-      when: manual
-    # Build everything after someone bypassed the CI
-    - if: *is-direct-push
-      when: manual
-    # Build everything in scheduled pipelines
-    - if: *is-scheduled-pipeline
-      when: on_success
-    # Allow building everything in fork pipelines, but build nothing unless
-    # manually triggered
-    - when: manual
+    # when triggered as a multi-project pipeline for an MR
+    - if: $CI_PIPELINE_SOURCE == 'pipeline' && $PARENT_MERGE_REQUEST_IID != null && $PARENT_MERGE_REQUEST_IID != ""
+      variables:
+        PIPELINE_NAME: 'Downstream pipeline for $PARENT_PROJECT_PATH!$PARENT_MERGE_REQUEST_IID'
+    # when triggered as a multi-project pipeline
+    - if: $CI_PIPELINE_SOURCE == 'pipeline'
+      variables:
+        PIPELINE_NAME: 'Downstream pipeline for $PARENT_PROJECT_PATH'
+    # when triggered via a schedule
+    - if: $CI_PIPELINE_SOURCE == 'schedule'
+      variables:
+        PIPELINE_NAME: 'Scheduled pipeline for $ONLY_JOB_NAME'
+    # for merge requests
+    - if: $CI_MERGE_REQUEST_ID
+    # when triggered via the REST api
+    - if: $CI_PIPELINE_SOURCE == 'api'
+    # for the tip of the default branch
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+    # when triggered via a trigger token
+    - if: $CI_PIPELINE_SOURCE == 'trigger'
+    # when triggered from a button press in the web interface
+    - if: $CI_PIPELINE_SOURCE == 'web'
+    # for branch tips without open MRs, ignoring special branches
+    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_OPEN_MERGE_REQUESTS == null
+    # when forced via '-o ci.variable="FORCE_CI=true"' during pushing
+    - if: $FORCE_CI == 'true'
 
 variables:
   SMATCH_DB_DIR: /smatch/smatch_data
-- 
GitLab