From d8194ee1b91fd98a152d617f93ec373ad4cb06f5 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Wed, 24 Mar 2021 18:53:11 +0100
Subject: [PATCH] gitlab-ci.yml: restrict job creation based on files changed

CI process in the meta-ohos repository is rather heavy, with large
number of long-running build jobs. The pipeline system allows
restricting job startup to a set of rules, and to further restrict each
rule to trigger only when one of a set of given files is modified.

This should allow efficient modification pipeline that only touches the
documentation or the meta-layers, without needlessly running unrelated
testing.

This is documented at https://docs.gitlab.com/ee/ci/yaml/#ruleschanges

Closes: https://git.ostc-eu.org/OSTC/OHOS/meta-ohos/-/issues/34
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .ostc-ci/gitlab-ci.yml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/.ostc-ci/gitlab-ci.yml b/.ostc-ci/gitlab-ci.yml
index e6276e8e..f608d217 100644
--- a/.ostc-ci/gitlab-ci.yml
+++ b/.ostc-ci/gitlab-ci.yml
@@ -52,6 +52,11 @@ build-docs:
   rules:
     # Build the docs when a merge request is created.
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
+      changes:
+        # React to changes to the docs directory.
+        - docs/**
+        # Run this job in case the pipeline changes.
+        - .ostc-ci/*.yml
 
 # Customize the generic .build job, included from build-generic.yaml above,
 # with settings for testing updates to the meta-ohos git repository.
@@ -67,3 +72,13 @@ build-docs:
     # Disable collection of image artifacts. They are not used here and they
     # are expensive to upload and store.
     paths: []
+  rules:
+    # Perform bitbake build when a merge request is created.
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
+      changes:
+        # React to changes to meta-layers assets and flavours.
+        - assets/**
+        - flavours/**
+        - meta-*/**
+        # Run this job in case the pipeline changes.
+        - .ostc-ci/*.yml
-- 
GitLab