From 3c4a227a20c73111a8454b002d92cfa7ac9b5b22 Mon Sep 17 00:00:00 2001 From: jjudd Date: Tue, 29 Oct 2024 12:40:51 -0600 Subject: [PATCH] Use Bazelisk and update to Bazel 7.4.0 --- .bazelrc | 3 +- .bazelrc_shared | 15 +----- .bazelversion | 1 + .github/workflows/ci.yml | 5 +- MODULE.bazel.lock | 20 ++++---- rules/scala/workspace.bzl | 2 +- scripts/ci.sh | 2 - scripts/format.sh | 2 - scripts/prepare-path.sh | 38 -------------- scripts/test.sh | 2 - tests/MODULE.bazel.lock | 20 ++++---- tools/bazel | 103 -------------------------------------- 12 files changed, 29 insertions(+), 184 deletions(-) create mode 100644 .bazelversion delete mode 100755 scripts/prepare-path.sh delete mode 100755 tools/bazel diff --git a/.bazelrc b/.bazelrc index e9f3c16b1..c5a9b752a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,2 @@ -common --config=rules -common:v7.2 --config=rules_v7.2 +common --config=rules import %workspace%/.bazelrc_shared diff --git a/.bazelrc_shared b/.bazelrc_shared index 057b8e954..101042930 100644 --- a/.bazelrc_shared +++ b/.bazelrc_shared @@ -20,16 +20,5 @@ build --verbose_failures test --test_output=all -build:rules --disk_cache=.bazel_cache -build:tests --disk_cache=../.bazel_cache - -common:rules_v7.2 --config=noop - -# route potentially unrouted configs to a terminating noop config -# it's a noop because we use the default value -common:rules --config=noop -common:tests --config=noop -common:v7.2 --config=rules_v7.2 - -# pick something trivial as a "noop" -common:noop --logging=3 +common:rules --disk_cache=.bazel_cache +common:tests --disk_cache=../.bazel_cache diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..ba7f754d0 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.4.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff7775403..abbd86319 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-24.04] - bazel_version: [7.2.0] + bazel_version: [bazelbuild/7.4.0] steps: - uses: actions/checkout@v3 + - uses: bazel-contrib/setup-bazel@0.9.0 + with: + bazelisk-version: 1.22.1 - run: ./scripts/ci.sh build - run: ./scripts/ci.sh lint - run: ./scripts/ci.sh test diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index f5cd53106..d62a47c0f 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -34,8 +34,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", - "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_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", @@ -56,27 +56,27 @@ "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", "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.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": { "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { "bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=", - "usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=", + "usagesDigest": "+hz7IHWN6A1oVJJWNDB6yZRG+RYhF76wAYItpAeIUIg=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { - "local_config_apple_cc": { + "local_config_apple_cc_toolchains": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf", + "ruleClassName": "_apple_cc_autoconf_toolchains", "attributes": {} }, - "local_config_apple_cc_toolchains": { + "local_config_apple_cc": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf_toolchains", + "ruleClassName": "_apple_cc_autoconf", "attributes": {} } }, @@ -92,7 +92,7 @@ "@@platforms//host:extension.bzl%host_platform": { "general": { "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", + "usagesDigest": "pCYpDQmqMbmiiPI1p2Kd3VLm5T48rRAht5WdW0X2GlA=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, diff --git a/rules/scala/workspace.bzl b/rules/scala/workspace.bzl index 71a40a4cf..3d4bc75b0 100644 --- a/rules/scala/workspace.bzl +++ b/rules/scala/workspace.bzl @@ -50,7 +50,7 @@ def scala_artifacts(): ] def scala_repositories( - java_launcher_version = "7.2.0", + java_launcher_version = "7.4.0", java_launcher_template_sha = "ee4aa47ae5e639632c67be5cc0ccbc4e941a67a1b884a1ce0c4329357a4b62b2"): maven_install( name = "annex", diff --git a/scripts/ci.sh b/scripts/ci.sh index efb98d2f9..c58d1aba1 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -7,8 +7,6 @@ set -eox pipefail cd "$(dirname "$0")/.." -. ./scripts/prepare-path.sh --force - case "$1" in "build") diff --git a/scripts/format.sh b/scripts/format.sh index 93f841820..1bfa1267f 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -7,8 +7,6 @@ set -o pipefail cd "$(dirname "$0")/.." -. ./scripts/prepare-path.sh --force - if [ "$1" != check ]; then bazel build $(bazel query 'kind("scala_format_test", //...)') bazel query 'kind("scala_format_test", //...)' --output package | while read package; do bazel-bin/"$package"/*-format .; done diff --git a/scripts/prepare-path.sh b/scripts/prepare-path.sh deleted file mode 100755 index 2a0b02639..000000000 --- a/scripts/prepare-path.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -e - -# -# Ensures that the 'bazel' launcher command is on the current path, creating -# a very trivial one that forwards to ./tools/bazel if needed. -# - -set -o pipefail -cd "$(dirname "$0")/.." - -if [[ ! -z "$__ALREADY_PREPARED_BAZEL_PATH" ]]; then - echo "prepare-path: bazel already prepared" -elif ([ "$1" = "--force" ] || ! hash bazel >/dev/null 2>&1); then - echo 'prepare-path: creating one-off bazel launcher' - path_entry=$(mktemp -d) - runner="$path_entry/bazel" - cat > "$runner" <<'EOF' -#!/bin/bash -find_workspace() { - if [ ! -f WORKSPACE ]; then - cd .. - find_workspace - fi -} -workspace=$(find_workspace; pwd) -# use parent workspace, if needed -if ! [ -f "$workspace/tools/bazel" ]; then - workspace=$(cd $workspace/..; find_workspace; pwd) -fi -(>&2 echo :: exec "$workspace/tools/bazel" "$@") -exec "$workspace/tools/bazel" "$@" -EOF - chmod +x "$runner" - export __ALREADY_PREPARED_BAZEL_PATH=1 - export PATH=$path_entry:$PATH -else - echo 'prepare-path: using host bazel launcher' -fi diff --git a/scripts/test.sh b/scripts/test.sh index e339a8352..3f4512c07 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -7,8 +7,6 @@ set -o pipefail cd "$(dirname "$0")/.." -. ./scripts/prepare-path.sh --force - find tests -name test -type f | sort | while read f; do echo running ${f#"tests/"}... output=$($f 2>&1) || ( echo "$output" && exit 1 ) diff --git a/tests/MODULE.bazel.lock b/tests/MODULE.bazel.lock index f5cd53106..d62a47c0f 100644 --- a/tests/MODULE.bazel.lock +++ b/tests/MODULE.bazel.lock @@ -34,8 +34,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", - "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_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", @@ -56,27 +56,27 @@ "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", "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.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": { "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { "bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=", - "usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=", + "usagesDigest": "+hz7IHWN6A1oVJJWNDB6yZRG+RYhF76wAYItpAeIUIg=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { - "local_config_apple_cc": { + "local_config_apple_cc_toolchains": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf", + "ruleClassName": "_apple_cc_autoconf_toolchains", "attributes": {} }, - "local_config_apple_cc_toolchains": { + "local_config_apple_cc": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf_toolchains", + "ruleClassName": "_apple_cc_autoconf", "attributes": {} } }, @@ -92,7 +92,7 @@ "@@platforms//host:extension.bzl%host_platform": { "general": { "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", + "usagesDigest": "pCYpDQmqMbmiiPI1p2Kd3VLm5T48rRAht5WdW0X2GlA=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, diff --git a/tools/bazel b/tools/bazel deleted file mode 100755 index bacb7e487..000000000 --- a/tools/bazel +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -e - -abs_path() { - perl -MCwd -le ' - for (@ARGV) { - if ($p = Cwd::abs_path $_) { - print $p; - } else { - warn "abs_path: $_: $!\n"; - $ret = 1; - } - } - exit $ret' "$@" -} -workspace=$(cd $(dirname "$0")/..; pwd) -root_workspace=$(cd $(dirname $(abs_path "$0"))/..; pwd) - -default_bazel_version='7.2.0' - -if [ -z "$BAZEL_VERSION" ]; then - bazel_version="$default_bazel_version" -else - bazel_version="$BAZEL_VERSION" -fi - -# SHA comes from `bazel--installer--x86_64.sh.sha256` on https://github.com/bazelbuild/bazel/releases -case "$bazel_version" in - 'host') - bazel_version=$("$BAZEL_REAL" version | awk '/Build label/ {print $3}' | cut -d '-' -f 1) - bazel="$BAZEL_REAL" - ;; - '7.2.0') - linux_sha='63434c9d4d352e829d89180a08e04f0e71cca68daf27c382d6f40fa50c48de6a' - ;; - *) - echo "The requested Bazel version '$bazel_version' is not supported" - exit 1 - ;; -esac - -if [ -z "$bazel" ]; then - bazel_bin_loc=~/.bazel_binaries - mkdir -p $bazel_bin_loc - bazel=$bazel_bin_loc/$bazel_version/bin/bazel-real -fi - -if ! [ -f "$bazel" ]; then - case $(uname -s) in - Linux) - platform='linux' - sha=$linux_sha - ;; - *) - echo 'Your OS is not supported.' - exit 1 - ;; - esac - remote_source=https://github.com/bazelbuild/bazel/releases/download - installer_name="bazel-$bazel_version-installer-$platform-x86_64.sh" - url="$remote_source/$bazel_version/$installer_name" - ( - tmp_dir=$(mktemp -d) - trap "rm -rf $tmp_dir" EXIT - cd $tmp_dir - (>&2 echo "downloading installer from") - (>&2 echo "$url") - curl -o installer.sh -L $url - generated_sha=$(shasum -a 256 installer.sh | awk '{print $1}') - if [ "$generated_sha" != "$sha" ]; then - echo "Sha 256 does not match, expected: $sha" - echo "But found $generated_sha" - echo "Recommend you: update the sha to the expected" - echo "and then re-run this script" - exit 1 - fi - chmod +x installer.sh - ./installer.sh --base=$bazel_bin_loc/$bazel_version --bin=$bazel_bin_loc/$bazel_version/bin_t - ) -fi - -extra_command_args=() - -IFS=. read -r major minor patch < <(echo "$bazel_version") -extra_command_args+=("--config=v$major.$minor") - -for (( i=1; i<=$#; i++ )) -do - case "${!i}" in - -*) - ;; - *) - n=$(($i + 1)) - set -- "${@:1:$i}" "${extra_command_args[@]}" "${@:$n}" - break - ;; - esac -done - -disk_cache="$root_workspace"/.bazel_cache -mkdir -p "$disk_cache" - -(>&2 echo :: exec "$bazel" "$@") -exec "$bazel" "$@"