From 792228b3792b216b43f8114616847bbc2c0cca09 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Tue, 26 Oct 2021 11:06:18 +0200
Subject: [PATCH] .gitlab-ci.yml: fix testing changes to the manifest

The manifest is special, because when it changes the oniro repository is
cloned three times inside the CI process:

- first time by GitLab, as a part of the normal CI checkout process
- second time by repo init, as a part of the .workspace job
- last time by repo sync, as a part of the same job

When the manifest changes, the CI system should be testing the incoming
change. Crucially the second step needs to be adjusted, to take the
manifest from a non-default location. This was handled before the
manifest repository was merged into the oniro repository. During that
merge the critical step was lost.

Adjust the .bitbake-workspace job to inject variables that pick the
correct manifest repository and branch. Leave a comment for the untested
rule about CI for tags.

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

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index de1e5575..fd634acd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -61,13 +61,25 @@ aggregate-docs:
     - if: '$CI_PIPELINE_SOURCE == "schedule"'
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(wip|draft):.*/i'
       when: manual
+      variables:
+        # See below for rationale.
+        CI_ONIRO_MANIFEST_URL: "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL"
+        CI_ONIRO_MANIFEST_BRANCH: "$CI_COMMIT_REF_NAME"
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
       changes:
         - assets/**/*
         - flavours/**/*
         - meta-*/**/*
         - .oniro-ci/*
+      # When building a merge request substitute the CI_ONIRO_MANIFEST_URL to point
+      # to the incoming repository, and CI_ONIRO_MANIFEST_BRANCH, to the right
+      # branch name. This allows testing the changes coming into project. This
+      # is done here, so that it does not clobber scheduled pipelines.
+      variables:
+        CI_ONIRO_MANIFEST_URL: "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL"
+        CI_ONIRO_MANIFEST_BRANCH: "$CI_COMMIT_REF_NAME"
     - if: '$CI_COMMIT_TAG'
+      # XXX: This needs CI_ONIRO_MANIFEST_BRANCH as well, most likely.
 
 # Mimic the updated rules for lava-test from the bitbake-workspace.
 .lava-test:
-- 
GitLab