Are you thinking about migrating a Ruby on Rails project CI pipeline to GitHub Actions? Learn how to configure the Rails app to run RSpec tests using GitHub Actions.

Are you thinking about migrating a Ruby on Rails project CI pipeline to Github Actions? You will learn how to configure the Rails app to run RSpec tests using GitHub Actions.

This article covers a few things for Github Actions YAML config:

  • How to use ruby/setup-ruby action to install Ruby gems with bundler and automatically cache gems. This way you can load Ruby gems for your project from the cache and run CI build fast.
  • How to use Postgres on Github Actions.
  • How to use Redis on Github Actions.
  • How to use Github Actions build matrix to run parallel jobs and execute RSpec tests spread across multiple jobs to save time.

Github Actions YML Config for Rails Application

ruby/setup-ruby Action

ruby/setup-ruby is an action that you can use to install a particular Ruby programming language version. It allows you to cache Ruby gems based on your Gemfile.lock out of the box.

It’s recommended to  use ruby/setup-ruby instead of outdated actions/setup-ruby.

- name: Set up Ruby
  uses: ruby/setup-ruby@v1
  with:
    ## Not needed with a .ruby-version file
    ruby-version: 2.7
    ## runs 'bundle install' and caches installed gems automatically
    bundler-cache: true

#ruby #testing #github #ruby on rails

RSpec Tests Config for Github Actions in Ruby on Rails Project
1.50 GEEK