Skip to content

Run RSpec in parallel with rspec-core-parallel - #473

Merged
coorasse merged 4 commits into
mainfrom
feature/rspec-core-parallel
Nov 6, 2026
Merged

coorasse merged 4 commits into
mainfrom
feature/rspec-core-parallel

Conversation

@coorasse

@coorasse coorasse commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Replaces parallel_tests with rspec-core-parallel in the RSpec setup:

  • rspec-core-parallel goes in the :test group, parallel_tests is removed
  • require "rspec/core/parallel" at the top of spec/spec_helper.rb
  • bin/check runs bundle exec rspec instead of bundle exec parallel_rspec
  • New CI section: the main test database is still created with db:create db:schema:load, and tmp/rspec_parallel_run_times.txt is cached between Semaphore builds by the renuo configure-semaphore template (renuo/renuo-cli#356)

The suite is loaded once and forked into one worker per physical core. Each worker gets its own test database, created automatically, and the run produces a single report and exit code. SimpleCov results are merged without extra configuration. Already in use in migrolino and cobra.

It replaces parallel_tests: the suite is loaded once and forked into
workers, with a test database per worker, a single report and one exit
code, and plain `rspec` runs in parallel.
@coorasse coorasse self-assigned this Nov 6, 2026
Alessandro Rodi added 2 commits November 6, 2026 15:39
The main test database is created as before, the workers' ones by the
gem. The run times file has to be cached between builds, otherwise the
workers can't start with the longest groups.
renuo configure-semaphore now sets it up.
Comment thread ruby_on_rails/rspec.md Outdated
Comment on lines +169 to +170
* Create the test database with `bin/rails db:create db:schema:load`, as the Semaphore template does, and not with
`parallel:create`. The databases of the workers (`test_0`, `test_1`, ...) are created by the gem, also when

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "and not with parallel:create"? remove that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5db016b

Comment thread ruby_on_rails/rspec.md Outdated
Comment on lines +173 to +177
between builds, so that the workers start with the longest groups: the tests block restores it with
`source .semaphore/bin/cache_restore run_times` and stores it after `bin/check` with
`source .semaphore/bin/cache_store run_times` (only on `main` and `develop`).
In existing projects, copy the `run_times` cache group from the
[templates](https://github.com/renuo/renuo-cli/tree/main/lib/renuo/cli/templates/semaphore).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove everything from ", so..." onwards

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5db016b

@coorasse
coorasse merged commit b41c20a into main Nov 6, 2026
2 checks passed
@coorasse
coorasse deleted the feature/rspec-core-parallel branch November 6, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant