Only perform bundler actions / don't install Ruby
We run actions with a custom Docker image that already contains Ruby and Bundler.
The recommendation is to use this action to cache gems with Bundler, but I don't want it to also install Ruby.
Can we set something like ruby_version: none to skip that part?
Or maybe it will be possible to set ruby_version: system instead?
I'm not clear how actions work inside Docker images, but I suppose they do?
PR welcome. It is not completely trivial, because e.g. the Ruby version should still be part of the cached key and we need to know the Bundler major version.
@eregon yep, seems you are right, for case in issue description, it is much clearer just run bundle install to separate bundler path and then use https://github.com/actions/cache directly. Smth like:
jobs:
specs:
runs-on: ubuntu-latest
container: ruby:2.4.10-stretch
services:
redis:
image: redis:6.2-alpine
ports:
- "6379:6379"
postgres:
image: postgres:11-bullseye
ports:
- "5432:5432"
env:
RAILS_ENV: "test"
BUNDLE_PATH: "/opt/ruby-gemset"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache gemset
id: gemset-cache
uses: actions/cache@v3
with:
path: /opt/ruby-gemset
key: ${{ runner.os }}-${{ hashFiles('Gemfile.lock') }}
- name: Install ruby gems
run: bundle install --jobs 8
- name: Create database config file
run: cp config/database.yml.example config/database.yml
- name: Run tests
run: |
bin/rake db:setup
bin/rspec
It is much clearer just run bundle install to separate bundler path and then use https://github.com/actions/cache directly.
The linked recommendation explicitly says not to do that:
Caching gems with Bundler correctly is not trivial and just using actions/cache is not enough.
Instead, it is recommended to use ruby/setup-ruby's bundler-cache: true option whenever possible: