From 04ba36a8a8f88bb913687f3f44b51bd077153c32 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 16 Jun 2026 23:23:37 +0000 Subject: [PATCH] codex: address CI timeout warnings (#28598) --- codex-rs/app-server/BUILD.bazel | 5 +--- codex-rs/core/BUILD.bazel | 7 ++---- codex-rs/exec/BUILD.bazel | 2 +- codex-rs/utils/image/BUILD.bazel | 4 +-- defs.bzl | 43 +++++++++++++++++++++++--------- 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/codex-rs/app-server/BUILD.bazel b/codex-rs/app-server/BUILD.bazel index 5e653d4cbc..6ec98e92d5 100644 --- a/codex-rs/app-server/BUILD.bazel +++ b/codex-rs/app-server/BUILD.bazel @@ -17,11 +17,8 @@ codex_rust_crate( # can cause us to exhaust our CI timeout if the shard happens to run # long. Using a higher shard count for app-server-all-test should help # mitigate this risk. - "app-server-all-test": 16, + "app-server-all-test": 32, "app-server-unit-tests": 8, }, - test_sizes = { - "app-server-all-test-windows-cross": "medium", - }, test_tags = ["no-sandbox"], ) diff --git a/codex-rs/core/BUILD.bazel b/codex-rs/core/BUILD.bazel index 274cb66c38..ff972618f1 100644 --- a/codex-rs/core/BUILD.bazel +++ b/codex-rs/core/BUILD.bazel @@ -44,11 +44,8 @@ codex_rust_crate( ], test_shard_counts = { "core-all-test": 16, - "core-unit-tests": 8, - }, - test_sizes = { - "core-all-test-windows-cross": "medium", - "core-unit-tests-windows-cross": "medium", + "core-all-test-windows-cross": 32, + "core-unit-tests": 16, }, test_tags = ["no-sandbox"], ) diff --git a/codex-rs/exec/BUILD.bazel b/codex-rs/exec/BUILD.bazel index 6aec3e0b77..b4926fc346 100644 --- a/codex-rs/exec/BUILD.bazel +++ b/codex-rs/exec/BUILD.bazel @@ -4,7 +4,7 @@ codex_rust_crate( name = "exec", crate_name = "codex_exec", test_shard_counts = { - "exec-all-test": 8, + "exec-all-test": 16, }, test_tags = ["no-sandbox"], ) diff --git a/codex-rs/utils/image/BUILD.bazel b/codex-rs/utils/image/BUILD.bazel index 70f71ea337..d101a9f870 100644 --- a/codex-rs/utils/image/BUILD.bazel +++ b/codex-rs/utils/image/BUILD.bazel @@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "image", crate_name = "codex_utils_image", - test_sizes = { - "image-unit-tests-windows-cross": "medium", + test_shard_counts = { + "image-unit-tests": 4, }, ) diff --git a/defs.bzl b/defs.bzl index 39d2449f7c..bdc9b09aeb 100644 --- a/defs.bzl +++ b/defs.bzl @@ -239,7 +239,9 @@ def codex_rust_crate( The launcher resolves the real Rust test binary through runfiles and then assigns each libtest case to a stable bucket by hashing the test name. Matching tests are also marked flaky, which gives - them Bazel's default three attempts. + them Bazel's default three attempts. Windows-cross and Wine + variants inherit the native target's count unless callers + override the generated variant name explicitly. test_sizes: Mapping from generated test target name to Bazel test size. All generated tests default to small. Callers can override slower targets individually, including Windows-cross and Wine tests. @@ -327,6 +329,9 @@ def codex_rust_crate( windows_cross_unit_test_name = unit_test_name + "-windows-cross" generated_test_names.extend([unit_test_name, windows_cross_unit_test_name]) unit_test_shard_count = _test_shard_count(test_shard_counts, unit_test_name) + windows_cross_unit_test_shard_count = _test_shard_count(test_shard_counts, windows_cross_unit_test_name) + if windows_cross_unit_test_shard_count == None: + windows_cross_unit_test_shard_count = unit_test_shard_count # Shard at the workspace_root_test layer. rules_rust's sharding wrapper # expects to run from its own runfiles cwd, while workspace_root_test @@ -352,19 +357,19 @@ def codex_rust_crate( tags = test_tags + ["manual"], ) - # Keep a distinct Windows-cross label so callers can raise its - # nonconfigurable size without slowing the native test everywhere. - for unit_test_target_name, target_compatible_with in [ - (unit_test_name, WINDOWS_GNULLVM_INCOMPATIBLE), - (windows_cross_unit_test_name, WINDOWS_GNULLVM_ONLY), + # Keep a distinct Windows-cross label so callers can tune its + # nonconfigurable test attributes without changing every platform. + for unit_test_target_name, target_compatible_with, shard_count in [ + (unit_test_name, WINDOWS_GNULLVM_INCOMPATIBLE, unit_test_shard_count), + (windows_cross_unit_test_name, WINDOWS_GNULLVM_ONLY, windows_cross_unit_test_shard_count), ]: unit_test_kwargs = { "size": _test_size(test_sizes, unit_test_target_name), } if unit_test_timeout: unit_test_kwargs["timeout"] = unit_test_timeout - if unit_test_shard_count: - unit_test_kwargs["shard_count"] = unit_test_shard_count + if shard_count: + unit_test_kwargs["shard_count"] = shard_count unit_test_kwargs["flaky"] = True workspace_root_test( @@ -457,6 +462,9 @@ def codex_rust_crate( } test_kwargs.update(integration_test_kwargs) test_shard_count = _test_shard_count(test_shard_counts, test_name) + windows_cross_test_shard_count = _test_shard_count(test_shard_counts, windows_cross_test_name) + if windows_cross_test_shard_count == None: + windows_cross_test_shard_count = test_shard_count if test_shard_count: # Put Bazel sharding on the label users/CI invoke. Do not set # rules_rust's experimental_enable_sharding on the Rust test @@ -578,8 +586,11 @@ def codex_rust_crate( wine_test_kwargs = {} wine_test_kwargs.update(integration_test_kwargs) wine_test_kwargs["size"] = _test_size(test_sizes, wine_test_name) - if test_shard_count: - wine_test_kwargs["shard_count"] = test_shard_count + wine_test_shard_count = _test_shard_count(test_shard_counts, wine_test_name) + if wine_test_shard_count == None: + wine_test_shard_count = test_shard_count + if wine_test_shard_count: + wine_test_kwargs["shard_count"] = wine_test_shard_count wine_test_kwargs["flaky"] = True # The Wine runner is a binary rather than a rust_test, but it still @@ -601,8 +612,8 @@ def codex_rust_crate( "size": _test_size(test_sizes, windows_cross_test_name), } windows_cross_test_kwargs.update(integration_test_kwargs) - if test_shard_count: - windows_cross_test_kwargs["shard_count"] = test_shard_count + if windows_cross_test_shard_count: + windows_cross_test_kwargs["shard_count"] = windows_cross_test_shard_count windows_cross_test_kwargs["flaky"] = True rust_test( @@ -643,6 +654,14 @@ def codex_rust_crate( if unknown_test_sizes: fail("test_sizes contains unknown generated test targets: {}".format(", ".join(unknown_test_sizes))) + unknown_test_shard_counts = sorted([ + test_name + for test_name in test_shard_counts + if test_name not in generated_test_names + ]) + if unknown_test_shard_counts: + fail("test_shard_counts contains unknown generated test targets: {}".format(", ".join(unknown_test_shard_counts))) + def _test_shard_count(test_shard_counts, test_name): shard_count = test_shard_counts.get(test_name) if shard_count == None: