Skip to content
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

Only perform bundler actions / don't install Ruby #489

Open
steveh opened this issue Mar 29, 2023 · 4 comments
Open

Only perform bundler actions / don't install Ruby #489

steveh opened this issue Mar 29, 2023 · 4 comments

Comments

@steveh
Copy link

steveh commented Mar 29, 2023

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?

@AskarZinurov
Copy link

Or maybe it will be possible to set ruby_version: system instead?

@eregon
Copy link
Member

eregon commented May 29, 2023

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.

@AskarZinurov
Copy link

AskarZinurov commented May 29, 2023

@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

@steveh
Copy link
Author

steveh commented Aug 21, 2023

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants