mirror of
https://github.com/openai/codex.git
synced 2026-10-31 19:28:49 +00:00
ci: generalize Windows hybrid execution
This commit is contained in:
@@ -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[@]}" \
|
||||
|
||||
@@ -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] -- <bazel args> -- <targets>" >&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] -- <bazel args> -- <targets>" >&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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user