From 1de2f9182adb71fa8ff352da95ae5ec39733bae3 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Mon, 6 Jun 2022 10:23:18 +0200
Subject: [PATCH] .oniro-ci,gitlab-ci.yml: add and display CI_ONIRO_MAGIC

Our GitLab pipeline jobs rely on both the .extends mechanism and the
re-definition-in-place mechanism, in order to avoid repetition.
Something is misbehaving, as evidenced by [1] and [2], suggesting that
the way GitLab computes the effective set of jobs in a pipeline is
different from what we understand.

The CI_ONIRO_MAGIC variable is set to the name and location of the job
defining the particular value. By showing the effective value of the
variable, we may gain some insight into what is going on in practice.

[1] https://gitlab.eclipse.org/eclipse/oniro-core/oniro/-/issues/613
[2] https://gitlab.eclipse.org/eclipse/oniro-core/oniro/-/issues/574

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .gitlab-ci.yml               | 5 +++++
 .oniro-ci/build-generic.yaml | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1021198e..c3ab6c72 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -57,17 +57,21 @@ aggregate-docs:
 # automatically, giving an option to the developer, to start the desired jobs
 # manually.
 .workspace-rules:
+  variables:
+    CI_ONIRO_MAGIC: ".gitlab-ci.yml:61:.workspace-rules"
   rules:
     - if: '$CI_PIPELINE_SOURCE == "schedule"'
       variables:
         CI_ONIRO_MANIFEST_URL: "$CI_PROJECT_URL"
         CI_ONIRO_MANIFEST_BRANCH: "$CI_COMMIT_REF_NAME"
+        CI_ONIRO_MAGIC: ".gitlab-ci.yml:67:.workspace-rules"
     - 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"
+        CI_ONIRO_MAGIC: ".gitlab-ci.yml:74:.workspace-rules"
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
       changes:
         - assets/**/*
@@ -83,6 +87,7 @@ aggregate-docs:
       variables:
         CI_ONIRO_MANIFEST_URL: "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL"
         CI_ONIRO_MANIFEST_BRANCH: "$CI_COMMIT_REF_NAME"
+        CI_ONIRO_MAGIC: ".gitlab-ci.yml:90:.workspace-rules"
     - if: '$CI_COMMIT_TAG'
       # XXX: This needs CI_ONIRO_MANIFEST_BRANCH as well, most likely.
 
diff --git a/.oniro-ci/build-generic.yaml b/.oniro-ci/build-generic.yaml
index 8dbb59ac..7149b47f 100644
--- a/.oniro-ci/build-generic.yaml
+++ b/.oniro-ci/build-generic.yaml
@@ -15,7 +15,9 @@
     CI_ONIRO_MANIFEST_MIRROR: oniro-develop
     CI_ONIRO_GIT_REPO_PATH: ""
     CI_ONIRO_INSTANCE_SIZE: s3.large.8
+    CI_ONIRO_MAGIC: ".oniro-ci/build-generic.yaml:18:.workspace"
   before_script:
+    - env | grep -E ^CI_ONIRO | sort
     - test ! -e "$CI_PROJECT_DIR"/.scratch-dir-name || (
         echo "precondition failed - concurrent modification of $CI_PROJECT_DIR"
         && env | grep CI_ | sort
@@ -91,6 +93,7 @@
     CI_ONIRO_BB_LOCAL_CONF_plus_equals_USER_CLASSES: "buildstats buildstats-summary"
     CI_ONIRO_DEVTOOL_RECIPE_NAME: ""
     CI_ONIRO_DEVTOOL_LAYER_PATH: ""
+    CI_ONIRO_MAGIC: ".oniro-ci/build-generic.yaml:96:.bitbake-workspace"
 
   before_script:
     # Bitbake requires a non-root user to operate.
-- 
GitLab