Skip to content

Commit

Permalink
[ci] Syncronize with generic pipeline template
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dennisjbell committed Sep 10, 2024
1 parent 8357cde commit fe0b05b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
10 changes: 8 additions & 2 deletions ci/scripts/check-sha1s
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion ci/scripts/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
20 changes: 15 additions & 5 deletions ci/scripts/test-deployment
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ts> --all|--json|--file <file>|--extract-to <path>)" --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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")"
Expand All @@ -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------------------"
Expand Down

0 comments on commit fe0b05b

Please sign in to comment.