Ensure the following before filing this issue
Are you running on a GitHub-hosted runner or a self-hosted runner?
self-hosted runner
Link to the failed workflow job (must be a public workflow job, so the necessary information is available)
N/A
Any other notes?
We use GitHub Actions runners on AWS CodeBuild with a custom Docker image. The Bundler gems caching is unfortunately not working for us - Bundler installs all gems from scratch on every run. I had a look into why, and noticed a difference in the cache key between jobs, e.g.:
# Run 1
Cache key: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.3.6-wd-/codebuild/output/src3491982091/src/actions-runner/_work/better_caring/better_caring-with--without--only--Gemfile.lock-3f96ad38961e7a44e242400b976a8833512d7d013bd35c5f24b09672d2fd2667
# Run 2
Cache key: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.3.6-wd-/codebuild/output/src1813367680/src/actions-runner/_work/better_caring/better_caring-with--without--only--Gemfile.lock-3f96ad38961e7a44e242400b976a8833512d7d013bd35c5f24b09672d2fd2667
That unfortunately results in being unable to reuse a previous cache.
The cause of the cache key difference is the differing working directory. This looks to be done by CodeBuild for run isolation, which seems fair. I vaguely recall seeing a similar thing with Buildkite.
I looked into the source code of this action to see if the cache key could be configured, and I don't see a way to do that. It seems there is no way to avoid the inclusion of the ephemeral working directory path in the cache key:
|
// cache key |
|
const paths = [cachePath] |
|
const baseKey = await computeBaseKey(engine, rubyVersion, lockFile, cacheVersion) |
|
const key = `${baseKey}-${await common.hashFile(lockFile)}` |
|
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below |
|
const restoreKeys = [`${baseKey}-`] |
|
console.log(`Cache key: ${key}`) |
One option for us could be to change to using a constant workdir; but I'm not confident we won't run into run isolation problems from doing that.
Please consider allowing omission of the workdir from the cache key. I'd suggest replacing it with another way to identify the project - perhaps the Git remote URL (with special characters substituted as necessary).
Thank you for your work on this project =)
Ensure the following before filing this issue
I verified it reproduces with the latest version with
- uses: ruby/setup-ruby@v1(see Versioning policy)I tried to reproduce the issue locally by following the workflow steps (including all commands done byruby/setup-ruby, except forDownloading Ruby&Extracting Ruby),and it did not reproduce locally (if it does reproduce locally, it's not a ruby/setup-ruby issue)
Are you running on a GitHub-hosted runner or a self-hosted runner?
self-hosted runner
Link to the failed workflow job (must be a public workflow job, so the necessary information is available)
N/A
Any other notes?
We use GitHub Actions runners on AWS CodeBuild with a custom Docker image. The Bundler gems caching is unfortunately not working for us - Bundler installs all gems from scratch on every run. I had a look into why, and noticed a difference in the cache key between jobs, e.g.:
That unfortunately results in being unable to reuse a previous cache.
The cause of the cache key difference is the differing working directory. This looks to be done by CodeBuild for run isolation, which seems fair. I vaguely recall seeing a similar thing with Buildkite.
I looked into the source code of this action to see if the cache key could be configured, and I don't see a way to do that. It seems there is no way to avoid the inclusion of the ephemeral working directory path in the cache key:
setup-ruby/bundler.js
Lines 190 to 196 in 7372622
One option for us could be to change to using a constant workdir; but I'm not confident we won't run into run isolation problems from doing that.
Please consider allowing omission of the workdir from the cache key. I'd suggest replacing it with another way to identify the project - perhaps the Git remote URL (with special characters substituted as necessary).
Thank you for your work on this project =)