Skip to content

Commit

Permalink
Resolve TODO: human-readable image-suffixes
Browse files Browse the repository at this point in the history
This conditional was required temporarily so containers#247 could merge.  Remove
and replace it with a version that avoids modifying any files and only
checks if `IMG_SFX` changes were made.

Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Jan 27, 2023
1 parent 3c24076 commit 9528b57
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions ci/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,17 @@ if ! git diff --name-only ${CIRRUS_BASE_SHA}..HEAD | grep -q IMG_SFX; then
Simply run 'make IMG_SFX', commit the result, and re-push."
fi

# Verify new IMG_SFX value always sorts later than previous value. This prevents
# screwups due to local timezone, bad, or unset clocks, etc.
cd $REPO_DIRPATH
# Automation requires the date and time components sort properly
# as if they were version-numbers regardless of distro-version component.
new_img_ver=$(awk -F '-' '{print $1"."$2}' ./IMG_SFX)
# TODO: Conditional checkout not needed after the PR which added IMG_SFX file.
if git checkout ${CIRRUS_BASE_SHA} IMG_SFX; then
old_img_ver=$(awk -F '-' '{print $1"."$2}' ./IMG_SFX)
# If IMG_SFX was modified vs PR's base-branch, validate the changes.
v_prev=$(git show ${CIRRUS_BASE_SHA}:IMG_SFX 2>&1 || true)
if ! [[ $v_prev =~ "exists on disk, but not in" ]]; then
# Verify new IMG_SFX value always sorts later than previous value. This prevents
# screwups due to local timezone, bad, or unset clocks, etc.
new_img_ver=$(awk -F 't' '{print $1"."$2}' ./IMG_SFX | cut -dz -f1)
old_img_ver=$(awk -F 't' '{print $1"."$2}'<<<"$v_prev" | cut -dz -f1)
# Version-sorting of date/time mimics the way renovate will compare values
# see https://github.com/containers/automation/blob/main/renovate/defaults.json5
latest_img_ver=$(echo -e "$old_img_ver\n$new_img_ver" | sort -V | tail -1)
[[ "$latest_img_ver" == "$new_img_ver" ]] || \
die "Date/time stamp appears to have gone backwards! Please commit
an 'IMG_SFX' change with a value later than '$(<IMG_SFX)'"
else
warn "Could not find previous version of IMG_SFX, ignoring."
die "Updated IMG_SFX '$(<IMG_SFX)' appears to have gone backwards! Please commit
an 'IMG_SFX' change with a value later than '$(v_prev)'"
fi

0 comments on commit 9528b57

Please sign in to comment.