A GitHub Action that implements smart caching for rust/cargo projects
Go to file
Arpad Borsos d38127a85b Improve target pruning
fixes #1
2020-09-29 12:30:19 +02:00
.github initial commit 2020-09-26 23:48:29 +02:00
dist Improve target pruning 2020-09-29 12:30:19 +02:00
src Improve target pruning 2020-09-29 12:30:19 +02:00
.gitignore initial commit 2020-09-26 23:48:29 +02:00
action.yml initial commit 2020-09-26 23:48:29 +02:00
CHANGELOG.md Improve target pruning 2020-09-29 12:30:19 +02:00
package-lock.json 1.0.1 2020-09-28 13:06:41 +02:00
package.json 1.0.1 2020-09-28 13:06:41 +02:00
README.md update readme 2020-09-28 12:51:40 +02:00
tsconfig.json initial commit 2020-09-26 23:48:29 +02:00

Rust Cache Action

A GitHub Action that implements smart caching for rust/cargo projects

Inputs

  • key - An optional key for the target cache. This is useful in case you have different jobs for test / check / clippy, etc

Example usage

- uses: Swatinem/rust-cache@v1
  with:
    key: test

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 assumption is that we will likely recompile the own crate(s) anyway.

It also separates the cache into 4 groups, each treated differently:

  • Registry Index: ~/.cargo/registry/index/<registry>:

    This is always restored from its latest snapshot, and persisted based on the most recent revision.

  • Registry Cache: ~/.cargo/registry/cache/<registry>:

    Automatically keyed by the lockfile/toml hash, and is being pruned to only persist the dependencies that are being used.

  • target: ./target

    Automatically keyed by the lockfile/toml hash, and is being pruned to only persist the dependencies that are being used. This is especially throwing away any intermediate artifacts.