Skip to content

Commit

Permalink
Check that the MODULE files overrides to the same commits
Browse files Browse the repository at this point in the history
  • Loading branch information
stagnation authored and moroten committed Aug 19, 2024
1 parent dc02863 commit cc1f3a9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
8 changes: 4 additions & 4 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 32 additions & 3 deletions tools/update-container-image-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand All @@ -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

0 comments on commit cc1f3a9

Please sign in to comment.