Using CI and/or GitHub Actions? A common issue you might run into is that your CI environment is looking for the 'instrumental-components-library' gem, but it's not available since it's a private gem that is only available on your local system.
To resolve this, here are instructions for reconfiguring your CI workflow and Gemfile so that:
instrumental-components-library
gem) remains available for use in your local development environment (which is only where it's needed, anyway)instrumental-components-library
gem, and will not attempt to install itThe following assumes you're using the default GitHub CI workflow localted in .github/workflows/ci.yml
, which comes pre-installed when you start a new Rails application. You can adjust and adapt the following instructions to fit your own CI workflow.
instrumental-components-library
to a 'private' group in your Gemfile.By default, the instrumental-components-library
gem is installed in the development
group in your Gemfile. To ensure that your CI environment doesn't attempt to install it, you'll need to move it out of the development
group and into a 'private' group.
Before:
...
group :development do
gem 'instrumental-components-library'
end
...
After:
...
group :private do
gem 'instrumental-components-library'
end
...
In your .github/workflows/ci.yml
file, you should see ~4 instances of "Set up Ruby" in the jobs
sections. You'll need to update each of these to set bundler-cache
to false
.
Before:
...
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
...
After:
...
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: false
...
Still in your .github/workflows/ci.yml
file, below each instance of "Set up Ruby", add an additional step that installs gems and excludes the private gems group.
Add this:
...
- name: Install gems (excluding private group)
run: |
bundle config set without 'private'
bundle install
...
After making the above updates, the full .github/workflows/ci.yml file should look like (something like) this:
name: CI
on:
pull_request:
push:
branches: [ main ]
jobs:
scan_ruby:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: false
- name: Install gems (excluding private group)
run: |
bundle config set without 'private'
bundle install
- name: Scan for common Rails security vulnerabilities using static analysis
run: bin/brakeman --no-pager
scan_js:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: false
- name: Install gems (excluding private group)
run: |
bundle config set without 'private'
bundle install
- name: Scan for security vulnerabilities in JavaScript dependencies
run: bin/importmap audit
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: false
- name: Install gems (excluding private group)
run: |
bundle config set without 'private'
bundle install
- name: Lint code for consistent style
run: bin/rubocop -f github
test:
runs-on: ubuntu-latest
# services:
# redis:
# image: redis
# ports:
# - 6379:6379
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config google-chrome-stable
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: false
- name: Install gems (excluding private group)
run: |
bundle config set without 'private'
bundle install
- name: Run tests
env:
RAILS_ENV: test
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:test:prepare test test:system
- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: ${{ github.workspace }}/tmp/screenshots
if-no-files-found: ignore
I created Instrumental Components to make designing and building professional apps with Ruby on Rails easy, fast, and fun. I use it on all of my projects and I hope it helps you build something great.