2222import io
2323import os
2424from pathlib import Path
25- import runpy
2625import subprocess
2726import sys
2827import tempfile
@@ -48,8 +47,13 @@ def setUp(self):
4847 "native/lib.rs" : "fn native() {}\n " , "native/proto/expr.proto" : "message Expr {}\n " ,
4948 "spark/Plan.scala" : "object Plan {}\n " , "README.md" : "Comet\n " ,
5049 ".github/workflows/README.md" : "CI documentation\n " ,
50+ ".github/workflows/pr_build_linux.yml" : "jobs: {}\n " ,
5151 ".github/workflows/spark_sql_test_reusable.yml" : "jobs: {}\n " ,
52+ ".github/workflows/iceberg_spark_test_reusable.yml" : "jobs: {}\n " ,
53+ ".github/workflows/spark_sql_writer_tests.yml" : "jobs: {}\n " ,
5254 ".github/workflows/check_pr_title.yml" : "jobs: {}\n " ,
55+ ".github/actions/build-native-ci/action.yaml" : "runs: {}\n " ,
56+ ".github/actions/setup-builder/action.yaml" : "runs: {}\n " ,
5357 "dev/ci/compute-changes.py" : "# shared native input rules\n " ,
5458 "contrib/delta/native/Cargo.toml" : '[package]\n name = "delta"\n ' ,
5559 "contrib/delta/native/src/lib.rs" : "fn delta() {}\n " ,
@@ -84,7 +88,7 @@ def test_source_and_dependency_changes_invalidate_the_right_keys(self):
8488 before = self .keys ()
8589 for name in ("native/lib.rs" , "native/proto/expr.proto" , "native/Cargo.toml" , "native/Cargo.lock" ,
8690 "contrib/delta/native/Cargo.toml" , "dev/ci/compute-changes.py" ,
87- ".github/workflows/spark_sql_test_reusable.yml " ):
91+ ".github/actions/build-native-ci/action.yaml" , ".github/actions/setup-builder/action.yaml " ):
8892 with self .subTest (name = name ):
8993 self .write (name , self .inputs [name ] + "changed\n " )
9094 after = self .keys ()
@@ -100,30 +104,39 @@ def test_generated_files_and_unrelated_jvm_edits_preserve_keys(self):
100104 """Generated files and non-build edits preserve reuse; debug still tracks benchmarks."""
101105 before = self .keys ()
102106 debug = self .keys ("debug" )
107+ for name in self .inputs :
108+ if name .startswith (".github/workflows/" ):
109+ self .write (name , "unrelated test configuration\n " )
110+ self .env ["GITHUB_RUN_ID" ] = "12345"
111+ self .assertEqual (before , self .keys ())
112+ self .assertEqual (debug , self .keys ("debug" ))
103113 self .write ("native/proto/src/generated/expr.rs" , "generated Rust" )
104114 self .write ("native/target/ci/libcomet.so" , "compiled library" )
105115 self .write ("spark/Plan.scala" , "object NewPlan {}" )
106116 self .write ("README.md" , "updated docs" )
107- self .write (".github/workflows/README.md" , "updated CI docs" )
108- self .write (".github/workflows/check_pr_title.yml" , "jobs: {changed: {}}" )
109117 self .write ("contrib/delta/native/src/lib.rs" , "fn changed_delta() {}" )
110118 self .write ("contrib/delta/native/Cargo.lock" , "version = 3\n " )
111119 self .write ("contrib/a/b/native/Cargo.toml" , '[package]\n name = "changed_nested"\n ' )
112120 self .write ("native/core/benches/perf.rs" , "fn changed_benchmark() {}" )
113121 self .assertEqual (before , self .keys ())
114122 self .assertNotEqual (debug ["source-key" ], self .keys ("debug" )["source-key" ])
115123
116- def test_every_binary_key_input_has_a_main_cache_warmer (self ):
117- """Check real tracked inputs against push routing, plus inputs absent from today's tree ."""
124+ def test_native_input_routing (self ):
125+ """Library inputs warm main; helper tests retain Linux coverage without extra consumers ."""
118126 project = Path (__file__ ).resolve ().parents [2 ]
119- route = runpy . run_path ( str ( project / "dev/ci/compute-changes.py" ))[ " compute" ]
127+ route = CACHE . CHANGES . compute
120128 _ , sources = CACHE .source_inputs (project )
121129 for name in [* sources , ".cargo/config.toml" , "rust-toolchain" , "contrib/new/native/Cargo.toml" ]:
122130 self .assertTrue (route ([name ], {"name" : "push" })["build_linux" ], name )
123131 for name in ("contrib/delta/native/src/lib.rs" , "contrib/delta/native/Cargo.lock" ,
124132 "contrib/a/b/native/Cargo.toml" , "contrib/a/b/native/x.rs" ):
125133 self .assertFalse (route ([name ], {"name" : "push" })["build_linux" ], name )
126134 self .assertFalse (route (["contrib/new/native/Cargo.toml" ], {"name" : "pull_request" })["build_linux" ])
135+ for event in ("merge_group" , "schedule" ):
136+ routed = route (["dev/ci/test-native-cache-key.py" ], {"name" : event })
137+ self .assertTrue (routed ["build_linux" if event == "merge_group" else "build_linux_all_profiles" ])
138+ self .assertFalse (any (selected for name , selected in routed .items ()
139+ if name .startswith (("spark_" , "iceberg_" ))))
127140
128141 def test_tools_jdk_flags_and_tracked_build_configuration_invalidate (self ):
129142 """Observed tool/package versions, Java metadata, flags and tracked configs enter keys."""
@@ -142,6 +155,16 @@ def test_tools_jdk_flags_and_tracked_build_configuration_invalidate(self):
142155 self .env ["RUSTFLAGS" ] += " -Copt-level=1"
143156 self .assertNotEqual (before ["binary-key" ], self .keys ()["binary-key" ])
144157 self .env ["RUSTFLAGS" ] = "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd"
158+ for name in ("CC" , "CXX" , "CFLAGS" , "LDFLAGS" , "AR" , "PROTOC" , "PROTOC_INCLUDE" ,
159+ "RUSTC_WRAPPER" , "CARGO_BUILD_TARGET" , "CARGO_PROFILE_CI_OPT_LEVEL" ,
160+ "CC_x86_64_unknown_linux_gnu" , "HOST_CC" , "TARGET_CFLAGS" ,
161+ "HDFS_LIB_DIR" , "HADOOP_HOME" , "HDFS_STATIC" , "DOCS_RS" , "PATH" ):
162+ with self .subTest (environment = name ):
163+ self .env [name ] = "build override"
164+ after = self .keys ()
165+ for key in ("binary-key" , "source-key" , "restore-prefix" ):
166+ self .assertNotEqual (before [key ], after [key ])
167+ del self .env [name ]
145168 self .write (".cargo/config.toml" , "[build]\n incremental = false\n " )
146169 subprocess .run (["git" , "add" , ".cargo/config.toml" ], cwd = self .root , check = True )
147170 self .assertNotEqual (before ["binary-key" ], self .keys ()["binary-key" ])
0 commit comments