fix(cache): exclude rust from mise cache#474
Conversation
Greptile SummaryThis PR excludes
Confidence Score: 5/5The staging/restore approach is structurally sound — the finally block guarantees installs/rust is always returned to its original location, and no new logic defects were found in the changed code paths. The core try/finally contract is correct: the Rust path is always restored regardless of whether saveCache succeeds, is skipped (cacheId -1), or throws. The staged-path naming (pid + timestamp + relative path) is unique enough for sequential execution. No new logic defects were found in the changed code paths during this review pass. src/index.ts — specifically the RUST_CACHE_PATHS constant and how stageRustCachePaths handles multiple entries if new paths are added in future. Important Files Changed
Reviews (4): Last reviewed commit: "fix(cache): exclude rust from mise cache" | Re-trigger Greptile |
| `Swatinem/rust-cache` caches `~/.cargo` and `target` by default, including | ||
| `~/.cargo/bin` for tools installed during the workflow. If your workflow uses a | ||
| custom `CARGO_HOME`, or installs Cargo tools somewhere else, add that directory | ||
| to your cache configuration manually. |
There was a problem hiding this comment.
The
~/.cargo description is a slight over-simplification. Swatinem/rust-cache does not cache the entire ~/.cargo tree — it caches specific subdirectories (registry/index, registry/cache, git/db) plus ~/.cargo/bin (when cache-bin: true, the default) and the target directory. Notably, ~/.cargo/registry/src is explicitly not cached because cargo recreates it from the compressed archives. Saying "caches ~/.cargo and target" may lead users to assume all cargo data is persisted when it isn't.
| `Swatinem/rust-cache` caches `~/.cargo` and `target` by default, including | |
| `~/.cargo/bin` for tools installed during the workflow. If your workflow uses a | |
| custom `CARGO_HOME`, or installs Cargo tools somewhere else, add that directory | |
| to your cache configuration manually. | |
| `Swatinem/rust-cache` caches the Cargo registry, git dependencies, `~/.cargo/bin`, | |
| and `target` by default. If your workflow uses a custom `CARGO_HOME`, or installs | |
| Cargo tools somewhere else, add that directory to your cache configuration manually. |
There was a problem hiding this comment.
Code Review
This pull request updates the README.md to include a new section on Rust and Cargo caching, recommending the use of Swatinem/rust-cache alongside mise-action. The review feedback suggests improving the technical accuracy of the documentation by specifying the exact subdirectories cached within the Cargo home and noting that mise-action automatically exports CARGO_HOME, which simplifies the integration.
| `Swatinem/rust-cache` caches `~/.cargo` and `target` by default, including | ||
| `~/.cargo/bin` for tools installed during the workflow. If your workflow uses a | ||
| custom `CARGO_HOME`, or installs Cargo tools somewhere else, add that directory | ||
| to your cache configuration manually. |
There was a problem hiding this comment.
It is more accurate to state that Swatinem/rust-cache caches the Cargo registry, git database, and binaries (~/.cargo/{registry,git,bin}) rather than the entire ~/.cargo directory. Additionally, since mise-action exports environment variables like CARGO_HOME to GITHUB_ENV, rust-cache will typically pick them up automatically. Manual configuration is usually only necessary for non-standard tool installation paths outside of the Cargo home.
0a94d23 to
0254002
Compare
0254002 to
1ddfb33
Compare
Summary
Notes
@actions/cache.saveCachedoes not support per-path exclusions when saving a cache path. To keep the current job behavior intact, this PR temporarily stagesinstalls/rustoutsideMISE_DATA_DIR, saves the mise cache, then restores it in afinallyblock.I checked the mise Rust backend:
downloads/rustis not read as a reusable cache. Rust installs go through rustup, rustup state lives underRUSTUP_HOME/CARGO_HOME, and mise only createsdownloads/rust/<version>via generic install scaffolding. That directory is removed after successful install unlessalways_keep_downloadis enabled, where it is retained for debugging rather than reuse.This replaces the previous docs-only approach after the mise-side fix was declined.
Test plan
npm run format:writenpm run lintnpm run packageThis PR body was generated by an AI coding assistant.