mirror of
https://github.com/openai/codex.git
synced 2026-04-30 19:32:04 +03:00
## Why A rerun of the Windows Bazel clippy job after [#19161](https://github.com/openai/codex/pull/19161) had exactly the cache behavior we wanted in BuildBuddy: zero action-cache misses. Even so, the GitHub job still took a little over five minutes. The problem was that the job was paying for two separate Bazel startup paths: 1. a `bazel query` to discover extra lint targets 2. the real `bazel build --config=clippy ...` invocation On Windows, that query was bypassing the CI Bazel wrapper, so it did not reuse the same `--output_user_root`, CI config, or remote-cache setup as the real build. In practice that meant the rerun could still cold-start a separate Bazel server before the actual clippy build even began. ## What - add `.github/scripts/run-bazel-query-ci.sh` to run CI-side Bazel queries with the same startup and cache-related flags as the main Bazel command - switch `scripts/list-bazel-clippy-targets.sh` to use that helper for manual `rust_test` target discovery - switch `tools/argument-comment-lint/list-bazel-targets.sh` to use the same helper - simplify `.github/scripts/run-argument-comment-lint-bazel.sh` so its Windows-only query path also goes through the shared helper This keeps the target-discovery queries aligned with the later build/test invocation instead of treating them as a separate cold Bazel session. ## Verification - `bash -n .github/scripts/run-bazel-query-ci.sh` - `bash -n scripts/list-bazel-clippy-targets.sh` - `bash -n tools/argument-comment-lint/list-bazel-targets.sh` - `bash -n .github/scripts/run-argument-comment-lint-bazel.sh` - mocked a Windows invocation of `run-bazel-query-ci.sh` and verified it forwards `--output_user_root`, `--config=ci-windows`, the BuildBuddy auth header, and the repository cache flags ## Docs No documentation updates are needed.
81 lines
2.7 KiB
Bash
Executable File
81 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
bazel_lint_args=("$@")
|
|
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
|
has_host_platform_override=0
|
|
for arg in "${bazel_lint_args[@]}"; do
|
|
if [[ "$arg" == --host_platform=* ]]; then
|
|
has_host_platform_override=1
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ $has_host_platform_override -eq 0 ]]; then
|
|
# The nightly Windows lint toolchain is registered with an MSVC exec
|
|
# platform even though the lint target platform stays on `windows-gnullvm`.
|
|
# Override the host platform here so the exec-side helper binaries actually
|
|
# match the registered toolchain set.
|
|
bazel_lint_args+=("--host_platform=//:local_windows_msvc")
|
|
fi
|
|
|
|
# Native Windows lint runs need exec-side Rust helper binaries and proc-macros
|
|
# to use rust-lld instead of the C++ linker path. The default `none`
|
|
# preference resolves to `cc` when a cc_toolchain is present, which currently
|
|
# routes these exec actions through clang++ with an argument shape it cannot
|
|
# consume.
|
|
bazel_lint_args+=("--@rules_rust//rust/settings:toolchain_linker_preference=rust")
|
|
|
|
# Some Rust top-level targets are still intentionally incompatible with the
|
|
# local Windows MSVC exec platform. Skip those explicit targets so the native
|
|
# lint aspect can run across the compatible crate graph instead of failing the
|
|
# whole build after analysis.
|
|
bazel_lint_args+=("--skip_incompatible_explicit_targets")
|
|
fi
|
|
|
|
read_query_labels() {
|
|
local query="$1"
|
|
local query_stdout
|
|
local query_stderr
|
|
query_stdout="$(mktemp)"
|
|
query_stderr="$(mktemp)"
|
|
|
|
if ! ./.github/scripts/run-bazel-query-ci.sh \
|
|
--keep_going \
|
|
--output=label \
|
|
-- "$query" >"$query_stdout" 2>"$query_stderr"; then
|
|
cat "$query_stderr" >&2
|
|
rm -f "$query_stdout" "$query_stderr"
|
|
exit 1
|
|
fi
|
|
|
|
cat "$query_stdout"
|
|
rm -f "$query_stdout" "$query_stderr"
|
|
}
|
|
|
|
final_build_targets=(//codex-rs/...)
|
|
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
|
# 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
|
|
# non-test code while avoiding non-Rust wrapper targets such as platform_data.
|
|
final_build_targets=()
|
|
while IFS= read -r label; do
|
|
[[ -n "$label" ]] || continue
|
|
final_build_targets+=("$label")
|
|
done < <(read_query_labels 'kind("rust_(library|binary|proc_macro) rule", //codex-rs/...)')
|
|
|
|
if [[ ${#final_build_targets[@]} -eq 0 ]]; then
|
|
echo "Failed to discover Windows Bazel lint targets." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
./.github/scripts/run-bazel-ci.sh \
|
|
-- \
|
|
build \
|
|
"${bazel_lint_args[@]}" \
|
|
-- \
|
|
"${final_build_targets[@]}"
|