Parallel RSpec Tests on CircleCI With JUnit XML Reports

You will learn how to run RSpec tests for your Ruby on Rails project on CircleCI with parallel jobs to shorten the running time of your CI build. Moreover, you will learn how to configure JUnit formatter to generate an XML report for your tests to show failing RSpec test examples nicely in CircleCI web UI. Finally, you will see how to automatically detect slow spec files and divide their test examples between parallel jobs to eliminate the bottleneck job that’s taking too much time to run tests.

Ruby Gems to Configure Your RoR Project

Here are the key elements you need:

How to Run GitLab CI Pipeline With Parallel RSpec Tests in Ruby

GitLab CI allows you to run tests much faster thanks to its CI parallelization feature. You can run parallel jobs across multiple GitLab Runners. In order to do it, you will learn how to split tests in a dynamic way across parallel tasks to ensure there is no bottleneck in GitLab Pipeline. Thanks to that CI build can be run as fast as possible so your Ruby and JS tests can be finely fast.

GitLab CI Parallelization

The common problem when you want to run tests in parallel to complete your one-hour test suite in a few minutes instead of waiting hours is to find a way to split tests on parallel jobs. Some of your Ruby or JavaScript tests can take milliseconds and some even a few minutes per test file (for instance, when using Capybara in RSpec features testing). The problem with slow tests also occurs in E2E (end to end testing) when using Cypress test runner as browser testing can take quite a long time to execute.

Fast CI Build Time With Parallel Jobs on Semaphore CI for RSpec, Cypress, and Jest Tests

Semaphore CI 2.0 allows for configuring your CI build task with parallel jobs. This way, you can run simultaneously a few different commands that do not depend on each other. But we could also use parallel jobs to split your test suite across a few jobs and save time this way. I will show you how to speed up your CI build for your Ruby or JavaScript project (Rails/Node project).

With Semaphore CI 2.0, you don’t pay for a reserved amount of containers that can be run in parallel as in some other CI providers. Instead, they count the amount of work time spent on running containers. This creates an incentive to run more parallel jobs to execute our tests fast and still keep bill at a similar level as if we would just run all tests in single container waisting our own time.

Run RSpec on GitHub Actions in the Shortest Time Using Parallel Jobs

GitHub introduced their own CI server solution called GitHub Actions. You will learn how to set up your Ruby on Rails application on GitHub Actions with the YAML config file. To run your RSpec test suite faster, you will configure parallel jobs with matrix strategy on GitHub Actions.

Automate Your Workflow on GitHub Actions

GitHub Actions makes it easy to automate all your software workflows with world-class CI/CD. The building, testing, and deploying your code right from GitHub became available with simple YAML configuration.