From 3f6a9c296798371541a7ddeebdc3e2fea1807d8b Mon Sep 17 00:00:00 2001
From: Pavel Zhukov <pavel.zhukov@huawei.com>
Date: Tue, 26 Jul 2022 09:50:22 +0200
Subject: [PATCH] oniro-ci: Add variable to specify oe-core path or branch

This allows overriding of oe-core to point to different branch/repo for
testing updated which are not in stable repo yet or testing the repo
before bumping revision in the manifest.

The main purpose is testing oniro against <branch>-nut in scheduled
pipelines to avoid breakages.

To test oniro against different branch/repo of oe-core set pipeline
variables as follows:

	CI_ONIRO_OECORE_BRANCH: branch_to_be_tested_with
	CI_ONIRO_OECORE_REPO: url_of_the_repo

Example:

	CI_ONIRO_OECORE_BRANCH: stable/kirkstone-nut
	CI_ONIRO_OECORE_REPO: https://git.openembedded.org/openembedded-core-contrib

Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .oniro-ci/build-generic.yaml      | 17 +++++++++++++++++
 docs/ci/hidden-jobs/workspace.rst | 14 ++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/.oniro-ci/build-generic.yaml b/.oniro-ci/build-generic.yaml
index 2c80411e..6dce95b4 100644
--- a/.oniro-ci/build-generic.yaml
+++ b/.oniro-ci/build-generic.yaml
@@ -15,6 +15,9 @@
     CI_ONIRO_MANIFEST_MIRROR: oniro-develop
     CI_ONIRO_GIT_REPO_PATH: ""
     CI_ONIRO_INSTANCE_SIZE: s3.large.8
+    # For testing with bleeding edge Yocto.
+    CI_ONIRO_OECORE_REPO: ""
+    CI_ONIRO_OECORE_BRANCH: ""
   before_script:
     - test ! -e "$CI_PROJECT_DIR"/.scratch-dir-name || (
         echo "precondition failed - concurrent modification of $CI_PROJECT_DIR"
@@ -56,6 +59,20 @@
       fi
       set +x
 
+    - |
+      set -x
+      if [ -n "$CI_ONIRO_OECORE_BRANCH" ]; then
+          if [ -n "$CI_ONIRO_OECORE_REPO" ]; then
+              echo "CI: Using oe-core from '$CI_ONIRO_OECORE_REPO': '$CI_ONIRO_OECORE_BRANCH'"
+              ( cd oe-core && git remote add oecore-nut "$CI_ONIRO_OECORE_REPO" \
+                  && git fetch oecore-nut && git checkout oecore-nut/"$CI_ONIRO_OECORE_BRANCH" )
+          else
+              echo "CI: Using oe-core branch: '$CI_ONIRO_OECORE_BRANCH'"
+              ( cd oe-core && git fetch && git checkout "$CI_ONIRO_OECORE_BRANCH" )
+          fi
+      fi
+      set +x
+
   script:
     # Reload the value of SCRATCH_DIR set in the before_script phase. Those run
     # in separate shell processes and do not share environment variables.
diff --git a/docs/ci/hidden-jobs/workspace.rst b/docs/ci/hidden-jobs/workspace.rst
index c930b9f8..b8755437 100644
--- a/docs/ci/hidden-jobs/workspace.rst
+++ b/docs/ci/hidden-jobs/workspace.rst
@@ -108,6 +108,20 @@ Merge Results`_ for more information.
 
 The default value is the empty string.
 
+
+CI_ONIRO_OECORE_BRANCH
+----------------------
+
+Can be used to specify Openembedded Core branch to be used for testing.
+If not specified, the one defined in ``CI_ONIRO_MANIFEST_NAME`` manifest file will be used
+
+CI_ONIRO_OECORE_REPO
+--------------------
+
+Can be used to specify Openembedded Core repo (remote) to be used for testing.
+If not specified, the one defined in ``CI_ONIRO_MANIFEST_NAME`` manifest file will be used
+NOTE: ``CI_ONIRO_OECORE_BRANCH`` *must* be specified for overriden repos
+
 Local git-repo Mirror
 =====================
 
-- 
GitLab