From cc1f3a9e900ea4d30c7de5abb7c84d3440d53ad3 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 --- MODULE.bazel.lock | 8 +++--- tools/update-container-image-versions.sh | 35 ++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index f293706..00fbead 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -115,8 +115,8 @@ "https://bcr.bazel.build/modules/rules_java/6.4.0/MODULE.bazel": "e986a9fe25aeaa84ac17ca093ef13a4637f6107375f64667a15999f77db6c8f6", "https://bcr.bazel.build/modules/rules_java/7.3.2/MODULE.bazel": "50dece891cfdf1741ea230d001aa9c14398062f2b7c066470accace78e412bc2", "https://bcr.bazel.build/modules/rules_java/7.5.0/MODULE.bazel": "b329bf9aa07a58bd1ccb37bfdcd9528acf6f12712efb38c3a8553c2cc2494806", - "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", - "https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", + "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jsonnet/0.5.0/MODULE.bazel": "26a7eb855041ee5168ed179daaaf8c5bffdb8ac3340de8fe61850d6ceecd7297", "https://bcr.bazel.build/modules/rules_jsonnet/0.6.0/MODULE.bazel": "66300179fdccc4abbb472f1a99ac03fd745fd67515a14c05abbf77fc09416de4", "https://bcr.bazel.build/modules/rules_jsonnet/0.6.0/source.json": "d1783eeaeea5329dd5a8e890bcbda93001d62f9936c15ffce6cdc51828bfd6ba", @@ -168,8 +168,8 @@ "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", "https://bcr.bazel.build/modules/zlib/1.2.13/MODULE.bazel": "aa6deb1b83c18ffecd940c4119aff9567cd0a671d7bba756741cb2ef043a29d5", - "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", - "https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c" + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" }, "selectedYankedVersions": {}, "moduleExtensions": { 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