This commit is contained in:
Miles Johnson 2023-11-17 10:12:15 -08:00
parent d7d917b850
commit 8a603fb6f3
4 changed files with 23 additions and 2 deletions

View file

@ -1,5 +1,7 @@
# 1.1.0
- Added a `cache-base` input. When provided, will only save cache on this branch/ref, but will
restore cache on all branches/refs.
- Updated dependencies.
# 1.0.3

View file

@ -22,6 +22,8 @@ optional.
- `bins` - Comma-separated list of global binaries to install into Cargo.
- `cache` - Toggle caching of directories. Defaults to `true`.
- `cache-base` - Base branch/ref to save a warmup cache on. Other branches/refs will restore from
this base.
- `cache-target` - Name of the target profile to cache. Defaults to `debug`.
- `channel` - Toolchain specification/channel to explicitly install.
- `components` - Comma-separated list of additional components to install.
@ -135,6 +137,23 @@ The following optimizations and considerations are taken into account when cachi
> The following sources are hashed for the generated cache key: `$GITHUB_JOB`, `Cargo.lock`, Rust
> version, Rust commit hash, and OS.
### Warmup strategy
Another strategy that we support is called a warmup cache, where a base branch/ref is used to
generate and save the cache (like master), and all other branches/refs will _only_ restore this
cache (and not save).
This can be enabled with the `cache-base` input, which requires a branch/ref name. This input also
supports regex.
```yaml
- uses: moonrepo/setup-rust@v1
with:
cache-base: master
# With regex
cache-base: (master|main|develop)
```
## Compared to
### `actions-rs/*`

View file

@ -11,8 +11,7 @@ inputs:
default: true
cache-base:
description:
'Base branch or ref to save a warmup cache. Other branches and refs will restore from this
base.'
'Base branch/ref to save a warmup cache on. Other branches/refs will restore from this base.'
cache-target:
description: 'Name of the target profile to cache.'
default: 'debug'

View file

@ -49,6 +49,7 @@ export async function getPrimaryCacheKey() {
if (core.getInput('cache-base')) {
core.debug('Using warmup strategy, not hashing Cargo.lock, GITHUB_WORKFLOW, or GITHUB_JOB');
hasher.update('warmup');
}
// When warming up, these add far too much granularity to the cache key