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

Better cache busting when using dependency-versions: 'highest' #234

Closed
desrosj opened this issue Oct 13, 2022 · 3 comments · Fixed by #239
Closed

Better cache busting when using dependency-versions: 'highest' #234

desrosj opened this issue Oct 13, 2022 · 3 comments · Fixed by #239
Labels
enhancement New feature or request

Comments

@desrosj
Copy link
Contributor

desrosj commented Oct 13, 2022

Better cache busting when using highest dependency versions

Using dependency-versions: 'highest' is the equivalent to running composer update, ensuring the latest versions of these dependencies are always used.

When it comes to cache keys, the key is unaware of when updates are available since the composer.(json|lock) files (hashed and used as part of the cache key) are not always updated to reflect these changes (the benefit of using highest is you don't have to).

Background/problem

If a project goes a long time without updating their composer.(json|lock) files, it's possible that the cache restored could become really outdated This reduces the benefit of the cache since update will need to pull new versions every workflow run.

Proposal/solution

One way to fix this could be to include a date in the cache key when using highest. In WordPress/wordpress-develop, we chose to use the date for the previous Monday to ensure the cache was refreshed at least once a week.

@desrosj desrosj added the enhancement New feature or request label Oct 13, 2022
@jrfnl
Copy link
Contributor

jrfnl commented Oct 14, 2022

May I suggest a slightly more flexible solution ?

You can currently already set a custom cache key, but that is cumbersome as the basic cache key used in the ramsey/composer-install action is pretty good to begin with.

What about having an option to set a custom-cache-extra parameter which would be added to the cache key currently in use ?

That way each project could decide for themselves what would be a reasonable additional parameter to use. WordPress can use the date of a week ago, but another project may want to set this to a month ago or even to something completely unrelated to dates, like the current branch name for long-running branches.

How does that sound ?

@desrosj
Copy link
Contributor Author

desrosj commented Oct 14, 2022

What about having an option to set a custom-cache-extra parameter which would be added to the cache key currently in use ?

That sounds great!

@jrfnl
Copy link
Contributor

jrfnl commented Oct 14, 2022

FYI: I've got a PR for this ready, but CI needs to be fixed first as otherwise the build will fail no matter what, see #236 and #237.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants