Skip to content

Commit 5495a3f

Browse files
committed
ci: run Windows argument-comment-lint via native Bazel
1 parent 5ffa06b commit 5495a3f

File tree

9 files changed

+122
-15
lines changed

9 files changed

+122
-15
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ build:clippy --@rules_rust//rust/settings:clippy.toml=//codex-rs:clippy.toml
8181
build:argument-comment-lint --aspects=//tools/argument-comment-lint:lint_aspect.bzl%rust_argument_comment_lint_aspect
8282
build:argument-comment-lint --output_groups=argument_comment_lint_checks
8383
build:argument-comment-lint --@rules_rust//rust/toolchain/channel=nightly
84+
# On Windows, exec-side helper binaries such as process_wrapper need to prefer
85+
# rust-lld over the GNU-flavored Bazel C++ linker path.
86+
build:argument-comment-lint-windows --config=argument-comment-lint
87+
build:argument-comment-lint-windows --@rules_rust//rust/settings:toolchain_linker_preference=rust
8488

8589
# Rearrange caches on Windows so they're on the same volume as the checkout.
8690
common:ci-windows --config=ci-bazel

.github/actions/setup-bazel-ci/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,15 @@ runs:
6060
# Use the shortest available drive to reduce argv/path length issues,
6161
# but avoid the drive root because some Windows test launchers mis-handle
6262
# MANIFEST paths there.
63-
$bazelOutputUserRoot = if (Test-Path 'D:\') { 'D:\b' } else { 'C:\b' }
63+
$hasDDrive = Test-Path 'D:\'
64+
$bazelOutputUserRoot = if ($hasDDrive) { 'D:\b' } else { 'C:\b' }
65+
$repoContentsCache = Join-Path $env:RUNNER_TEMP "bazel-repo-contents-cache-$env:GITHUB_RUN_ID-$env:GITHUB_JOB"
6466
"BAZEL_OUTPUT_USER_ROOT=$bazelOutputUserRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
67+
"BAZEL_REPO_CONTENTS_CACHE=$repoContentsCache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
68+
if (-not $hasDDrive) {
69+
$repositoryCache = Join-Path $env:USERPROFILE '.cache\bazel-repo-cache'
70+
"BAZEL_REPOSITORY_CACHE=$repositoryCache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
71+
}
6572
6673
- name: Enable Git long paths (Windows)
6774
if: runner.os == 'Windows'

.github/scripts/run-bazel-ci.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ if [[ $remote_download_toplevel -eq 1 ]]; then
126126
post_config_bazel_args+=(--remote_download_toplevel)
127127
fi
128128

129+
if [[ -n "${BAZEL_REPO_CONTENTS_CACHE:-}" ]]; then
130+
# Windows self-hosted runners can run multiple Bazel jobs concurrently. Give
131+
# each job its own repo contents cache so they do not fight over the shared
132+
# path configured in `ci-windows`.
133+
post_config_bazel_args+=("--repo_contents_cache=${BAZEL_REPO_CONTENTS_CACHE}")
134+
fi
135+
136+
if [[ -n "${BAZEL_REPOSITORY_CACHE:-}" ]]; then
137+
post_config_bazel_args+=("--repository_cache=${BAZEL_REPOSITORY_CACHE}")
138+
fi
139+
129140
bazel_console_log="$(mktemp)"
130141
trap 'rm -f "$bazel_console_log"' EXIT
131142

.github/workflows/rust-ci-full.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ jobs:
100100
sudo DEBIAN_FRONTEND=noninteractive apt-get update
101101
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends pkg-config libcap-dev
102102
- name: Run argument comment lint on codex-rs via Bazel
103+
if: ${{ runner.os != 'Windows' }}
104+
env:
105+
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
103106
shell: bash
104107
run: |
105108
./.github/scripts/run-bazel-ci.sh \
@@ -110,6 +113,23 @@ jobs:
110113
--build_metadata=COMMIT_SHA=${GITHUB_SHA} \
111114
-- \
112115
//codex-rs/...
116+
- name: Run argument comment lint on codex-rs via Bazel
117+
if: ${{ runner.os == 'Windows' }}
118+
env:
119+
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
120+
shell: bash
121+
run: |
122+
./.github/scripts/run-bazel-ci.sh \
123+
-- \
124+
build \
125+
--config=argument-comment-lint-windows \
126+
--host_platform=//:local_windows_msvc \
127+
--platforms=//:local_windows \
128+
--extra_execution_platforms=//:local_windows \
129+
--keep_going \
130+
--build_metadata=COMMIT_SHA=${GITHUB_SHA} \
131+
-- \
132+
//codex-rs/...
113133
114134
# --- CI to validate on different os/targets --------------------------------
115135
lint_build:

.github/workflows/rust-ci.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,6 @@ jobs:
159159
run: |
160160
sudo DEBIAN_FRONTEND=noninteractive apt-get update
161161
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends pkg-config libcap-dev
162-
- name: Install nightly argument-comment-lint toolchain
163-
if: ${{ runner.os == 'Windows' }}
164-
shell: bash
165-
run: |
166-
rustup toolchain install nightly-2025-09-18 \
167-
--profile minimal \
168-
--component llvm-tools-preview \
169-
--component rustc-dev \
170-
--component rust-src \
171-
--no-self-update
172-
rustup default nightly-2025-09-18
173162
- name: Run argument comment lint on codex-rs via Bazel
174163
if: ${{ runner.os != 'Windows' }}
175164
env:
@@ -184,10 +173,23 @@ jobs:
184173
--build_metadata=COMMIT_SHA=${GITHUB_SHA} \
185174
-- \
186175
//codex-rs/...
187-
- name: Run argument comment lint on codex-rs via packaged wrapper
176+
- name: Run argument comment lint on codex-rs via Bazel
188177
if: ${{ runner.os == 'Windows' }}
178+
env:
179+
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
189180
shell: bash
190-
run: python3 ./tools/argument-comment-lint/run-prebuilt-linter.py
181+
run: |
182+
./.github/scripts/run-bazel-ci.sh \
183+
-- \
184+
build \
185+
--config=argument-comment-lint-windows \
186+
--host_platform=//:local_windows_msvc \
187+
--platforms=//:local_windows \
188+
--extra_execution_platforms=//:local_windows \
189+
--keep_going \
190+
--build_metadata=COMMIT_SHA=${GITHUB_SHA} \
191+
-- \
192+
//codex-rs/...
191193
192194
# --- Gatherer job that you mark as the ONLY required status -----------------
193195
results:

BUILD.bazel

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ platform(
1717
platform(
1818
name = "local_windows",
1919
constraint_values = [
20-
# We just need to pick one of the ABIs. Do the same one we target.
2120
"@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm",
2221
],
2322
parents = ["@platforms//host"],
2423
)
2524

25+
platform(
26+
name = "local_windows_msvc",
27+
constraint_values = [
28+
"@rules_rs//rs/experimental/platforms/constraints:windows_msvc",
29+
],
30+
parents = ["@platforms//host"],
31+
)
32+
2633
alias(
2734
name = "rbe",
2835
actual = "@rbe_platform",

MODULE.bazel

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_r
8282
rules_rust.patch(
8383
patches = [
8484
"//patches:rules_rust_windows_gnullvm_build_script.patch",
85+
"//patches:rules_rust_repository_set_exec_constraints.patch",
8586
],
8687
strip = 1,
8788
)
@@ -96,6 +97,34 @@ nightly_rust.toolchain(
9697
dev_components = True,
9798
edition = "2024",
9899
)
100+
# Keep Windows exec tools on MSVC so Bazel helper binaries link correctly, but
101+
# lint crate targets as `windows-gnullvm` to preserve the repo's actual cfgs.
102+
nightly_rust.repository_set(
103+
name = "rust_windows_x86_64",
104+
edition = "2024",
105+
exec_triple = "x86_64-pc-windows-msvc",
106+
exec_compatible_with = [
107+
"@platforms//cpu:x86_64",
108+
"@platforms//os:windows",
109+
"@rules_rs//rs/experimental/platforms/constraints:windows_msvc",
110+
],
111+
target_compatible_with = [
112+
"@platforms//cpu:x86_64",
113+
"@platforms//os:windows",
114+
"@rules_rs//rs/experimental/platforms/constraints:windows_msvc",
115+
],
116+
target_triple = "x86_64-pc-windows-msvc",
117+
versions = ["nightly/2025-09-18"],
118+
)
119+
nightly_rust.repository_set(
120+
name = "rust_windows_x86_64",
121+
target_compatible_with = [
122+
"@platforms//cpu:x86_64",
123+
"@platforms//os:windows",
124+
"@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm",
125+
],
126+
target_triple = "x86_64-pc-windows-gnullvm",
127+
)
99128
use_repo(nightly_rust, "rust_toolchains")
100129

101130
toolchains = use_extension("@rules_rs//rs/experimental/toolchains:module_extension.bzl", "toolchains")

patches/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ exports_files([
22
"abseil_windows_gnullvm_thread_identity.patch",
33
"aws-lc-sys_memcmp_check.patch",
44
"llvm_windows_symlink_extract.patch",
5+
"rules_rust_repository_set_exec_constraints.patch",
56
"rules_rust_windows_gnullvm_build_script.patch",
67
"rules_rs_windows_gnullvm_exec.patch",
78
"rusty_v8_prebuilt_out_dir.patch",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# What: let `rules_rust` repository_set entries specify an explicit exec-platform
2+
# constraint set.
3+
# Why: codex needs Windows nightly lint toolchains to run helper binaries on an
4+
# MSVC exec platform while still targeting `windows-gnullvm` crates.
5+
6+
diff --git a/rust/extensions.bzl b/rust/extensions.bzl
7+
--- a/rust/extensions.bzl
8+
+++ b/rust/extensions.bzl
9+
@@ -52,6 +52,7 @@ def _rust_impl(module_ctx):
10+
"allocator_library": repository_set.allocator_library,
11+
"dev_components": repository_set.dev_components,
12+
"edition": repository_set.edition,
13+
+ "exec_compatible_with": [str(v) for v in repository_set.exec_compatible_with] if repository_set.exec_compatible_with else None,
14+
"exec_triple": repository_set.exec_triple,
15+
"extra_target_triples": {repository_set.target_triple: [str(v) for v in repository_set.target_compatible_with]},
16+
"name": repository_set.name,
17+
@@ -166,6 +167,9 @@ _COMMON_TAG_KWARGS = {
18+
19+
_RUST_REPOSITORY_SET_TAG_ATTRS = {
20+
+ "exec_compatible_with": attr.label_list(
21+
+ doc = "Execution platform constraints for this repository_set.",
22+
+ ),
23+
"exec_triple": attr.string(
24+
doc = "Exec triple for this repository_set.",
25+
),
26+
"name": attr.string(

0 commit comments

Comments
 (0)