mirror of
https://github.com/openai/codex.git
synced 2026-09-06 15:29:32 +00:00
bazel: serialize contention-prone Windows tests (#28598)
This commit is contained in:
@@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
codex_rust_crate(
|
||||
name = "agent-identity",
|
||||
crate_name = "codex_agent_identity",
|
||||
test_sizes = {
|
||||
"agent-identity-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"agent-identity-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
codex_rust_crate(
|
||||
name = "apply-patch",
|
||||
crate_name = "codex_apply_patch",
|
||||
test_sizes = {
|
||||
"apply-patch-all-test-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"apply-patch-all-test-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
codex_rust_crate(
|
||||
name = "file-system",
|
||||
crate_name = "codex_file_system",
|
||||
test_sizes = {
|
||||
"file-system-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"file-system-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
codex_rust_crate(
|
||||
name = "read",
|
||||
crate_name = "codex_memories_read",
|
||||
test_sizes = {
|
||||
"read-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"read-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
codex_rust_crate(
|
||||
name = "secrets",
|
||||
crate_name = "codex_secrets",
|
||||
test_sizes = {
|
||||
"secrets-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"secrets-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ codex_rust_crate(
|
||||
"migrations/**",
|
||||
]),
|
||||
crate_name = "codex_state",
|
||||
test_sizes = {
|
||||
"state-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"state-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
codex_rust_crate(
|
||||
name = "approval-presets",
|
||||
crate_name = "codex_utils_approval_presets",
|
||||
test_sizes = {
|
||||
"approval-presets-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"approval-presets-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -5,6 +5,8 @@ codex_rust_crate(
|
||||
crate_name = "codex_utils_rustls_provider",
|
||||
test_sizes = {
|
||||
"rustls-provider-preinstalled-test-windows-cross": "medium",
|
||||
"rustls-provider-unit-tests-windows-cross": "medium",
|
||||
},
|
||||
test_tags_by_target = {
|
||||
"rustls-provider-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ codex_rust_crate(
|
||||
"codex-windows-sandbox-setup.manifest",
|
||||
],
|
||||
crate_name = "codex_windows_sandbox",
|
||||
test_sizes = {
|
||||
"windows-sandbox-rs-unit-tests-windows-cross": "medium",
|
||||
test_tags_by_target = {
|
||||
"windows-sandbox-rs-unit-tests-windows-cross": ["exclusive-if-local"],
|
||||
},
|
||||
)
|
||||
|
||||
24
defs.bzl
24
defs.bzl
@@ -198,6 +198,7 @@ def codex_rust_crate(
|
||||
test_shard_counts = {},
|
||||
test_sizes = {},
|
||||
test_tags = [],
|
||||
test_tags_by_target = {},
|
||||
unit_test_timeout = None,
|
||||
extra_binaries = [],
|
||||
extra_binaries_non_windows = [],
|
||||
@@ -247,6 +248,8 @@ def codex_rust_crate(
|
||||
targets individually, including Windows-cross and Wine tests.
|
||||
test_tags: Tags applied to unit + integration test targets.
|
||||
Typically used to disable the sandbox, but see https://bazel.build/reference/be/common-definitions#common.tags
|
||||
test_tags_by_target: Mapping from generated test target name to
|
||||
additional Bazel tags for that target.
|
||||
unit_test_timeout: Optional Bazel timeout for the unit-test target
|
||||
generated from `src/**/*.rs`.
|
||||
extra_binaries: Additional binary labels to surface as test data and
|
||||
@@ -378,7 +381,7 @@ def codex_rust_crate(
|
||||
test_bin = ":" + unit_test_binary,
|
||||
workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker",
|
||||
target_compatible_with = target_compatible_with,
|
||||
tags = test_tags,
|
||||
tags = _test_tags(test_tags, test_tags_by_target, unit_test_target_name),
|
||||
**unit_test_kwargs
|
||||
)
|
||||
|
||||
@@ -528,7 +531,7 @@ def codex_rust_crate(
|
||||
test_bin = ":" + integration_test_binary,
|
||||
workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker",
|
||||
target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE,
|
||||
tags = test_tags,
|
||||
tags = _test_tags(test_tags, test_tags_by_target, test_name),
|
||||
**test_kwargs
|
||||
)
|
||||
else:
|
||||
@@ -554,7 +557,7 @@ def codex_rust_crate(
|
||||
rustc_env = rustc_env,
|
||||
env = integration_test_cargo_env,
|
||||
target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE,
|
||||
tags = test_tags,
|
||||
tags = _test_tags(test_tags, test_tags_by_target, test_name),
|
||||
**test_kwargs
|
||||
)
|
||||
|
||||
@@ -604,7 +607,7 @@ def codex_rust_crate(
|
||||
test_bin = "//codex-rs/exec-server/testing:wine-exec-test-runner",
|
||||
workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker",
|
||||
target_compatible_with = WINE_TEST_TARGET_COMPATIBLE_WITH,
|
||||
tags = test_tags + ["manual"],
|
||||
tags = _test_tags(test_tags, test_tags_by_target, wine_test_name) + ["manual"],
|
||||
**wine_test_kwargs
|
||||
)
|
||||
|
||||
@@ -642,7 +645,7 @@ def codex_rust_crate(
|
||||
test_bin = ":" + windows_cross_test_binary,
|
||||
workspace_root_marker = "//codex-rs/utils/cargo-bin:repo_root.marker",
|
||||
target_compatible_with = WINDOWS_GNULLVM_ONLY,
|
||||
tags = test_tags,
|
||||
tags = _test_tags(test_tags, test_tags_by_target, windows_cross_test_name),
|
||||
**windows_cross_test_kwargs
|
||||
)
|
||||
|
||||
@@ -662,6 +665,14 @@ def codex_rust_crate(
|
||||
if unknown_test_shard_counts:
|
||||
fail("test_shard_counts contains unknown generated test targets: {}".format(", ".join(unknown_test_shard_counts)))
|
||||
|
||||
unknown_test_tags = sorted([
|
||||
test_name
|
||||
for test_name in test_tags_by_target
|
||||
if test_name not in generated_test_names
|
||||
])
|
||||
if unknown_test_tags:
|
||||
fail("test_tags_by_target contains unknown generated test targets: {}".format(", ".join(unknown_test_tags)))
|
||||
|
||||
def _test_shard_count(test_shard_counts, test_name):
|
||||
shard_count = test_shard_counts.get(test_name)
|
||||
if shard_count == None:
|
||||
@@ -672,6 +683,9 @@ def _test_shard_count(test_shard_counts, test_name):
|
||||
|
||||
return shard_count
|
||||
|
||||
def _test_tags(test_tags, test_tags_by_target, test_name):
|
||||
return test_tags + test_tags_by_target.get(test_name, [])
|
||||
|
||||
def _test_size(test_sizes, test_name):
|
||||
size = test_sizes.get(test_name, "small")
|
||||
if size not in ["small", "medium", "large", "enormous"]:
|
||||
|
||||
Reference in New Issue
Block a user