Runtime-balanced RSpec and Minitest shards for GitHub Actions, powered by parallel_tests. Timing history is collected and reused automatically.
Requires Ruby 3.3+ and either RSpec or Minitest 5.
Add to your Gemfile and run bundle install:
gem 'parallel_tests-ci', '0.2.1', require: 'parallel_tests/ci/rspec'RSpec matches spec/**/*_spec.rb by default and records timings automatically; no changes to spec_helper.rb are needed.
Add .github/workflows/test.yml:
name: Test
on: [push, pull_request]
permissions:
contents: read
actions: read
jobs:
test:
name: Test
uses: dblock/parallel_tests-ci/.github/workflows/rspec.yml@v0.2.1
with:
shards: 8Add to your Gemfile and run bundle install:
gem 'parallel_tests-ci', '0.2.1', require: 'parallel_tests/ci/minitest'Minitest matches test/**/*_test.rb by default. If your test boot does not call Bundler.require, add require 'parallel_tests/ci/minitest' to test_helper.rb. The timing hook only activates in shard workers.
Add .github/workflows/test.yml:
name: Test
on: [push, pull_request]
permissions:
contents: read
actions: read
jobs:
test:
name: Test
uses: dblock/parallel_tests-ci/.github/workflows/minitest.yml@v0.2.1
with:
shards: 8If you manage your own CI jobs, use the standalone action to plan RSpec or Minitest shards. It defaults to RSpec; set framework: minitest for Minitest. See the RSpec and Minitest examples, replacing uses: ./ with uses: dblock/parallel_tests-ci@v0.2.1. Unlike the reusable workflows, the standalone action only assigns files to shards; your workflow runs the tests and manages timing history.
The workflow uses Ruby from your version file and defaults to Ubuntu. The first run groups tests by file size. Successful pushes on the default branch record timings for later runs, and PRs read them without updating history.
These inputs configure the reusable workflows.
| Input | Default | Purpose |
|---|---|---|
runs-on |
ubuntu-latest |
Runner label or JSON label array for all jobs. |
timeout-minutes |
360 |
Minutes per job, including setup; positive integer. |
max-parallel |
256 |
Concurrent worker limit (1-256). |
fail-fast |
false |
Cancel remaining workers on failure. |
fetch-depth |
1 |
Checkout depth; 0 gets all history and tags. |
ruby-version |
Empty | Override the caller's Ruby version. |
bundler-cache |
true |
Cache gems; false still installs them. |
| Input | Default | Purpose |
|---|---|---|
shards |
4 |
Workers (1-256), capped at test file count. |
worker-name |
{shard.number} of {shard.count} |
Worker label template. |
pattern |
spec/**/*_spec.rb (RSpec), test/**/*_test.rb (Minitest) |
Repository-relative test glob. |
test-options |
[] |
Test framework arguments as a JSON array. |
environment |
{} |
Non-secret env vars as a JSON object. |
before-bundle |
Empty | Shell setup before gem install in all jobs. |
setup |
Empty | Shell setup before tests in each worker. |
Use arguments supported by the selected framework, for example test-options: '["--seed","123"]'.
| Input | Default | Purpose |
|---|---|---|
group-by |
auto |
Choose auto, filesize, or runtime. |
auto: Use runtime history when usable timings cover at least half the selected files. Otherwise, group by file size.filesize: Group by file size without reading timing history. Reusable workflows still collect fresh timings.runtime: Group by runtime. Planning fails if usable timings cover fewer than half the selected files.
| Input | Default | Purpose |
|---|---|---|
artifacts |
Empty | Extra files to keep, even on failure. |
artifact-prefix |
parallel-tests-ci |
Artifact name prefix; unique per call. |
artifact-retention-days |
30 |
Days to keep run artifacts; 0 uses repo default. |
baseline-retention-days |
90 |
Days to keep timing history; 0 uses repo default. |
See Workflow Inputs for templates, secret environments, and setup rules, and Plans and Retries for rerun behavior.
Posebook runs 1,142 examples across eight workers. Times are for the slowest successful RSpec worker, excluding setup and spec loading.
- Serial run: 395s.
- Custom sharding #178: 61.62s.
parallel_testsalone #181: 70.71s.- Cold run #185: 79.11s.
- Warm run #187: 57.59s; timings for 85/95 files.
See Contributing, Coding Guidance, Design, Changelog, Releasing, and Upgrading.
Distributed under the MIT License.