From 0ab76a2f95b16a59a0cfd649f64391c5ee6d7348 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Tue, 25 Jul 2023 15:00:01 +0200 Subject: [PATCH] bazel: update bazel container version on //:tidy Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- bazel/ci/BUILD.bazel | 8 ++++++ bazel/ci/bazel_container.sh.in | 45 ++++++++++++++++++++++++++++++++++ bazel/container/Containerfile | 2 +- bazel/container/container.sh | 2 +- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100755 bazel/ci/bazel_container.sh.in diff --git a/bazel/ci/BUILD.bazel b/bazel/ci/BUILD.bazel index ecd813a21..4a8b9a75a 100644 --- a/bazel/ci/BUILD.bazel +++ b/bazel/ci/BUILD.bazel @@ -434,6 +434,13 @@ repo_command( command = ":com_github_katexochen_ghh", ) +sh_template( + name = "bazel_container", + data = [], + substitutions = {}, + template = "bazel_container.sh.in", +) + multirun( name = "tidy", commands = [ @@ -446,6 +453,7 @@ multirun( ":terraform_fmt", ":buf_fmt", ":deps_mirror_fix", + ":bazel_container", ], jobs = 1, # execute sequentially visibility = ["//visibility:public"], diff --git a/bazel/ci/bazel_container.sh.in b/bazel/ci/bazel_container.sh.in new file mode 100755 index 000000000..b3539e64f --- /dev/null +++ b/bazel/ci/bazel_container.sh.in @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +###### script header ###### + +lib=$(realpath @@BASE_LIB@@) || exit 1 +stat "${lib}" >> /dev/null || exit 1 + +# shellcheck source=../sh/lib.bash +if ! source "${lib}"; then + echo "Error: could not find import" + exit 1 +fi + +cd "${BUILD_WORKSPACE_DIRECTORY}" + +###### script body ###### + +bazelVer=$(cat .bazelversion) # has no v prefix + +bazelVerContainerfileRegex='(ARG BAZEL_VERSION=)([0-9]+\.[0-9]+\.[0-9]+)' +if [[ ! "$(cat bazel/container/Containerfile)" =~ ${bazelVerContainerfileRegex} ]]; then + echo "Error: no match found in Containerfile" + exit 1 +fi + +bazelVerContainerfile="${BASH_REMATCH[2]}" + +if [[ ${bazelVer} != "${bazelVerContainerfile}" ]]; then + sed -r -i "s/${bazelVerContainerfileRegex}/\\1${bazelVer}/" bazel/container/Containerfile + echo "Containerfile updated, was previously at ${bazelVerContainerfile}" +fi + +bazelVerScriptRegex='(containerImage="ghcr.io/edgelesssys/bazel-container:v)([0-9]+\.[0-9]+\.[0-9]+)' +if [[ ! "$(cat bazel/container/container.sh)" =~ ${bazelVerScriptRegex} ]]; then + echo "Error: no match found in container.sh" + exit 1 +fi + +bazelVerScript="${BASH_REMATCH[2]}" + +if [[ ${bazelVer} != "${bazelVerScript}" ]]; then + # bazelVerScriptRegex contains slashes, so use % as delimiter + sed -r -i "s%${bazelVerScriptRegex}%\\1${bazelVer}%" bazel/container/container.sh + echo "container.sh updated, was previously at ${bazelVerScript}" +fi diff --git a/bazel/container/Containerfile b/bazel/container/Containerfile index bb9746482..b15c88a51 100644 --- a/bazel/container/Containerfile +++ b/bazel/container/Containerfile @@ -3,7 +3,7 @@ FROM fedora:38 ARG TARGETOS ARG TARGETARCH -ARG BAZEL_VERSION=6.1.2 +ARG BAZEL_VERSION=6.2.1 ARG BAZELISK_VERSION=v1.16.0 ARG BAZELISK_SHA256=168851e70cf5f95c0e215e7f3aaca5132ffc3c8dd8f585a4157b0be2b53cfe32 diff --git a/bazel/container/container.sh b/bazel/container/container.sh index b97370c90..0ca6e7ded 100644 --- a/bazel/container/container.sh +++ b/bazel/container/container.sh @@ -15,7 +15,7 @@ function setup { } function startBazelServer { - local containerImage="ghcr.io/edgelesssys/bazel-container:v6.1.2-0" + local containerImage="ghcr.io/edgelesssys/bazel-container:v6.2.1-0" local containerName="bazeld" setup