@@ -256,8 +256,49 @@ test('keeps Rust CI independent, restore-only on PRs, and target-focused', () =>
256256 ) ;
257257 assert . equal (
258258 rustCache ?. with ?. [ 'cache-directories' ] ,
259- 'target/sherpa-onnx-prebuilt\n' ,
260- 'Rust CI must restore sherpa native libraries with the Cargo fingerprints that reference them' ,
259+ undefined ,
260+ 'Rust cache cleanup must not own native libraries stored under target' ,
261+ ) ;
262+
263+ const restoreSherpaCache = rustJob . steps . find (
264+ ( step ) => step . name === 'Restore Sherpa native libraries' ,
265+ ) ;
266+ const repairSherpaState = rustJob . steps . find (
267+ ( step ) => step . name === 'Repair missing Sherpa native state' ,
268+ ) ;
269+ const checkCompilation = rustJob . steps . find (
270+ ( step ) => step . name === 'Check compilation' ,
271+ ) ;
272+ const saveSherpaCache = rustJob . steps . find (
273+ ( step ) => step . name === 'Save Sherpa native libraries' ,
274+ ) ;
275+ const sherpaCacheKey =
276+ 'sherpa-onnx-v1-${{ runner.os }}-${{ runner.arch }}-1.13.4-static' ;
277+
278+ assert . equal ( restoreSherpaCache ?. uses , 'actions/cache/restore@v5' ) ;
279+ assert . equal ( restoreSherpaCache ?. with ?. path , 'target/sherpa-onnx-prebuilt' ) ;
280+ assert . equal ( restoreSherpaCache ?. with ?. key , sherpaCacheKey ) ;
281+ assert . match (
282+ repairSherpaState ?. run ?? '' ,
283+ / r m - r f t a r g e t \/ s h e r p a - o n n x - p r e b u i l t / ,
284+ ) ;
285+ assert . match ( repairSherpaState ?. run ?? '' , / c a r g o c l e a n - p s h e r p a - o n n x - s y s / ) ;
286+ assert . equal ( saveSherpaCache ?. uses , 'actions/cache/save@v5' ) ;
287+ assert . equal ( saveSherpaCache ?. with ?. path , 'target/sherpa-onnx-prebuilt' ) ;
288+ assert . equal ( saveSherpaCache ?. with ?. key , sherpaCacheKey ) ;
289+ assert . equal (
290+ saveSherpaCache ?. if ,
291+ "github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.sherpa-native-cache.outputs.cache-hit != 'true'" ,
292+ ) ;
293+ assert . ok (
294+ rustJob . steps . indexOf ( restoreSherpaCache ) <
295+ rustJob . steps . indexOf ( checkCompilation ) ,
296+ 'Sherpa native libraries must be restored before cargo check' ,
297+ ) ;
298+ assert . ok (
299+ rustJob . steps . indexOf ( checkCompilation ) <
300+ rustJob . steps . indexOf ( saveSherpaCache ) ,
301+ 'Sherpa native libraries must be saved before rust-cache post cleanup' ,
261302 ) ;
262303
263304 const commandByStep = new Map (
0 commit comments