refactor: relocate Gerrit metadata LAVA job YAML generation
This change moves the Gerrit metadata LAVA job YAML generation logic
from `gen_fvp_yaml_template` into `gen_fvp_yaml`. There's no real
reason to run this step separately anymore, and having two templating
phases makes it awkward to template the file (because second-phase
templating expressions need to be escaped).
Change-Id: Ib404b4fd275e0feb52a76699c5f060f651931527
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/fvp_utils.sh b/fvp_utils.sh
index 7854081..d004b1c 100644
--- a/fvp_utils.sh
+++ b/fvp_utils.sh
@@ -289,30 +289,19 @@
#
# - `lava-templates/fvp-linux.yaml`
# - `lava-templates/fvp-tftf.yaml`
-#
-# The job definition template is itself expanded with visibility of all
-# variables that are available from within the function, including those with
-# local scope.
-#
-# TODO: Move the Gerrit metadata generation to to the main YAML generation phase
-# so that we can template the file in one phase.
gen_fvp_yaml_template() {
- if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
- local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
- elif [ -n "${GERRIT_REFSPEC}" ]; then
- local gerrit_url=$(echo ${GERRIT_REFSPEC} |
- awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
- fi
-
local yaml_template_file="${workspace}/fvp_template.yaml"
- pushd "${ci_root}/script/lava-templates"
- expand_template "fvp-${payload_type:?}.yaml" > "$yaml_template_file"
- popd
+ cp "${ci_root}/script/lava-templates/fvp-${payload_type:?}.yaml" \
+ "${yaml_template_file}"
archive_file "${yaml_template_file}"
}
+# Generates the final YAML-based LAVA job definition from a template file.
+#
+# The job definition template is expanded with visibility of all variables that
+# are available from within the function, including those with local scope.
gen_fvp_yaml() {
local model="${model:?}"
@@ -348,6 +337,13 @@
# optional parameters, defaults to globals
local model_dtb="${model_dtb:-$default_model_dtb}"
+ if [ -n "${GERRIT_CHANGE_NUMBER}" ]; then
+ local gerrit_url="https://review.trustedfirmware.org/c/${GERRIT_CHANGE_NUMBER}/${GERRIT_PATCHSET_NUMBER}"
+ elif [ -n "${GERRIT_REFSPEC}" ]; then
+ local gerrit_url=$(echo ${GERRIT_REFSPEC} |
+ awk -F/ '{print "https://review.trustedfirmware.org/c/" $4 "/" $5}')
+ fi
+
# possible artefacts
backup_fip="$(fvp_gen_bin_url backup_fip.bin)"
bl1="$(fvp_gen_bin_url bl1.bin)"
@@ -504,7 +500,7 @@
done
# copied files are the working files
- cp "${yaml_template_file}" "${yaml_file}"
+ expand_template "${yaml_template_file}" > "${yaml_file}"
cp "$archive/model_params" "$lava_model_params"
# Ensure braces in the FVP model parameters are not accidentally interpreted