From 29e3c61b482bf7f3f03c1fa8954fda68408a3780 Mon Sep 17 00:00:00 2001 From: jif Date: Wed, 28 Oct 2026 13:42:55 +0000 Subject: [PATCH] Avoid recompiling Bazel integration tests for runtime fixture changes (#57742) ## Why Runtime fixtures and snapshots should not invalidate integration-test compilation. ## What changed Limit integration-test `compile_data` to Rust modules and explicitly declared embedded resources, while keeping all test files available as runtime data. Declare the embedded patch fixture in `exec` and PEM fixtures in `http-client` through `integration_compile_data_extra`. GitOrigin-RevId: 7d76809f9a7defdc40c90dc74d393e84e2c376b8 --- codex-rs/exec/BUILD.bazel | 1 + codex-rs/http-client/BUILD.bazel | 1 + defs.bzl | 13 +++++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/codex-rs/exec/BUILD.bazel b/codex-rs/exec/BUILD.bazel index 6aec3e0b77..a5396b1a00 100644 --- a/codex-rs/exec/BUILD.bazel +++ b/codex-rs/exec/BUILD.bazel @@ -3,6 +3,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( name = "exec", crate_name = "codex_exec", + integration_compile_data_extra = ["tests/fixtures/apply_patch_freeform_final.txt"], test_shard_counts = { "exec-all-test": 8, }, diff --git a/codex-rs/http-client/BUILD.bazel b/codex-rs/http-client/BUILD.bazel index 6092c05bf2..0bbd14beb0 100644 --- a/codex-rs/http-client/BUILD.bazel +++ b/codex-rs/http-client/BUILD.bazel @@ -4,4 +4,5 @@ codex_rust_crate( name = "http-client", compile_data = glob(["tests/fixtures/**"]), crate_name = "codex_http_client", + integration_compile_data_extra = glob(["tests/fixtures/*.pem"]), ) diff --git a/defs.bzl b/defs.bzl index 167e01c109..6e51ce0f31 100644 --- a/defs.bzl +++ b/defs.bzl @@ -253,7 +253,8 @@ def codex_rust_crate( rustc_env_files: Generated compiler environment files for the library target. deps_extra: Extra normal deps beyond @crates resolution. Typically only needed when features add additional deps. - integration_compile_data_extra: Extra compile_data for integration tests. + integration_compile_data_extra: Additional compile-time inputs for integration + tests, including resources embedded with include_str! or include_bytes!. integration_test_args: Optional args for integration test binaries. unit_test_args: Optional args for the unit test binary. binary_test_target_compatible_with: Platform constraints for binary unit tests. @@ -497,6 +498,10 @@ def codex_rust_crate( integration_test_cargo_env = cargo_env integration_test_cargo_env_runfiles = cargo_env_runfiles integration_test_files = native.glob(["tests/**"], allow_empty = True) + + # Fixtures and snapshots are runtime data. Only Rust modules and explicitly + # embedded resources should invalidate integration-test compilation. + integration_compile_files = native.glob(["tests/**/*.rs"], allow_empty = True) integration_test_data_extra = [ data for data in test_data_extra @@ -585,7 +590,7 @@ def codex_rust_crate( crate_root = test, srcs = [test], data = integration_test_files + integration_test_binaries + integration_test_data_extra, - compile_data = integration_test_files + integration_compile_data_extra, + compile_data = integration_compile_files + integration_compile_data_extra, deps = all_crate_deps(normal = True, normal_dev = True) + maybe_deps + deps_extra, # Bazel has emitted both `codex-rs//...` and # `../codex-rs//...` paths for `file!()`. Strip either @@ -626,7 +631,7 @@ def codex_rust_crate( crate_root = test, srcs = [test], data = integration_test_files + integration_test_binaries + integration_test_data_extra, - compile_data = integration_test_files + integration_compile_data_extra, + compile_data = integration_compile_files + integration_compile_data_extra, deps = all_crate_deps(normal = True, normal_dev = True) + maybe_deps + deps_extra, # Bazel has emitted both `codex-rs//...` and # `../codex-rs//...` paths for `file!()`. Strip either @@ -702,7 +707,7 @@ def codex_rust_crate( crate_root = test, srcs = [test], data = integration_test_files + integration_test_binaries + integration_test_data_extra, - compile_data = integration_test_files + integration_compile_data_extra, + compile_data = integration_compile_files + integration_compile_data_extra, deps = all_crate_deps(normal = True, normal_dev = True) + maybe_deps + deps_extra, rustc_flags = rustc_flags_extra + WINDOWS_RUSTC_LINK_FLAGS + [ "--remap-path-prefix=../codex-rs=",