From fe0b05b3ec0986e0acd427507a9f08e01948b917 Mon Sep 17 00:00:00 2001 From: "Dennis J. Bell" Date: Tue, 10 Sep 2024 10:52:51 -0700 Subject: [PATCH] [ci] Syncronize with generic pipeline template This includes the following changes: * Add versions to the sha1 check output * Whitespace cleanup in deploy script * Use genesis v3 features in test-deployment script --- ci/scripts/check-sha1s | 10 ++++++++-- ci/scripts/deploy | 2 +- ci/scripts/test-deployment | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ci/scripts/check-sha1s b/ci/scripts/check-sha1s index 4aa2ac98..37d9774a 100755 --- a/ci/scripts/check-sha1s +++ b/ci/scripts/check-sha1s @@ -10,12 +10,18 @@ for my $r (@{$data->{releases} || []}) { $sha1 =~ s/ .*//; if ($r->{sha1} eq $sha1) { - print "[ok] $r->{name} sha1 checkums are correct.\n"; + print "[ok] $r->{name} (v$r->{version}) sha1 checkums are correct.\n"; } else { - print "[!!] $r->{name} sha1 checkums are INCORRECT.\n"; + print "[!!] $r->{name} (v$r->{version}) sha1 checkums are INCORRECT.\n"; print "[!!] the kit has '$r->{sha1}' (wrong)\n"; print "[!!] actually got '$sha1' (correct)\n"; $rc = 1; } } + +if ($rc) { + print "\n[!!] sha1 check failed.\n"; +} else { + print "\n[ok] sha1 check passed.\n"; +} exit $rc; diff --git a/ci/scripts/deploy b/ci/scripts/deploy index 46b38dcb..648480d3 100755 --- a/ci/scripts/deploy +++ b/ci/scripts/deploy @@ -65,7 +65,7 @@ else header "Setting up Genesis deployment directory for $KIT_SHORTNAME v$VERSION..." rm -rf work/*; mkdir -p work/ genesis -v - genesis -C "$(dirname "$WORKDIR")" init -k "$KIT" --vault da-vault -d "$(basename "$WORKDIR")" + genesis -C "$(dirname "$WORKDIR")" init -k "$KIT" --vault da-vault -d "$(basename "$WORKDIR")" fi header "Copying test environment YAMLs from $CI_ROOT/ci/envs..." diff --git a/ci/scripts/test-deployment b/ci/scripts/test-deployment index 413e5a3f..c2c13c26 100755 --- a/ci/scripts/test-deployment +++ b/ci/scripts/test-deployment @@ -21,17 +21,26 @@ has_feature() { } is_proto() { - has_feature "$1" 'proto' # This will need to be changed in v2.8.0 + "$(genesis "$1" lookup genesis.use_create_env false 2>/dev/null)" || has_feature "$1" 'proto' } cleanup_environment() { local env="$1" + # FIXME: This needs to be updated when genesis 3.1 is released because + # .genesis/manifests directory will be gone. However, by using safe instead + # of local files, we won't have lost deployments: + # if [[ $(genesis version major) -eq 3 && $(genesis version minor) -ge 1 ]] ; then + # data="$(genesis "$env" lookup --historic latest --type state .)" --or-- + # data="$(genesis "$env" deployment-history|dh|history --all|--json|--file |--extract-to )" --default is deployed manifest + # ... + # fi if [[ -f .genesis/manifests/$env-state.yml ]] ; then header "Preparing to delete proto environment $env" echo "Generating reference manifest..." - genesis "$env" manifest --no-redact > manifest.yml 2>/dev/null + genesis "$env" manifest > manifest.yml 2>/dev/null echo $'\n'"Building BOSH variables file..." - genesis "${env}" lookup --merged bosh-variables > vars.yml 2>/dev/null + + genesis "${env}" manifest -s 'bosh-vars' > vars.yml 2>/dev/null echo $'\n'"$env state file:" echo "----------------->8------------------" cat ".genesis/manifests/$env-state.yml" @@ -62,7 +71,7 @@ cleanup() { if is_proto "$deployment" ; then cleanup_environment "$deployment" else ( # run in a subshell to prevent pollution - eval "$(genesis bosh --connect "${deployment}" 2>/dev/null)" + eval "$(genesis "${deployment}" bosh --connect 2>/dev/null)" cleanup_deployment "$deployment-${KIT_SHORTNAME}" ); fi done @@ -164,7 +173,7 @@ if [[ "$SKIP_DEPLOY" == "false" ]]; then *) echo >&2 "Unknown or missing INFRASTRUCTURE value -- cannot upload stemcell" ;; esac - if [[ -n "$stemcell_iaas" ]] ; then + if [[ -n "$stemcell_iaas" ]] && ! is_proto "$DEPLOY_ENV" ; then stemcell_data="$(genesis "${DEPLOY_ENV}" lookup --merged stemcells)" stemcell_os="$(jq -r '.[0].os' <<<"$stemcell_data")" stemcell_version="$(jq -r '.[0].version' <<<"$stemcell_data")" @@ -186,6 +195,7 @@ if [[ "$SKIP_DEPLOY" == "false" ]]; then genesis "${DEPLOY_ENV}" deploy -y + # FIXME for genesis 3.1 here too if [[ -f .genesis/manifests/${DEPLOY_ENV}-state.yml ]] ; then echo $'\n'"${DEPLOY_ENV} state file:" echo "----------------->8------------------"