From 0af059dbfb85670f7914494f648fd4d745b05e2a Mon Sep 17 00:00:00 2001 From: Nils Wireklint Date: Wed, 14 Aug 2024 13:44:07 +0200 Subject: [PATCH] Check that the MODULE files overrides to the same commits --- tools/update-container-image-versions.sh | 35 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tools/update-container-image-versions.sh b/tools/update-container-image-versions.sh index cf5656f..c06ad23 100755 --- a/tools/update-container-image-versions.sh +++ b/tools/update-container-image-versions.sh @@ -2,9 +2,9 @@ set -eu -o pipefail -E -# Updates the image version in the Docker Compose and Kubernetes deployments. +# # Updates the image version in the Docker Compose and Kubernetes deployments. # -# Run this script as soon as go.mod has been updated. +# Run this script after updating go.mod # # The image versions are extracted from `go.mod`, with the date field # and a hash truncated to seven characters. @@ -59,12 +59,37 @@ actions_summary_page() { echo "$res" } +check_module_overrides() { + # # Check that the git overrides in MODULE.bazel use the expected versions. + # We expect the following stanza: + # + # git_override( + # module_name = "com_github_buildbarn_bb_storage", + # commit = "3f5e30c53d7b52036eb758a63bc98e706f5d4d5c", + # remote = "https://github.com/buildbarn/bb-storage.git", + # ) + + repo="$1"; shift + + commit_hash=$(get_full_git_commit_hash "$repo") + remote=https://github.com/buildbarn/"$repo".git + + override_stanza="$(grep -B3 -A1 "$remote" MODULE.bazel)" + echo "$override_stanza" | grep -q "$commit_hash" || { + echo >&2 "Error: Did not find the expected module version override for $repo." + echo "Found: $override_stanza" + echo "Expected: commit = \"$commit_hash\"," + exit 1 + } +} + update_image_version() { repo="$1"; shift image_name="$1"; shift image_version=$(get_image_version "$repo") - timestamp=$(echo "$image_version" | sed 's#\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)T\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)Z.*#\1-\2-\3 \4:\5:\6#') + timestamp=$(echo "$image_version" \ + | sed 's#\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)T\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)Z.*#\1-\2-\3 \4:\5:\6#') commit_hash=$(get_full_git_commit_hash "$repo") short_commit_hash="${commit_hash:0:10}" checks_url="https://github.com/buildbarn/$repo/commit/$commit_hash/checks" @@ -89,3 +114,7 @@ update_image_version bb-remote-execution bb-runner-installer update_image_version bb-remote-execution bb-scheduler update_image_version bb-remote-execution bb-worker update_image_version bb-storage bb-storage + +check_module_overrides bb-browser +check_module_overrides bb-storage +check_module_overrides bb-remote-execution