From 6950877360f2804101b86a3f4b80a21b7e923225 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 26 Jan 2023 16:05:28 -0500 Subject: [PATCH] Resolve TODO: human-readable image-suffixes This conditional was required temporarily so PR #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 --- ci/validate.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ci/validate.sh b/ci/validate.sh index 75f62785..c1d32b54 100755 --- a/ci/validate.sh +++ b/ci/validate.sh @@ -13,7 +13,7 @@ REPO_DIRPATH=$(realpath "$SCRIPT_DIRPATH/../") # shellcheck source=./lib.sh source "$REPO_DIRPATH/lib.sh" -req_env_vars CIRRUS_PR CIRRUS_BASE_SHA +req_env_vars CIRRUS_PR CIRRUS_BASE_SHA CIRRUS_CHANGE_TITLE # die() will add a reference to this file and line number. [[ "$CIRRUS_CI" == "true" ]] || \ @@ -28,24 +28,24 @@ done # Variable is defined by Cirrus-CI at runtime # shellcheck disable=SC2154 -if ! git diff --name-only ${CIRRUS_BASE_SHA}..HEAD | grep -q IMG_SFX; then - die "Every PR must include an updated IMG_SFX file. +if [[ ! "$CIRRUS_CHANGE_TITLE" =~ CI:DOCS ]] && \ + [[ ! "$CIRRUS_CHANGE_TITLE" =~ CI:TOOLING ]] && \ + ! git diff --name-only ${CIRRUS_BASE_SHA}..HEAD | grep -q IMG_SFX; then + + die "Every PR that builds images must include an updated IMG_SFX file. 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) +else # IMG_SFX was modified vs PR's base-branch, confirm version moved forward + # shellcheck disable=SC2154 + v_prev=$(git show ${CIRRUS_BASE_SHA}:IMG_SFX 2>&1 || true) + # Verify new IMG_SFX value always version-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 '$(