Skip to content

Commit 73f9085

Browse files
justin808claude
andauthored
Split rspec-package-tests into parallel generator/unit shards (#3134)
## Summary - Splits the `rspec-package-tests` CI job into two parallel matrix shards: **generators** (429 examples with heavy filesystem I/O) and **unit** (584 examples covering everything else) - Applies to both PR (latest-only) and main (latest + minimum) matrix configurations - Artifact names updated to include shard name to avoid collisions Expected CI time reduction: ~24 min → ~12 min. Closes #3131 ## Test plan - [ ] Verify both `generators` and `unit` shard jobs appear in the CI matrix - [ ] Confirm generator shard runs only `spec/react_on_rails/generators` - [ ] Confirm unit shard runs `spec/react_on_rails` excluding generators - [ ] Check artifact names are unique per shard - [ ] Verify full matrix on main includes 4 jobs (2 Ruby versions × 2 shards) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it changes CI execution by splitting the RSpec suite into shard-specific commands and adjusts test initialization to suppress Minitest/Test::Unit autorun behavior, which could affect what tests run and how failures surface. > > **Overview** > Splits `rspec-package-tests` into two parallel matrix shards (`generators` vs `unit`) for both PR and full (main/`full-ci`) runs, and runs shard-specific RSpec commands (generators-only vs everything excluding generators). > > Updates uploaded artifact names to include the shard to avoid collisions, and tweaks both `spec_helper.rb` files to `require "minitest"` and disable Minitest/Test::Unit autorun hooks so RSpec CLI args don’t get parsed by Minitest during CI/test boot. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7b8a9c8. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated CI to run tests in parallel shards (generators and unit), improving feedback speed and artifact reporting. * **Bug Fixes** * Stabilized test boot process to prevent interfering test runners during spec runs, improving test reliability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e7aef5c commit 73f9085

3 files changed

Lines changed: 36 additions & 9 deletions

File tree

.github/workflows/gem-tests.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ jobs:
8686
- id: set-matrix
8787
run: |
8888
# Determine if we should run full matrix (main or full-ci label)
89+
# Each Ruby version / dependency level is split into two shards:
90+
# generators – spec/react_on_rails/generators (heavy filesystem I/O)
91+
# unit – everything else under spec/react_on_rails
8992
if [[ "${{ github.ref }}" == "refs/heads/main" ]] || \
9093
[[ "${{ needs.detect-changes.outputs.has_full_ci_label }}" == "true" ]]; then
91-
# Full matrix: test both latest and minimum supported versions
92-
echo 'matrix={"include":[{"ruby-version":"3.4","dependency-level":"latest"},{"ruby-version":"3.2","dependency-level":"minimum"}]}' >> $GITHUB_OUTPUT
94+
# Full matrix: test both latest and minimum supported versions × 2 shards
95+
echo 'matrix={"include":[{"ruby-version":"3.4","dependency-level":"latest","shard":"generators"},{"ruby-version":"3.4","dependency-level":"latest","shard":"unit"},{"ruby-version":"3.2","dependency-level":"minimum","shard":"generators"},{"ruby-version":"3.2","dependency-level":"minimum","shard":"unit"}]}' >> $GITHUB_OUTPUT
9396
else
94-
# PR matrix: test only latest versions for fast feedback
95-
echo 'matrix={"include":[{"ruby-version":"3.4","dependency-level":"latest"}]}' >> $GITHUB_OUTPUT
97+
# PR matrix: test only latest versions for fast feedback × 2 shards
98+
echo 'matrix={"include":[{"ruby-version":"3.4","dependency-level":"latest","shard":"generators"},{"ruby-version":"3.4","dependency-level":"latest","shard":"unit"}]}' >> $GITHUB_OUTPUT
9699
fi
97100
98101
rspec-package-tests:
@@ -152,14 +155,22 @@ jobs:
152155
run: |
153156
echo "CI_DEPENDENCY_LEVEL=${{ matrix.dependency-level }}" >> $GITHUB_ENV
154157
- name: Run rspec tests
155-
run: cd react_on_rails && bundle exec rspec spec/react_on_rails
158+
env:
159+
SHARD: ${{ matrix.shard }}
160+
run: |
161+
cd react_on_rails
162+
if [[ "$SHARD" = "generators" ]]; then
163+
bundle exec rspec spec/react_on_rails/generators
164+
else
165+
bundle exec rspec spec/react_on_rails --exclude-pattern "**/generators/**"
166+
fi
156167
- name: Store test results
157168
uses: actions/upload-artifact@v4
158169
with:
159-
name: main-rspec-${{ github.run_id }}-${{ github.job }}-ruby${{ matrix.ruby-version }}-${{ matrix.dependency-level }}
170+
name: main-rspec-${{ github.run_id }}-${{ github.job }}-ruby${{ matrix.ruby-version }}-${{ matrix.dependency-level }}-${{ matrix.shard }}
160171
path: ~/rspec
161172
- name: Store artifacts
162173
uses: actions/upload-artifact@v4
163174
with:
164-
name: main-test-log-${{ github.run_id }}-${{ github.job }}-ruby${{ matrix.ruby-version }}-${{ matrix.dependency-level }}
175+
name: main-test-log-${{ github.run_id }}-${{ github.job }}-ruby${{ matrix.ruby-version }}-${{ matrix.dependency-level }}-${{ matrix.shard }}
165176
path: log/test.log

react_on_rails/spec/react_on_rails/spec_helper.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@
1414
require "rspec/retry"
1515

1616
require "action_controller"
17+
require "minitest"
1718

1819
require "rails"
20+
21+
# Prevent Minitest's at_exit runner from parsing RSpec-only CLI args after
22+
# rails/test_help loads ActiveSupport's autorun hooks.
23+
# rubocop:disable Style/ClassVars
24+
Minitest.class_variable_set(:@@installed_at_exit, true) if Minitest.class_variable_defined?(:@@installed_at_exit)
25+
# rubocop:enable Style/ClassVars
26+
1927
require "rails/test_help"
2028
Rails.backtrace_cleaner.remove_silencers!
2129

2230
require_relative "simplecov_helper"
2331

24-
# prevent Test::Unit's AutoRunner from executing during RSpec's rake task
32+
# Prevent Test::Unit's AutoRunner from executing during RSpec runs.
2533
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
2634

2735
# This file was generated by the `rails generate rspec:install` command. Conventionally, all

react_on_rails_pro/spec/react_on_rails_pro/spec_helper.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@
1111
require "pry-byebug"
1212

1313
require "action_controller"
14+
require "minitest"
1415
require "rails"
16+
17+
# Prevent Minitest's at_exit runner from parsing RSpec-only CLI args after
18+
# rails/test_help loads ActiveSupport's autorun hooks.
19+
# rubocop:disable Style/ClassVars
20+
Minitest.class_variable_set(:@@installed_at_exit, true) if Minitest.class_variable_defined?(:@@installed_at_exit)
21+
# rubocop:enable Style/ClassVars
22+
1523
require "rails/test_help"
1624
Rails.backtrace_cleaner.remove_silencers!
1725

1826
require_relative "simplecov_helper"
19-
# prevent Test::Unit's AutoRunner from executing during RSpec's rake task
27+
# Prevent Test::Unit's AutoRunner from executing during RSpec runs.
2028
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
2129

2230
require "shakapacker"

0 commit comments

Comments
 (0)