Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fallback on caches from other cache groups #23

Merged
merged 1 commit into from
Aug 7, 2024
Merged

Do not fallback on caches from other cache groups #23

merged 1 commit into from
Aug 7, 2024

Conversation

BD103
Copy link
Collaborator

@BD103 BD103 commented Aug 7, 2024

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 outdated Cargo.lock and Cargo.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 runs cargo test. Both have different cache requirements.

  1. 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.
  2. 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 download cargo test's larger cache. Then, when cargo check saves a new cache, it contains all of the unnecessary binaries that cargo test generated, increasing the cache size and download time.

Solution

Prevent separate cache groups from sharing caches by removing the final restore key.

Copy link
Collaborator

@TimJentzsch TimJentzsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@TimJentzsch
Copy link
Collaborator

The question is now: Does this warrant v3 or can we stay v2?

@alice-i-cecile
Copy link
Contributor

I think v2 is fine; can you add a tag?

@alice-i-cecile alice-i-cecile merged commit 9ba9627 into Leafwing-Studios:main Aug 7, 2024
@BD103
Copy link
Collaborator Author

BD103 commented Aug 7, 2024

The question is now: Does this warrant v3 or can we stay v2?

I don't think this warrants v3. The only reason you would depend on this behavior is to share caches, but that's what cache groups are for.

@BD103 BD103 deleted the cache-group-fallback branch August 7, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't share caches between different jobs by default
3 participants