Commit Graph
37 Commits
Author SHA1 Message Date
Nathan Stocks c8037a86dd fix: include a virtual workspace's root Cargo.toml in the cache key (#395)
In a virtual workspace the root `Cargo.toml` is not a package, so the cache key hashed only the
members' manifests and left out the root's `[profile]`, `[patch]` and `[workspace.dependencies]`
(#268). Editing one of those, such as a `[profile.dev]` opt-level, kept the same key: every run
restored the stale cache as an exact hit, rebuilt what the edit invalidated, and saved nothing, so
the rebuild repeated on every run until something else changed the key.

This change hashes the root manifest of the workspace `cargo metadata` reports, along with its
members' manifests. It ignores `workspace.package.version` and the paths and versions of path
dependencies in `[workspace.dependencies]`, as it already does for members, so a release version
bump still keeps the key. It also reads `Cargo.lock` from that root, so a `workspaces` entry that
points at a member directory now hashes the lockfile that builds it. A workspace whose root is a
package keeps its key, and a virtual workspace gets a new one once.
2026-10-23 09:58:52 +02:00
Simon Scatton 0e361f3528 fix: log rustup toolchain list failure as info instead of warning (#393) (#394)
Do not show a warning when rustup is not installed.
2026-10-20 15:35:22 +02:00
Arpad Borsos 6e5b278ead correctly sort and dedupe Rust versions
fixes #369
2026-08-06 08:08:56 +02:00
Arpad Borsos 9f151aca7c update dependencies, rebuild 2026-07-26 16:34:10 +02:00
Arpad Borsos 1fe0a60026 Merge branch 'master' of https://github.com/Swatinem/rust-cache 2026-06-06 14:11:05 +02:00
Arpad Borsos be9aa033ee package maintenance
- update to TS6
- replace ncc by rollup, which seems to now be the recommended workflow according to <https://github.com/actions/typescript-action>
- remove buildjet provider, as they are shutting down, see <https://buildjet.com/for-github-actions/blog/we-are-shutting-down>
2026-06-06 14:02:52 +02:00
Arpad Borsos 781e8d91ab try reverting pipeline change 2026-03-12 18:11:51 +01:00
Tamir Duberstein 5e4a767433 Consider all installed toolchains in cache key (#293) 2025-12-16 12:30:13 +01:00
marc0246 151eeee51b Add support for running rust-cache commands from within a Nix shell (#290) 2025-12-01 19:56:12 +01:00
Ryan Brice 27f6075dd2 feat: Implement ability to disable adding job ID + rust environment hashes to cache names (#279) 2025-11-03 14:24:00 +01:00
Linda_pp 27b8ea9368 Include CPU arch in the cache key (#228) 2025-02-08 15:36:01 +01:00
Arpad Borsos 008623fb83 also cache cargo install metadata 2024-12-29 08:47:45 +01:00
Benjy Weinberger e8e63cdbf2 Allow opting out of caching $CARGO_HOME/bin. (#216)
Prevents wiping the bin directory, which is harmful for
self-hosted runners.
2024-12-10 08:47:51 +01:00
Rano | Ranadeep 9a2e0d3212 add runner OS in cache key (#220) 2024-12-09 22:32:01 +01:00
Jiahao XU 8f842c2d45 Support Cargo.lock format cargo-lock v4 (#211)
Fixed #209

Signed-off-by: Jiahao XU <[email protected]>
2024-10-08 20:55:46 +02:00
Max Heller d30f1144e8 Only key by Cargo.toml and Cargo.lock files of workspace members (#180) 2023-12-03 11:57:51 +01:00
Jiahao XU ab6b2769d1 dep: Use smol-toml instead of toml (#164)
Fixed #162 #163

The former is listed on
https://github.com/toml-lang/toml/wiki#implementations and is toml 1.0
compliant.

Signed-off-by: Jiahao XU <[email protected]>
2023-08-19 12:23:03 +02:00
Jiahao XU c0e052c18c Fix hashing of parsed Cargo.toml (#160)
The values for the dependencies could be strings intead of objects, so
add a `try` block to take care of that.

Also set `dep.path` to `""` if the dependency contains a key `path` to
make sure that the cache isn't invalidated due to change in workspace.

Signed-off-by: Jiahao XU <[email protected]>
2023-08-12 12:34:30 +02:00
Jiahao XU 4e0f4b19dd Fix typo in hashing parsed Cargo.lock (#159)
This simple mistake caused the entire `Cargo.lock` to be ignored (JS
treats having no return as `false`).

Signed-off-by: Jiahao XU <[email protected]>
2023-08-10 19:50:14 +02:00
Jiahao XU b919e1427f feat: Add logging to Cargo.lock/Cargo.toml hashing (#156)
There are a few problems in cargo-binstall where sometimes change to
`Cargo.lock` does not invalidate the cache.

Signed-off-by: Jiahao XU <[email protected]>
2023-08-04 12:39:02 +02:00
Arpad Borsos 3312b3ab47 Slightly improve docs 2023-08-02 12:46:45 +02:00
Jiahao XU be7377e68e fix src/config.ts: Remove sort_object (#152)
Fixed #151

I've tried running manually load and parse `Cargo.lock` and it runs fine
until `sort_object` is called.

Since `Cargo.lock` is auto-generated and usually sorted, I think there
is no need for sorting.

Signed-off-by: Jiahao XU <[email protected]>
2023-06-27 08:55:56 +02:00
Jiahao XU 715970feed feat: Add hash of .cargo/config.toml to key (#149)
Also:
 - Add and use `sort_and_uniq` to make sure `globFile` resulting
   and `keyFiles` does not contain duplicates.
 - Only returns regular file in function `globFile`

Signed-off-by: Jiahao XU <[email protected]>
2023-06-18 10:12:25 +02:00
Jiahao XU 3d4000164d feat: Rm workspace crates version before caching (#147)
Fixed #146

 - Set all `package.version` in `Cargo.toml` to `0.0.0`
 - Set `{build-, dev-, }dependencies` of workspace crates to `0.0.0`
 - Remove workspace crates from `Cargo.lock` before caching
 - Sort all toml objects before hashing them as json

Signed-off-by: Jiahao XU <[email protected]>
2023-06-18 09:29:44 +02:00
Steven Hartland bb80d0f127 chore: use 8 character hash components (#143)
Use 8 character hash components to reduce the key length, making it
more readable.

Fixes #97
2023-05-19 20:30:37 +02:00
Steven Hartland ad97570a01 fix: cache key stability (#142)
Ensure consistency of main and post configuration by storing and
restoring it from state, which in turn ensures cache key stability.

Also:
* Fixed some typos.
* Use core.error for logging errors.
* Fix inverted condition on cache-all-crates.

Reverts: #138
Fixes #140
2023-05-18 22:48:40 +02:00
Steven Hartland 827c240e23 fix: cache key dependency on installed packages (#138)
Add the installed packages to the environment element of the cache key
so that CI tooling is considered. This ensures that rust CI tooling is
cached correctly when changes occur. Prior to this a manual key change
or cache expiry would need to occur before CI tools were correctly
cached.
2023-05-11 23:12:12 +02:00
Felix Riegger 99229f978c Fix EISDIR error due to globbed directories (#1) (#132) 2023-05-02 21:49:27 +02:00
Arpad Borsos e78327dd9e small code style improvements, README and CHANGELOG updates 2022-11-06 09:50:33 +01:00
Lucas Fernandes Nogueira ccdddcc049 only hash Cargo.toml/Cargo.lock that belong to a configured workspace (#90) 2022-11-05 21:18:04 +01:00
Mikhail Katychev b8e72aae83 Added prefix-key cache-directories and cache-targets options (#85) 2022-10-18 23:05:42 +02:00
Arpad Borsos 622616010e prepare v2 2022-07-16 12:38:38 +02:00
Arpad Borsos 7b8626742a update registry cleaning 2022-07-09 18:51:34 +02:00
Arpad Borsos 827b33fbd0 pretty printing and fix workspace package retrieval 2022-07-09 15:51:45 +02:00
Arpad Borsos cb43a50800 fix env filtering 2022-07-09 15:31:33 +02:00
Arpad Borsos 11be10514b fix pretty printing 2022-07-09 15:25:09 +02:00
Arpad Borsos 6ed4c28a7c rewrite it all 2022-07-09 15:19:29 +02:00