ci: stop the publish job's cache save from erroring on package scratch - #24
Merged
Conversation
The v1.10.0 publish job succeeded but posted red annotations: Error: ENOENT: no such file or directory, opendir '.../target/package/pxsolver-cache-1.10.0/tests/trybuild' Nothing is wrong with those crates. `cargo publish` leaves scratch in target/package/<crate>-<ver>/, and for any crate shipping a tests/ dir that scratch contains a directory named `tests`. rust-cache's save-time cleanup treats every such directory as a possible nested test workspace and recurses into tests/target and tests/trybuild — a carve-out for trybuild and macrotest. Neither path exists here; this workspace has no trybuild dependency at all. The recursion is not awaited inside its own try/catch (Swatinem/rust-cache src/cleanup.ts, cleanProfileTarget), so the ENOENT never reaches the catch and escapes as an unhandled rejection. That is why it renders as a failure annotation on a job that succeeded, and why it named a nondeterministic subset — cache, camoufox and native out of the six published crates that carry tests/. Publish scratch is single-use and worthless in the cache, and pre-flight already populates the same key, so the job now restores without saving. That removes the failing code path instead of racing it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not a px-cache bug
The v1.10.0 publish job succeeded but posted failure annotations:
Named crates:
pxsolver-cache,pxsolver-camoufox,pxsolver-native— three of the six published crates that ship atests/directory. Nothing is wrong with any of them, and no manifest change fixes it.Root cause
cargo publishleaves scratch intarget/package/<crate>-<ver>/. For a crate shipping tests, that scratch contains a directory literally namedtests. rust-cache's save-time cleanup treats any directory namedtestsundertarget/as a possible nested test workspace and recurses intotests/targetandtests/trybuild— a carve-out for trybuild and macrotest artifacts. This workspace has no trybuild dependency, so neither path exists.From
Swatinem/rust-cachesrc/cleanup.ts,cleanProfileTarget:The calls are
asyncbut not awaited, so the rejection never reaches the surroundingcatch. It escapes as an unhandled rejection — which is why it renders as a failure annotation on a job that succeeded, and why it named an arbitrary subset of the eligible crates rather than all six.Fix
save-if: falseon the publish job's cache step. Publish scratch is single-use and worth nothing in the cache, andpre-flightalready populates the same key, so the job restores as before and simply never runs the save-time cleanup. That removes the failing code path rather than racing it (anrm -rf target/packagecleanup step would only cover the paths we know about today).pre-flightand all threeci.ymljobs are untouched — none of them runcargo package, so none can hit this.Verification
Workflow YAML parses; the
with: save-if: falselands oncrates-publishonly,pre-flightunchanged.Note this cannot be proven by a re-run: the publish loop skips crates already at the target version, so
cargo publishnever runs andtarget/package/is never created. The next real publish (1.11.0) is the empirical confirmation. The fix is sound by construction — no save step means no cleanup walk.