Skip to content

Commit

Permalink
Bazel bootstrap: use MODULE.bazel to get the version
Browse files Browse the repository at this point in the history
This is more reliable than parsing CHANGELOG.md, which is not always the latest.

This requires us to maintain the Bazel version number in MODULE.bazel, which should be updated once a year on the master branch, but every time we do a minor/patch release.

PiperOrigin-RevId: 695747413
Change-Id: I63d572445d8cb6a76a3e079c2ea6f083257216b0
  • Loading branch information
meteorcloudy authored and copybara-github committed Nov 12, 2024
1 parent a1af43c commit 24ada2c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

module(
name = "bazel",
version = "9.0.0-prerelease",
repo_name = "io_bazel",
)

Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

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

5 changes: 2 additions & 3 deletions scripts/bootstrap/buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,8 @@ function git_date() {
# Get the latest release version and append the date of
# the last commit if any.
function get_last_version() {
if [ -f "CHANGELOG.md" ]; then
local version="$(fgrep -m 1 '## Release' CHANGELOG.md \
| sed -E 's|.*Release (.*) \(.*\)|\1|')"
if [ -f "MODULE.bazel" ]; then
local version=$(grep "version =" MODULE.bazel | head -n 1 | sed 's/.*version = "\(.*\)".*/\1/' | cut -d '"' -f2)
else
local version=""
fi
Expand Down
17 changes: 8 additions & 9 deletions src/test/shell/bazel/bazel_bootstrap_distfile_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,14 @@ default_java_toolchain(
)
EOF

# TODO(pcloudy): Uncomment this once the bootstrap test is fixed.
# ./output/bazel \
# --server_javabase=$JAVABASE --host_jvm_args=--add-opens=java.base/java.nio=ALL-UNNAMED \
# build --nobuild --repository_cache=derived/repository_cache \
# --override_repository=$(cat derived/maven/MAVEN_CANONICAL_REPO_NAME)=derived/maven \
# --java_language_version=${JAVA_VERSION} --tool_java_language_version=${JAVA_VERSION} \
# --tool_java_runtime_version=local_jdk \
# --extra_toolchains=fake_java_toolchain:all \
# src:bazel_nojdk &> "${TEST_log}" || fail "analysis with bootstrapped Bazel failed"
./output/bazel \
--server_javabase=$JAVABASE --host_jvm_args=--add-opens=java.base/java.nio=ALL-UNNAMED \
build --nobuild --repository_cache=derived/repository_cache \
--override_repository=$(cat derived/maven/MAVEN_CANONICAL_REPO_NAME)=derived/maven \
--java_language_version=${JAVA_VERSION} --tool_java_language_version=${JAVA_VERSION} \
--tool_java_runtime_version=local_jdk \
--extra_toolchains=fake_java_toolchain:all \
src:bazel_nojdk &> "${TEST_log}" || fail "analysis with bootstrapped Bazel failed"
}

run_suite "bootstrap test"

0 comments on commit 24ada2c

Please sign in to comment.