From 41453d70c196a85d5907d7507fe357e3849ca87e Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Mon, 31 May 2021 07:51:11 +0000
Subject: [PATCH] .ostc-ci: handle scheduled builds and draft pull requests

Scheduled builds will allow us to re-test what's in HEAD without opening
a pull request. Making drafts start in manual mode will conserve
resources without limiting one's ability to iterate on selective
targets.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .ostc-ci/gitlab-ci.yml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/.ostc-ci/gitlab-ci.yml b/.ostc-ci/gitlab-ci.yml
index e407b6f2..658e59a8 100644
--- a/.ostc-ci/gitlab-ci.yml
+++ b/.ostc-ci/gitlab-ci.yml
@@ -58,9 +58,15 @@ aggregate-docs:
 
 # Customize the .bitbake-workspace job to set the rules governing when a build
 # is attempted to: modifications (changes) to the pipeline, meta-layers,
-# flavours and assets or to placement of a tag on a commit.
+# flavours and assets OR to placement of a tag on a commit OR when a job is
+# scheduled. In addition, draft merge requests will no longer start the heavy
+# build jobs automatically, giving an option to the developer, to start the
+# desired jobs manually.
 .bitbake-workspace:
   rules:
+    - if: '$CI_PIPELINE_SOURCE == "schedule"'
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(wip|draft):.*/i'
+      when: manual
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
       changes:
         - assets/**/*
-- 
GitLab