Skip to content

Allow customising project ID in cache key rather than it always including working directory#905

Open
ZimbiX wants to merge 1 commit intoruby:masterfrom
ZimbiX:remove-pwd-from-bundler-cache-key
Open

Allow customising project ID in cache key rather than it always including working directory#905
ZimbiX wants to merge 1 commit intoruby:masterfrom
ZimbiX:remove-pwd-from-bundler-cache-key

Conversation

@ZimbiX
Copy link
Copy Markdown

@ZimbiX ZimbiX commented Apr 21, 2026

Resolves #904

I decided to go with something simple rather than using the Git repo remote URL which I'd first thought to use. The URL might not suit all use-cases - perhaps someone has multiple bundles in the one repo (hence you having added the workdir to distinguish). Instead, a simple customisable string value project-id would allow using the action multiple times in a job for different directories with a different project-id.

Testing

Tested and working in our GitHub Actions workflow using:

      # Fork of ruby/setup-ruby to support ephemeral workdir
      - uses: ZimbiX/setup-ruby@remove-pwd-from-bundler-cache-key
        with:
          ruby-version: 3.3.6
          bundler-cache: true
          project-id: better_caring

Logs:

Cache key: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.3.6-better_caring-with--without--only--Gemfile.lock-3f96ad38961e7a44e242400b976a8833512d7d013bd35c5f24b09672d2fd2667
Cache hit for: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.3.6-better_caring-with--without--only--Gemfile.lock-3f96ad38961e7a44e242400b976a8833512d7d013bd35c5f24b09672d2fd2667
Received 0 of 140644053 (0.0%), 0.0 MBs/sec
Received 0 of 140644053 (0.0%), 0.0 MBs/sec
Received 8388608 of 140644053 (6.0%), 2.7 MBs/sec
Received 46137344 of 140644053 (32.8%), 11.0 MBs/sec
Received 100663296 of 140644053 (71.6%), 19.2 MBs/sec
Received 136449749 of 140644053 (97.0%), 21.7 MBs/sec
Received 140644053 of 140644053 (100.0%), 20.8 MBs/sec
Cache Size: ~134 MB (140644053 B)
/usr/bin/tar -xf /codebuild/output/src2839699089/src/actions-runner/_work/_temp/e8390f69-4590-46ba-aa6f-789b62f5e608/cache.tzst -P -C /codebuild/output/src2839699089/src/actions-runner/_work/better_caring/better_caring --use-compress-program unzstd
Cache restored successfully
Found cache for key: setup-ruby-bundler-cache-v6-ubuntu-22.04-x64-ruby-3.3.6-better_caring-with--without--only--Gemfile.lock-3f96ad38961e7a44e242400b976a8833512d7d013bd35c5f24b09672d2fd2667

…ding working directory

To fix cache key consistency for builds with an ephemeral working directory
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.

Bundler cache not working due to ephemeral workdir

1 participant