-
-
Notifications
You must be signed in to change notification settings - Fork 341
Description
Hello 👋
I am hoping to discuss whether you'd consider adding inputs that would allow a caller to indicate that they'd like to restore bundler cache but NOT save it at the end of the workflow.
Rationale: In some scenarios, it does not make sense to save the cache. One such scenario is when PRs are running in the merge queue. The branch associated with the PRs being checked looks like gh-readonly-queue/main/pr-15190-f5aefc512c3719594eb22d601d2824ad519d07a0
. This is scoped to a PR and a commit SHA. Due to the way cache restoration via actions/cache
works, this cache will only be used by subsequent runs on the same PR and the same sha only in the queue (which is extremely unlikely, if not impossible--I'm not sure if that SHA is the result of several PRs being combined or what). Anyway, I'd love to avoid adding a bunch of these useless cached objects to the cache and increasing the likelihood of cache thrashing, if at all possible.
Request: I am wondering if it would be as simple as adding a parameter save-cache: true|false
to the action:
- name: Setup Ruby and Bundler
if: ${{ inputs.install_ruby == 'true'}}
uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0
with:
ruby-version: ${{ steps.grab-versions.outputs.ruby_version }}
bundler-cache: true
working-directory: ${{ inputs.bundler_working_directory }}
# Don't cache in the merge queue, it won't be used!
save-cache: ${{ github.event_name != "merge_group" }}
For ultimate clarity, parameters restore-bundler-cache
and save-bundler-cache
would be better.
This is akin to the approach you can take when using actions/cache/restore
and actions/cache/save
directly. We do this in other places within our workflows.
Here's an example screenshot of a cache item in our cache that is using 100MB of space that'll never be used. Depending on the throughput of your repo, this may be significant if you have many PRs:
