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

Override the existing cache key #170

Open
cornelius-span opened this issue Sep 12, 2023 · 5 comments
Open

Override the existing cache key #170

cornelius-span opened this issue Sep 12, 2023 · 5 comments

Comments

@cornelius-span
Copy link

I am trying to create essentially a common cache across multiple branches regardless of lockfile sum. In the documentation it is specified that the 'shared-key' field is:

A cache key that is used instead of the automatic job-based key

however when I specify a 'shared-key' the lock files and other parameters are still used in the cache key which results in many copies of the cache (which is quite large). I am wondering:

a) is it possible to fully specify the cache key
b) what is the preferred method for reusing a single cache across multiple branches with modifications.

I understand that this will probably slow down build times slightly because the incremental build will not be a perfect fit however it is preferable than rebuilding from scratch (and creating a ~2gb cache) each time a new branch is pushed

@NobodyXu
Copy link
Contributor

however it is preferable than rebuilding from scratch (and creating a ~2gb cache) each time a new branch is pushed

GitHub Action cache can be shared between branches.

If a branch is created from main, then it can reuse cache from main.

If a branch is created from branch dev, which is then created from main, then you can reuse cache from dev and main.

@cornelius-span
Copy link
Author

cornelius-span commented Sep 13, 2023

I understand but this is based on the cache key. Currently when I specify a "shared-key" or "key" ex:

with:
workspaces: "${{ env.DIRS }}"
shared-key: "${{ matrix.ci_node_index }}-Rust"

the cache key ends up looking something like:
v0-rust-0-Rust-593f00b5-f42bcd39

which means that it is still using the hash of the cargo lock files which I dont want to do (I want to just have a common cache that is only updated by pushes to main but is always pulled in on all feature branches).

I want the cache key to just be something like:
1-Rust

@KiraCoding
Copy link

I require this too, I want my pull requests to re-use the main branch cache, but it always creates a new branch based cache instead of re-using/updating the main branch cache, either I misunderstood how this whole thing works or it's simply not implemented?

@NobodyXu
Copy link
Contributor

@KiraCoding If you modify cargo toolchain, cargo/rust envs, Cargo.toml/Cargo.lock, then rust-cache would restore cache from main and upload a new one to the branch.

GHA has cache protection rules that forbidden PR/branches GHA run cache to be reused in main, though they can always reuse cache they are branched from.

@NobodyXu
Copy link
Contributor

@cornelius-span That's probably a bug then

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

No branches or pull requests

3 participants