From df81e569e1a1a77055a911fc6238f5c547f8a8ca Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Mon, 22 Jun 2026 19:07:11 +0000 Subject: [PATCH] ci: generalize Windows hybrid execution --- .bazelrc | 12 ++++---- .../run-argument-comment-lint-bazel.sh | 4 +++ .github/scripts/run-bazel-ci.sh | 29 ++++++++++--------- .github/scripts/run_bazel_with_buildbuddy.py | 2 +- .../scripts/test_run_bazel_with_buildbuddy.py | 11 +++---- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.bazelrc b/.bazelrc index f22ac05518..8814a69ca9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -168,12 +168,12 @@ common:ci-windows --repo_contents_cache=D:/a/.cache/bazel-repo-contents-cache # Prefer RBE for Linux execution platforms, but require every Windows action to # run locally. V8Mksnapshot is currently mis-platformed as Linux even though it # invokes a Windows binary, so keep that narrow mnemonic exception local too. -common:ci-windows-argument-lint --config=ci-windows -common:ci-windows-argument-lint --extra_execution_platforms=//:rbe -common:ci-windows-argument-lint --strategy=remote,local -common:ci-windows-argument-lint --allowed_strategies_by_exec_platform=//:local_windows=local -common:ci-windows-argument-lint --allowed_strategies_by_exec_platform=//:windows_x86_64_gnullvm=local -common:ci-windows-argument-lint --strategy=V8Mksnapshot=local +common:ci-windows-hybrid --config=ci-windows +common:ci-windows-hybrid --extra_execution_platforms=//:rbe +common:ci-windows-hybrid --strategy=remote,local +common:ci-windows-hybrid --allowed_strategies_by_exec_platform=//:local_windows=local +common:ci-windows-hybrid --allowed_strategies_by_exec_platform=//:windows_x86_64_gnullvm=local +common:ci-windows-hybrid --strategy=V8Mksnapshot=local # We prefer to run the build actions entirely remotely so we can dial up the concurrency. # We have platform-specific tests, so we want to execute the tests on all platforms using the strongest sandboxing available on each platform. diff --git a/.github/scripts/run-argument-comment-lint-bazel.sh b/.github/scripts/run-argument-comment-lint-bazel.sh index a79efab820..77293baa6b 100755 --- a/.github/scripts/run-argument-comment-lint-bazel.sh +++ b/.github/scripts/run-argument-comment-lint-bazel.sh @@ -25,7 +25,10 @@ read_query_labels() { } final_build_targets=(//codex-rs/...) +bazel_ci_args=() if [[ "${RUNNER_OS:-}" == "Windows" ]]; then + bazel_ci_args+=(--windows-hybrid-execution) + # Bazel's local Windows platform currently lacks a default test toolchain for # `rust_test`, so target the concrete Rust crate rules directly. The lint # aspect still walks their crate graph, which preserves incremental reuse for @@ -44,6 +47,7 @@ if [[ "${RUNNER_OS:-}" == "Windows" ]]; then fi ./.github/scripts/run-bazel-ci.sh \ + "${bazel_ci_args[@]}" \ -- \ build \ "${bazel_lint_args[@]}" \ diff --git a/.github/scripts/run-bazel-ci.sh b/.github/scripts/run-bazel-ci.sh index 7a3e89ca99..58114a32d6 100755 --- a/.github/scripts/run-bazel-ci.sh +++ b/.github/scripts/run-bazel-ci.sh @@ -7,6 +7,7 @@ print_failed_bazel_action_summary=0 remote_download_toplevel=0 windows_msvc_host_platform=0 windows_cross_compile=0 +windows_hybrid_execution=0 while [[ $# -gt 0 ]]; do case "$1" in @@ -30,6 +31,10 @@ while [[ $# -gt 0 ]]; do windows_cross_compile=1 shift ;; + --windows-hybrid-execution) + windows_hybrid_execution=1 + shift + ;; --) shift break @@ -42,7 +47,12 @@ while [[ $# -gt 0 ]]; do done if [[ $# -eq 0 ]]; then - echo "Usage: $0 [--print-failed-test-logs] [--print-failed-action-summary] [--remote-download-toplevel] [--windows-msvc-host-platform] [--windows-cross-compile] -- -- " >&2 + echo "Usage: $0 [--print-failed-test-logs] [--print-failed-action-summary] [--remote-download-toplevel] [--windows-msvc-host-platform] [--windows-cross-compile] [--windows-hybrid-execution] -- -- " >&2 + exit 1 +fi + +if [[ $windows_cross_compile -eq 1 && $windows_hybrid_execution -eq 1 ]]; then + echo "--windows-cross-compile and --windows-hybrid-execution are mutually exclusive" >&2 exit 1 fi @@ -77,6 +87,8 @@ case "${RUNNER_OS:-}" in Windows) if [[ $windows_cross_compile -eq 1 ]]; then ci_config=ci-windows-cross + elif [[ $windows_hybrid_execution -eq 1 ]]; then + ci_config=ci-windows-hybrid else ci_config=ci-windows fi @@ -255,15 +267,6 @@ if [[ ${#bazel_args[@]} -eq 0 || ${#bazel_targets[@]} -eq 0 ]]; then exit 1 fi -if [[ "${RUNNER_OS:-}" == "Windows" ]]; then - for arg in "${bazel_args[@]}"; do - if [[ "$arg" == "--config=argument-comment-lint" ]]; then - ci_config=ci-windows-argument-lint - break - fi - done -fi - if [[ "${RUNNER_OS:-}" == "Windows" && $windows_cross_compile -eq 1 && -z "${BUILDBUDDY_API_KEY:-}" ]]; then # Windows cross-compilation depends on authenticated RBE. Preserve the local # Windows build shape when credentials are unavailable. @@ -296,7 +299,7 @@ if [[ $remote_download_toplevel -eq 1 ]]; then post_config_bazel_args+=(--remote_download_toplevel) fi -if [[ "${RUNNER_OS:-}" == "Windows" && -n "${BUILDBUDDY_API_KEY:-}" && ( $windows_cross_compile -eq 1 || "$ci_config" == "ci-windows-argument-lint" ) ]]; then +if [[ "${RUNNER_OS:-}" == "Windows" && -n "${BUILDBUDDY_API_KEY:-}" && ( $windows_cross_compile -eq 1 || $windows_hybrid_execution -eq 1 ) ]]; then # Bazel derives the default genrule shell from the client host. Remote Linux # actions must not be asked to run Git Bash from the Windows runner. post_config_bazel_args+=(--shell_executable=/bin/bash) @@ -305,7 +308,7 @@ if [[ "${RUNNER_OS:-}" == "Windows" && -n "${BUILDBUDDY_API_KEY:-}" && ( $window # `--enable_platform_specific_config` expands `common:windows` on Windows # hosts after ordinary rc configs, which can override `ci-windows-cross`'s # RBE host platform. Repeat it on the command line for cross builds. The - # argument-lint lane keeps its gnullvm host platform for local Rust actions. + # Hybrid execution keeps its gnullvm host platform for local Rust actions. post_config_bazel_args+=(--host_platform=//:rbe) fi fi @@ -336,7 +339,7 @@ fi if [[ "${RUNNER_OS:-}" == "Windows" ]]; then pass_windows_build_env=1 - if [[ -n "${BUILDBUDDY_API_KEY:-}" && ( $windows_cross_compile -eq 1 || "$ci_config" == "ci-windows-argument-lint" ) ]]; then + if [[ -n "${BUILDBUDDY_API_KEY:-}" && ( $windows_cross_compile -eq 1 || $windows_hybrid_execution -eq 1 ) ]]; then # Generic build actions execute on Linux RBE workers. Passing the Windows # runner's compiler environment there leaks VS/SDK paths and makes genrules # try to execute tools that do not exist on the worker. diff --git a/.github/scripts/run_bazel_with_buildbuddy.py b/.github/scripts/run_bazel_with_buildbuddy.py index 619ee7acde..dc31237461 100755 --- a/.github/scripts/run_bazel_with_buildbuddy.py +++ b/.github/scripts/run_bazel_with_buildbuddy.py @@ -20,7 +20,7 @@ REMOTE_EXECUTION_CONFIGS = { "--config=ci-linux", "--config=ci-macos", "--config=ci-v8", - "--config=ci-windows-argument-lint", + "--config=ci-windows-hybrid", "--config=ci-windows-cross", } # Honor either explicit setting so the wrapper never overrides the caller's diff --git a/.github/scripts/test_run_bazel_with_buildbuddy.py b/.github/scripts/test_run_bazel_with_buildbuddy.py index 648d4e6261..299fbfc037 100644 --- a/.github/scripts/test_run_bazel_with_buildbuddy.py +++ b/.github/scripts/test_run_bazel_with_buildbuddy.py @@ -98,14 +98,14 @@ class RunBazelWithBuildBuddyTest(unittest.TestCase): ], ) - def test_windows_argument_lint_configuration_uses_remote_execution(self) -> None: + def test_windows_hybrid_configuration_uses_remote_execution(self) -> None: env = {"BUILDBUDDY_API_KEY": "fork-token"} self.assertEqual( run_bazel_with_buildbuddy.bazel_args_with_remote_config( [ "build", - "--config=ci-windows-argument-lint", + "--config=ci-windows-hybrid", "//codex-rs/cli:codex", ], env, @@ -114,12 +114,12 @@ class RunBazelWithBuildBuddyTest(unittest.TestCase): "build", "--config=buildbuddy-generic-rbe", "--remote_header=x-buildbuddy-api-key=fork-token", - "--config=ci-windows-argument-lint", + "--config=ci-windows-hybrid", "//codex-rs/cli:codex", ], ) - def test_windows_argument_lint_separates_remote_build_and_test_environments( + def test_windows_hybrid_execution_separates_build_and_test_environments( self, ) -> None: with TemporaryDirectory() as temp_dir: @@ -168,6 +168,7 @@ class RunBazelWithBuildBuddyTest(unittest.TestCase): [ bash, str(Path(__file__).with_name("run-bazel-ci.sh")), + "--windows-hybrid-execution", "--", "build", "--config=argument-comment-lint", @@ -186,7 +187,7 @@ class RunBazelWithBuildBuddyTest(unittest.TestCase): for line in result.stdout.splitlines() if line.startswith("[") ) - self.assertIn("--config=ci-windows-argument-lint", command) + self.assertIn("--config=ci-windows-hybrid", command) self.assertIn("--shell_executable=/bin/bash", command) self.assertIn("--action_env=PATH=/usr/bin:/bin", command) self.assertIn("--host_action_env=PATH=/usr/bin:/bin", command)