2020-09-25 22:42:39 +08:00
|
|
|
# Rust Cache Action
|
|
|
|
|
|
|
|
A GitHub Action that implements smart caching for rust/cargo projects
|
|
|
|
|
|
|
|
## Example usage
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
- uses: Swatinem/rust-cache@v1
|
|
|
|
```
|
|
|
|
|
|
|
|
## Specifics
|
|
|
|
|
|
|
|
This action tries to be better than just caching the following directories:
|
|
|
|
|
|
|
|
```
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
|
|
|
```
|
|
|
|
|
|
|
|
It disables incremental compilation and only caches dependencies. The
|
2020-10-03 23:33:09 +08:00
|
|
|
assumption is that we will likely recompile our own crate(s) anyway.
|
2020-09-25 22:42:39 +08:00
|
|
|
|
2020-10-03 23:33:09 +08:00
|
|
|
It also separates the cache into 3 groups, each treated differently:
|
2020-09-25 22:42:39 +08:00
|
|
|
|
2020-09-28 18:51:40 +08:00
|
|
|
- Registry Index: `~/.cargo/registry/index/<registry>`:
|
2020-09-25 22:42:39 +08:00
|
|
|
|
|
|
|
This is always restored from its latest snapshot, and persisted based on the
|
|
|
|
most recent revision.
|
|
|
|
|
2020-09-28 18:51:40 +08:00
|
|
|
- Registry Cache: `~/.cargo/registry/cache/<registry>`:
|
2020-09-25 22:42:39 +08:00
|
|
|
|
|
|
|
Automatically keyed by the lockfile/toml hash, and is being pruned to only
|
|
|
|
persist the dependencies that are being used.
|
|
|
|
|
|
|
|
- target: `./target`
|
|
|
|
|
2020-10-03 23:33:09 +08:00
|
|
|
Automatically keyed by the lockfile, toml hash and job, and is being pruned
|
|
|
|
to only persist the dependencies that are being used. This is especially
|
|
|
|
throwing away any intermediate artifacts.
|