-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Feature request: support caching for multiple Gemfiles #170
Comments
Would https://github.com/ruby/setup-ruby/blob/master/README.md#matrix-of-gemfiles work for your use-case? |
In each case, the CI job needs both. The top-level Gemfile is actually a gemspec, and specifies the gem's own dependencies. The example repo depends on the gem via |
It sounds like the Implementing caching for multiple |
I understand that supporting multiple caches is nontrivial, but I don't think setting |
Regarding the path, it should be possible to set an absolute path using (https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context): env:
BUNDLE_GEMFILE: ${{ github.workspace }}/example/Gemfile It's the same variable on purpose, so all (2) is a problem if the root Gemfile has extra gems (or needs different versions) compared to the other one, indeed. The only way to make https://github.com/testdouble/test_data/blob/master/script/test work and cache both bundles seems to install with the cache before running that script, and that requires lots of changes (#170 (comment)). I think a good solution might be to split that script in two parts, and run each of those in separate jobs with |
I was trying to set I appreciate your help working through this in this thread, but I think I'm going to give up on trying to cache this for now (my reason for opening this issue was honestly less about this particular project and more about half dozen of other gems I maintain with 1-to-many example apps beneath them) Thank you @eregon <3 |
👋 I have a bit of a niche use-case, I'm writing a library for CI purposes intended to interact with Ruby repositories (as well as other languages). It will execute This library has multiple ruby project fixtures within it for testing, all with their own To enable caching in GH actions, I used multiple What I'm wondering is, would there be any more elegant approach to this? For example supporting multiple Thanks again for your time. |
Multiple I think supporting multiple |
@searls Did you ever find a good solution for this? |
Sorry, I haven't! (But for lack of trying! I don't even remember this issue) |
Multiple |
If this 👆 doesn't work for you, @coderberry I can muster something up using I'm using this setup to cache the bundler deps.
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler: default
ruby-version: ${{ matrix.ruby }}
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-test-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-test-gems-${{ hashFiles('**/Gemfile.lock') }}
- name: Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3 I'm assuming you're running bundle install in multiple directories. The new approach would look something like this (untested): - name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler: default
ruby-version: ${{ matrix.ruby }}
- name: First Gemfile cache
uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-test-gems-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-test-gems-${{ hashFiles('Gemfile.lock') }}
- name: Second Gemfile cache
uses: actions/cache@v3
with:
path: vendor/second_bundle
key: ${{ runner.os }}-test-gems-${{ hashFiles('subdirectory/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-test-gems-${{ hashFiles('subdirectory/Gemfile.lock') }}
- name: First Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Second Bundle install
run: |
bundle config path vendor/second_bundle
bundle install --jobs 4 --retry 3 Now, the It's not the most kosher approach, but it's rather easy to implement and understand later. |
Most of my gems include an example application in
example/
that a test script will exercise, and—in the case of gems that interact with Rails—are usually where all the heavyweight gems are, so that's what would benefit the most from caching.Example:
I'd really love a way to tell the action I've got more than one Gemfile that needs to be installed so that both can benefit from caching.
Thank you!
The text was updated successfully, but these errors were encountered: