Ruby on Rails Minitest on Github Actions: Parallel Testing

You can use Github Actions build matrices to divide Minitest files between jobs and run the test suite much faster.

How to run Ruby on Rails tests in Minitest on Github Actions? What to do if tests are slow? How to manage complex workflows? You can use Github Actions build matrices to divide Minitest files between jobs and run the test suite much faster.

If your Minitest tests are taking dozens of minutes and you would like to save some time for your Ruby engineering team then you could use tests parallelization on your CI server.

To run tests as fast as possible you need to split them into equal buckets (into parallel jobs). But how to do it? Some of the test files can be super fast to execute, other Minitest files can take minutes if they run system tests (E2E tests).

There is also an aspect of preparing the test environment for each parallel job. By preparing I mean you need to clone a repository, install ruby gems or load them from a cache, maybe you need to load some docker container, etc. This can take various amounts of time on each parallel job. Random network errors happen like network delay to  load cached gems, or maybe Github Actions from time to time will start one of your jobs late compared to others. It’s an inevitable issue in the network environment and can cause your tests to run for a different amount of time on each parallel job. This is visible on the graph below and it causes the CI build to be slower.

not optimal tests split on CI server, CI parallelism

#tutorial #devops #qa #github actions #github

What is GEEK

Buddha Community

Ruby on Rails Minitest on Github Actions: Parallel Testing

Ruby on Rails Development Services | Ruby on Rails Development

Ruby on Rails is a development tool that offers Web & Mobile App Developers a structure for all the codes they write resulting in time-saving with all the common repetitive tasks during the development stage.

Want to build a Website or Mobile App with Ruby on Rails Framework

Connect with WebClues Infotech, the top Web & Mobile App development company that has served more than 600 clients worldwide. After serving them with our services WebClues Infotech is ready to serve you in fulfilling your Web & Mobile App Development Requirements.

Want to know more about development on the Ruby on Rails framework?


Share your requirements

View Portfolio

#ruby on rails development services #ruby on rails development #ruby on rails web development company #ruby on rails development company #hire ruby on rails developer #hire ruby on rails developers

Github Actions auto split of slow RSpec test file in parallel jobs for Ruby, Rails project

Splitting your CI build jobs between multiple machines running in parallel is a great way to make the process fast, which results in more time for building features. Github Actions allows running parallel jobs easily. In a previous article, we explained how you can use  Knapsack Pro to  split your RSpec test files efficiently between parallel jobs on GitHub Actions. Today we’d like to show how to address the problem of slow test files negatively impacting the whole build times.

Consider the split

Imagine you have a project with 30 RSpec spec files. Each file contains multiple test examples (RSpec “

its”). Most of the files are fairly robust, fast unit tests. Let’s say there are also some slower files, like feature specs. Perhaps one such feature spec file takes approximately 5 minutes to execute.

When we run different spec files on different parallel machines, we strive for similar execution time on all of them. In a described scenario, even if we run 30 parallel jobs (each one running just one test file), the 5 minute feature spec would be a bottleneck of the whole build. 29 machines may finish their work in a matter of seconds, but the whole build won’t be complete until the 1 remaining node finishes executing its file.

#github #github-actions #rspec #ruby #ruby-on-rails #test-automation #devops #good-company

Oral  Brekke

Oral Brekke


Caching Ruby Gems on Github Actions Using ruby/setup-ruby or actions/cache

How do you cache Ruby gems on Github Actions CI? There are actually 2 ways of doing it with ruby/setup-ruby or actions/cache.

How to start CI build faster by loading Ruby gems from cache on Github Actions? You can start running your tests for a Ruby on Rails project quicker if you manage to set up all dependencies in a short amount of time. Caching can be helpful with that. Ruby gems needed for your project can be cached by Github Actions and thanks to that they can be loaded much faster when you run a new CI build.

You will learn how to configure Github Actions using:

  • actions/cache — it’s a popular solution to cache Ruby gems.
  • ruby/setup-ruby — it’s a solution to install a specific Ruby version and cache Ruby gems with bundler. Two features in one action.

Actions/cache — Just Cache Dependencies

Actions/cache is a popular solution that can be used to save data into the cache and restore it during the next CI build. It’s often used for Ruby on Rails projects that also use actions/setup-ruby for managing the Ruby version on Github Actions.

Let’s look at the Github Actions caching config example using actions/cache.

## .github/workflows/main.yml
name: Main
on: [push, pull_request]
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2

      - uses: actions/cache@v2
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: Bundle install
          RAILS_ENV: test
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3

#ruby #testing #tech #github #ruby on rails #cache #tests

Emily Johnson


Hire Ruby on Rails Developer | Hire RoR Developer

Are you looking for Ruby on Rails developers for building next-generation web applications?

Bacancy Technology is top-notch Ruby on Rails development company providing world’s best Ruby On Rails Development Services With 8+ Years Of Experience. Hire Ruby on Rails developer for web application that reflects cutting-edge solutions for your business needs. Access 40+ RoR developers. save upto 40% on development cost.

Get top Ruby on Rails developers from Bacancy Technology, contact now and hire your choice of developer’s within 48 Hours, to know more about our RoR services & pricing:

ruby on rails development

#hire ruby on rails developer #ruby on rails developer #ruby on rails development company #ruby on rails development services #hire ror developer #ruby on rails development

RSpec Tests Config for Github Actions in Ruby on Rails Project

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
    ## 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