From b8972c1c39d4b34cb5f93a9a5f644302172f8213 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Sat, 28 Mar 2026 11:16:49 -0700 Subject: [PATCH] ci: run Windows argument-comment-lint via native Bazel --- .github/actions/setup-bazel-ci/action.yml | 9 ++++++++- .github/scripts/run-bazel-ci.sh | 11 +++++++++++ .github/workflows/rust-ci-full.yml | 2 ++ .github/workflows/rust-ci.yml | 16 ---------------- MODULE.bazel | 1 + patches/rules_rust_windows_nightly_gnu.patch | 20 ++++++++++++++++++++ 6 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 patches/rules_rust_windows_nightly_gnu.patch diff --git a/.github/actions/setup-bazel-ci/action.yml b/.github/actions/setup-bazel-ci/action.yml index 34bbd40b19..f7b1ffaa59 100644 --- a/.github/actions/setup-bazel-ci/action.yml +++ b/.github/actions/setup-bazel-ci/action.yml @@ -60,8 +60,15 @@ runs: # Use the shortest available drive to reduce argv/path length issues, # but avoid the drive root because some Windows test launchers mis-handle # MANIFEST paths there. - $bazelOutputUserRoot = if (Test-Path 'D:\') { 'D:\b' } else { 'C:\b' } + $hasDDrive = Test-Path 'D:\' + $bazelOutputUserRoot = if ($hasDDrive) { 'D:\b' } else { 'C:\b' } + $repoContentsCache = Join-Path $env:RUNNER_TEMP "bazel-repo-contents-cache-$env:GITHUB_RUN_ID-$env:GITHUB_JOB" "BAZEL_OUTPUT_USER_ROOT=$bazelOutputUserRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + "BAZEL_REPO_CONTENTS_CACHE=$repoContentsCache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + if (-not $hasDDrive) { + $repositoryCache = Join-Path $env:USERPROFILE '.cache\bazel-repo-cache' + "BAZEL_REPOSITORY_CACHE=$repositoryCache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + } - name: Enable Git long paths (Windows) if: runner.os == 'Windows' diff --git a/.github/scripts/run-bazel-ci.sh b/.github/scripts/run-bazel-ci.sh index cf50135c2e..47e7088d55 100755 --- a/.github/scripts/run-bazel-ci.sh +++ b/.github/scripts/run-bazel-ci.sh @@ -126,6 +126,17 @@ if [[ $remote_download_toplevel -eq 1 ]]; then post_config_bazel_args+=(--remote_download_toplevel) fi +if [[ -n "${BAZEL_REPO_CONTENTS_CACHE:-}" ]]; then + # Windows self-hosted runners can run multiple Bazel jobs concurrently. Give + # each job its own repo contents cache so they do not fight over the shared + # path configured in `ci-windows`. + post_config_bazel_args+=("--repo_contents_cache=${BAZEL_REPO_CONTENTS_CACHE}") +fi + +if [[ -n "${BAZEL_REPOSITORY_CACHE:-}" ]]; then + post_config_bazel_args+=("--repository_cache=${BAZEL_REPOSITORY_CACHE}") +fi + bazel_console_log="$(mktemp)" trap 'rm -f "$bazel_console_log"' EXIT diff --git a/.github/workflows/rust-ci-full.yml b/.github/workflows/rust-ci-full.yml index 9480c05379..d576ff26c9 100644 --- a/.github/workflows/rust-ci-full.yml +++ b/.github/workflows/rust-ci-full.yml @@ -100,6 +100,8 @@ jobs: sudo DEBIAN_FRONTEND=noninteractive apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends pkg-config libcap-dev - name: Run argument comment lint on codex-rs via Bazel + env: + BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} shell: bash run: | ./.github/scripts/run-bazel-ci.sh \ diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index a655b3071e..e255b42091 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -159,19 +159,7 @@ jobs: run: | sudo DEBIAN_FRONTEND=noninteractive apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends pkg-config libcap-dev - - name: Install nightly argument-comment-lint toolchain - if: ${{ runner.os == 'Windows' }} - shell: bash - run: | - rustup toolchain install nightly-2025-09-18 \ - --profile minimal \ - --component llvm-tools-preview \ - --component rustc-dev \ - --component rust-src \ - --no-self-update - rustup default nightly-2025-09-18 - name: Run argument comment lint on codex-rs via Bazel - if: ${{ runner.os != 'Windows' }} env: BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} shell: bash @@ -184,10 +172,6 @@ jobs: --build_metadata=COMMIT_SHA=${GITHUB_SHA} \ -- \ //codex-rs/... - - name: Run argument comment lint on codex-rs via packaged wrapper - if: ${{ runner.os == 'Windows' }} - shell: bash - run: python3 ./tools/argument-comment-lint/run-prebuilt-linter.py # --- Gatherer job that you mark as the ONLY required status ----------------- results: diff --git a/MODULE.bazel b/MODULE.bazel index 8163c0b018..3ac8e502fe 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -82,6 +82,7 @@ rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_r rules_rust.patch( patches = [ "//patches:rules_rust_windows_gnullvm_build_script.patch", + "//patches:rules_rust_windows_nightly_gnu.patch", ], strip = 1, ) diff --git a/patches/rules_rust_windows_nightly_gnu.patch b/patches/rules_rust_windows_nightly_gnu.patch new file mode 100644 index 0000000000..97bd540353 --- /dev/null +++ b/patches/rules_rust_windows_nightly_gnu.patch @@ -0,0 +1,20 @@ +# What: make the default rules_rust Windows nightly toolchain use GNU, not MSVC. +# Why: codex's Bazel Windows platform is based on llvm-mingw/gnullvm, and the +# nightly rustc-dev artifacts that power argument-comment-lint do not exist for +# gnullvm. Using the default MSVC nightly toolchain on that platform mixes MSVC +# Rust libraries with GNU/clang linker flags and breaks tool targets such as +# `process_wrapper`. + +diff --git a/rust/repositories.bzl b/rust/repositories.bzl +--- a/rust/repositories.bzl ++++ b/rust/repositories.bzl +@@ -48,8 +48,8 @@ DEFAULT_TOOLCHAIN_TRIPLES = { + "aarch64-unknown-linux-gnu": "rust_linux_aarch64", + "powerpc64le-unknown-linux-gnu": "rust_linux_powerpc64le", + "s390x-unknown-linux-gnu": "rust_linux_s390x", + "x86_64-apple-darwin": "rust_macos_x86_64", +- "x86_64-pc-windows-msvc": "rust_windows_x86_64", ++ "x86_64-pc-windows-gnu": "rust_windows_x86_64", + "x86_64-unknown-freebsd": "rust_freebsd_x86_64", + "x86_64-unknown-linux-gnu": "rust_linux_x86_64", + }