Skip to content

Commit

Permalink
Run bazel 8.0.0 and retry in case of failure
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy committed Dec 20, 2024
1 parent 5d2adac commit 9645d00
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions buildkite/bazelci.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,9 @@ def PrepareRepoInCwd(print_cmd_groups, initial_setup=False):

# Dirty workaround for #1660
if initial_setup:
# Run `bazel --version` to make sure Bazel is fetched.
run_bazel_version(bazel_binary)

# Set OUTPUT_BASE environment variable
os.environ["OUTPUT_BASE"] = get_output_base(bazel_binary)

Expand Down Expand Up @@ -1979,6 +1982,18 @@ def rbe_flags(original_flags, accept_cached):
return flags


def run_bazel_version(bazel_binary, max_retry=5):
"""Run `bazel --version` to make sure Bazel is fetched by Bazelisk."""
# Retry to address https://github.com/bazelbuild/continuous-integration/issues/2123
retry = 0
while retry < max_retry:
exit_code = execute_command([bazel_binary, "--version"])
if exit_code == 0:
return
retry += 1
time.sleep(1)


def get_output_base(bazel_binary):
return execute_command_and_get_output(
[bazel_binary] + common_startup_flags() + ["info", "output_base"],
Expand Down

0 comments on commit 9645d00

Please sign in to comment.