From 68dee6f0f2d38d7aadc2c674ccf5e65d202bdff7 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 9 Jun 2026 20:22:18 +0000 Subject: [PATCH] ci: delegate Bazel launches to shared wrapper --- .github/scripts/run_bazel_ci.py | 11 +++-------- .github/scripts/run_bazel_query_ci.py | 4 ++-- .github/scripts/run_bazel_with_buildbuddy.py | 4 ++++ .github/scripts/test_run_bazel_ci.py | 6 +++--- .github/scripts/test_run_bazel_query_ci.py | 8 +++----- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/scripts/run_bazel_ci.py b/.github/scripts/run_bazel_ci.py index d7e4531188..e9a48ee3bf 100755 --- a/.github/scripts/run_bazel_ci.py +++ b/.github/scripts/run_bazel_ci.py @@ -16,7 +16,7 @@ from tempfile import NamedTemporaryFile from typing import TextIO sys.path.insert(0, str(Path(__file__).resolve().parent)) -from run_bazel_with_buildbuddy import bazel_command +from run_bazel_with_buildbuddy import buildbuddy_wrapper_command USAGE = ( @@ -198,13 +198,12 @@ def build_invocation( startup_args = [] if output_user_root := env.get("BAZEL_OUTPUT_USER_ROOT"): startup_args.append(f"--output_user_root={output_user_root}") - command = bazel_command( + command = buildbuddy_wrapper_command( *startup_args, "--noexperimental_remote_repo_contents_cache", *run_args, "--", *targets, - env=env, ) child_env = dict(env) if env.get("RUNNER_OS") == "Windows": @@ -308,14 +307,10 @@ def bazel_testlogs_dir(invocation: Invocation) -> Path: for arg in invocation.post_config_args if arg.startswith(INFO_POST_CONFIG_PREFIXES) ) - command = bazel_command( - *( - [arg for arg in invocation.command[1:] if arg.startswith("--output_user_root=")] - ), + command = buildbuddy_wrapper_command( "--noexperimental_remote_repo_contents_cache", *info_args, "bazel-testlogs", - env=invocation.child_env, ) result = subprocess.run( command, diff --git a/.github/scripts/run_bazel_query_ci.py b/.github/scripts/run_bazel_query_ci.py index 2f88edc77f..034080d5ea 100755 --- a/.github/scripts/run_bazel_query_ci.py +++ b/.github/scripts/run_bazel_query_ci.py @@ -10,7 +10,7 @@ from collections.abc import Sequence from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) -from run_bazel_with_buildbuddy import bazel_command +from run_bazel_with_buildbuddy import buildbuddy_wrapper_command USAGE = "Usage: run_bazel_query_ci.py [...] -- " @@ -28,7 +28,7 @@ def query_command(args: Sequence[str], env: Mapping[str, str]) -> list[str]: query_args.extend(args[:-2]) query_args.append(args[-1]) - return bazel_command(*query_args, env=env) + return buildbuddy_wrapper_command(*query_args) def main(argv: Sequence[str] | None = None, env: Mapping[str, str] | None = None) -> int: diff --git a/.github/scripts/run_bazel_with_buildbuddy.py b/.github/scripts/run_bazel_with_buildbuddy.py index 4503b4fda3..4ae6d93cdb 100755 --- a/.github/scripts/run_bazel_with_buildbuddy.py +++ b/.github/scripts/run_bazel_with_buildbuddy.py @@ -158,6 +158,10 @@ def bazel_command(*args: str, env: Mapping[str, str] | None = None) -> list[str] return [bazel, *startup_args(args, env), *bazel_args_with_remote_config(args, env)] +def buildbuddy_wrapper_command(*args: str) -> list[str]: + return [sys.executable, str(Path(__file__).resolve()), *args] + + def main() -> None: config = remote_config(sys.argv[1:], os.environ) if config is None: diff --git a/.github/scripts/test_run_bazel_ci.py b/.github/scripts/test_run_bazel_ci.py index e8ea2be770..3e4fea4f03 100644 --- a/.github/scripts/test_run_bazel_ci.py +++ b/.github/scripts/test_run_bazel_ci.py @@ -13,6 +13,7 @@ from tempfile import TemporaryDirectory from unittest.mock import patch import run_bazel_ci +import run_bazel_with_buildbuddy class RunBazelCiTest(unittest.TestCase): @@ -56,12 +57,11 @@ class RunBazelCiTest(unittest.TestCase): self.assertEqual( invocation.command, [ - "fake-bazel", + sys.executable, + str(Path(run_bazel_with_buildbuddy.__file__).resolve()), "--output_user_root=/tmp/output", "--noexperimental_remote_repo_contents_cache", "test", - "--config=buildbuddy-generic-rbe", - "--remote_header=x-buildbuddy-api-key=token", "--keep_going", "--config=ci-linux", "--remote_download_toplevel", diff --git a/.github/scripts/test_run_bazel_query_ci.py b/.github/scripts/test_run_bazel_query_ci.py index 8433e9bc3d..e2cf9f76cd 100644 --- a/.github/scripts/test_run_bazel_query_ci.py +++ b/.github/scripts/test_run_bazel_query_ci.py @@ -10,6 +10,7 @@ from pathlib import Path from tempfile import TemporaryDirectory import run_bazel_query_ci +import run_bazel_with_buildbuddy class RunBazelQueryCiTest(unittest.TestCase): @@ -29,12 +30,9 @@ class RunBazelQueryCiTest(unittest.TestCase): }, ), [ - "fake-bazel", - "--output_user_root=/tmp/output", - "--noexperimental_remote_repo_contents_cache", + sys.executable, + str(Path(run_bazel_with_buildbuddy.__file__).resolve()), "query", - "--config=buildbuddy-generic", - "--remote_header=x-buildbuddy-api-key=token", "--repo_contents_cache=/tmp/contents", "--repository_cache=/tmp/repository", "--keep_going",