From a6598d8037d2a935660ce6efbcc98b2e21c2d9c2 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 pipiline 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               | 9 +++++++++
 .oniro-ci/build-generic.yaml | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1021198e..61a6ff80 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.
 
@@ -102,9 +107,13 @@ aggregate-docs:
 # that replace the previous value.
 
 .bitbake-workspace:
+  variables:
+    CI_ONIRO_MAGIC: .gitlab-ci.yml:111:.bitbake-workspace
   extends: [.workspace, .workspace-rules]
 
 .build-rauc-bundle:
+  variables:
+    CI_ONIRO_MAGIC: .gitlab-ci.yml:116:.build-rauc-bundle
   extends: [.build-image, .workspace-rules]
 
 .publish-rauc-bundle-to-hawkbit:
diff --git a/.oniro-ci/build-generic.yaml b/.oniro-ci/build-generic.yaml
index 8dbb59ac..a7ef28eb 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:.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:.bitbake-workspace
 
   before_script:
     # Bitbake requires a non-root user to operate.
-- 
GitLab