gitlab-ci: Overhaul job run policy
authorMichel Dänzer <mdaenzer@redhat.com>
Thu, 26 Sep 2019 07:27:27 +0000 (09:27 +0200)
committerMichel Dänzer <michel@daenzer.net>
Fri, 6 Dec 2019 09:02:01 +0000 (10:02 +0100)
Use new rules: instead of only:

For container stage jobs:

* In the main Mesa project, run them by default.

* In merge requests, run them by default if any files affecting pipeline
  results are changed.

* In all other cases (in particular branches in personal projects),
  don't run them by default but allow triggering them manually.

build & test stage jobs are left at the default (when: on_success), so
they will run automatically once all their dependencies are satisified.
(Using the same rules as above would require these jobs to be manually
triggered as well, which is only possible once all dependency jobs have
passed) Please be considerate of CI runner resources and cancel unneeded
jobs on personal branches with no corresponding merge requests (this can
be done before the jobs start running).

In summary: No more special branch names. Unnecessary job runs are
avoided by default, but jobs which don't run by default can be triggered
manually.

v2:
* Split out LAVA changes to separate commit
* Clarify commit log a little, in particular WRT build/test stage jobs

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> # v1
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> # v1
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> # v1
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
.gitlab-ci.yml

index 0c89ec45a2aba3573402ce151770b6f0214e7527..9934293b2df4093d5f1129e7d6c824300b180b4c 100644 (file)
@@ -18,28 +18,8 @@ stages:
 
 # When to automatically run the CI
 .ci-run-policy:
-  only:
-    refs:
-      - branches@mesa/mesa
-      - merge_requests
-      - /^ci([-/].*)?$/
-    changes:
-      - VERSION
-      - bin/**/*
-      # GitLab CI
-      - .gitlab-ci.yml
-      - .gitlab-ci/**/*
-      # Meson
-      - meson*
-      - build-support/**/*
-      - subprojects/**/*
-      # SCons
-      - SConstruct
-      - scons/**/*
-      - common.py
-      # Source code
-      - include/**/*
-      - src/**/*
+  rules:
+    - when: on_success
   retry:
     max: 2
     when:
@@ -77,6 +57,32 @@ stages:
   stage: container
   extends:
     - .ci-run-policy
+  rules:
+    # Run pipeline by default for merge requests changing files affecting it
+    - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME'
+      changes:
+      - VERSION
+      - bin/**/*
+      # GitLab CI
+      - .gitlab-ci.yml
+      - .gitlab-ci/**/*
+      # Meson
+      - meson*
+      - build-support/**/*
+      - subprojects/**/*
+      # SCons
+      - SConstruct
+      - scons/**/*
+      - common.py
+      # Source code
+      - include/**/*
+      - src/**/*
+      when: on_success
+    # Always run pipeline by default in the main project
+    - if: '$CI_PROJECT_PATH == "mesa/mesa"'
+      when: on_success
+    # Otherwise, allow triggering jobs manually
+    - when: manual
   variables:
     DEBIAN_VERSION: buster-slim
     REPO_SUFFIX: $CI_JOB_NAME