Skip to content

Commit decf801

Browse files
bolinfestcodex
andcommitted
bazel: add explicit rust test shard labels
Generate separate Bazel test labels for selected large Rust test targets so BuildBuddy can report timing and flakiness per shard. Keep the original aggregate target names as test_suites over the generated shard targets. For integration tests, compile one manual *-all-test-bin rust_test and make each shard label a lightweight wrapper around that binary. This preserves distinct BuildBuddy labels without compiling the same test crate once per shard. Patch the pinned rules_rust archive with the stable name-hash sharding, explicit RULES_RUST_TEST_* env support, Windows manifest fallback, Windows-safe PowerShell UInt32 masking, and isolated Windows shard temp files from hermeticbuild/rules_rust#14 until Codex can bump to a merged rules_rust commit that contains it. Co-authored-by: Codex <noreply@openai.com>
1 parent 9e2fc31 commit decf801

14 files changed

+854
-197
lines changed

BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ alias(
3737

3838
exports_files([
3939
"AGENTS.md",
40+
"test_binary_test_launcher.bat.tpl",
41+
"test_binary_test_launcher.sh.tpl",
4042
"workspace_root_test_launcher.bat.tpl",
4143
"workspace_root_test_launcher.sh.tpl",
4244
])

MODULE.bazel

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,40 @@ single_version_override(
9494
)
9595

9696
rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_rust")
97-
# Build-script probe binaries inherit CFLAGS/CXXFLAGS from Bazel's C++
98-
# toolchain. On `windows-gnullvm`, llvm-mingw does not ship
99-
# `libssp_nonshared`, so strip the forwarded stack-protector flags there.
100-
rules_rust.patch(
97+
98+
bazel_dep(name = "rules_rust", version = "0.69.0")
99+
100+
# `rules_rs` 0.0.43 pins an older hermeticbuild/rules_rust commit. Override the
101+
# extension-created repo so Codex can use rust_test sharding from #14 without
102+
# updating the entire rules_rs module.
103+
#
104+
# Build-script probe binaries inherit CFLAGS/CXXFLAGS from Bazel's C++ toolchain.
105+
# On `windows-gnullvm`, llvm-mingw does not ship `libssp_nonshared`, so strip the
106+
# forwarded stack-protector flags there.
107+
archive_override(
108+
module_name = "rules_rust",
109+
integrity = "sha256-q37yA5WS3++LIgdkThIhxsQkoZ5F/+DD4GhTWkY1rkE=",
110+
patch_strip = 1,
101111
patches = [
102112
"//patches:rules_rust_windows_gnullvm_build_script.patch",
103113
"//patches:rules_rust_windows_exec_msvc_build_script_env.patch",
104114
"//patches:rules_rust_windows_bootstrap_process_wrapper_linker.patch",
105115
"//patches:rules_rust_windows_build_script_runner_paths.patch",
106116
"//patches:rules_rust_windows_msvc_direct_link_args.patch",
107117
"//patches:rules_rust_windows_process_wrapper_skip_temp_outputs.patch",
118+
"//patches:rules_rust_stable_explicit_test_shards.patch",
108119
"//patches:rules_rust_windows_exec_bin_target.patch",
109120
"//patches:rules_rust_windows_exec_std.patch",
110121
"//patches:rules_rust_windows_exec_rustc_dev_rlib.patch",
111-
"//patches:rules_rust_repository_set_exec_constraints.patch",
112122
],
113-
strip = 1,
123+
strip_prefix = "rules_rust-10825e1a40b8f6d979c51bc795c9d3fa7f78cc6f",
124+
urls = ["https://github.com/hermeticbuild/rules_rust/archive/10825e1a40b8f6d979c51bc795c9d3fa7f78cc6f.tar.gz"],
125+
)
126+
127+
override_repo(
128+
rules_rust,
129+
rules_rust = "rules_rust",
114130
)
115-
use_repo(rules_rust, "rules_rust")
116131

117132
nightly_rust = use_extension(
118133
"@rules_rs//rs/experimental:rules_rust_reexported_extensions.bzl",

MODULE.bazel.lock

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ codex_rust_crate(
44
name = "app-server",
55
crate_name = "codex_app_server",
66
integration_test_timeout = "long",
7+
test_shard_counts = {
8+
"app-server-all-test": 8,
9+
"app-server-unit-tests": 8,
10+
},
711
test_tags = ["no-sandbox"],
812
)

codex-rs/core/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ codex_rust_crate(
4747
# succeeds without this workaround.
4848
"//:AGENTS.md",
4949
],
50+
test_shard_counts = {
51+
"core-all-test": 8,
52+
"core-unit-tests": 8,
53+
},
5054
test_tags = ["no-sandbox"],
5155
unit_test_timeout = "long",
5256
extra_binaries = [

codex-rs/tui/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ codex_rust_crate(
1919
"src/**/*.rs",
2020
"src/**/snapshots/**",
2121
]) + ["//codex-rs/core:model_availability_nux_fixtures"],
22+
test_shard_counts = {
23+
"tui-unit-tests": 8,
24+
},
2225
integration_compile_data_extra = ["src/test_backend.rs"],
2326
extra_binaries = [
2427
"//codex-rs/cli:codex",

0 commit comments

Comments
 (0)