Do not fallback on caches from other cache groups #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #22.
Objective
Github Actions Caches have the ability to "fall back" to multiple caches, if the created cache key is not found. This is by setting the
restore-key
input, and let's us still use caches with outdatedCargo.lock
andCargo.toml
files, as well as other cache groups.This is an issue, because often cache groups do not do the same work. Let me give an example:
You have two jobs: one that runs
cargo check
and another that runscargo test
. Both have different cache requirements.cargo check
does not need to compile anything, so it generates less files. As a result, its cache is smaller, meaning that it downloads faster.cargo test
does need to compile into binaries, so it generates a lot more files. It's cache is larger, but that's fine because it uses the entire cache.If we let the cache action fallback across multiple different jobs,
cargo check
could downloadcargo test
's larger cache. Then, whencargo check
saves a new cache, it contains all of the unnecessary binaries thatcargo test
generated, increasing the cache size and download time.Solution
Prevent separate cache groups from sharing caches by removing the final restore key.