Skip to content

Parallelize rspec tests#7972

Open
akarki2005 wants to merge 8 commits into
MarkUsProject:masterfrom
akarki2005:parallelize-rspec-tests
Open

Parallelize rspec tests#7972
akarki2005 wants to merge 8 commits into
MarkUsProject:masterfrom
akarki2005:parallelize-rspec-tests

Conversation

@akarki2005
Copy link
Copy Markdown
Contributor

@akarki2005 akarki2005 commented Jun 1, 2026

Proposed Changes

Adds the parallel_tests gem to run RSpec tests in parallel, reducing CI test suite runtime. Each parallel worker gets its own isolated test database using the TEST_ENV_NUMBER environment variable. System tests continue to run sequentially as they require a browser.

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration) X

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • [N/A] I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • [N/A] I have updated the project documentation, if applicable.
    • This is required for new features.
  • [N/A] If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

@akarki2005
Copy link
Copy Markdown
Contributor Author

akarki2005 commented Jun 1, 2026

Hi @david-yz-liu, I'm seeing that the CI run is failing due to the parallel_tests gem not getting installed properly - I made a commit to try and address this, but I think the bundle cache is stale, and I'm unable to change Gemfile.lock to re-trigger it. Are you able to clear the Actions cache for my PR? Thanks :)

@akarki2005 akarki2005 requested a review from david-yz-liu June 1, 2026 01:28
Copy link
Copy Markdown
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@akarki2005 I removed the gem cache and re-ran the tests. It looks like the gem installed correctly, but there's an issue with bundler using parallel_tests. See my comments for a suggested fix.

Comment thread .github/workflows/test_ci.yml Outdated
- name: Set up database
run: bundle exec rails db:migrate
- name: Set up databases
run: bundle exec rake parallel:setup
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use rails (not rake) as the task runner; this is the more modern convention

Comment thread .github/workflows/test_ci.yml Outdated
run: chromedriver --port=9515 --whitelisted-ips &
- name: Run rspec tests
run: bundle exec rspec
run: bundle exec parallel_tests spec/ -t rspec --exclude-pattern "spec/system/**/*_spec.rb"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use rails parallel:spec rather than parallel_tests. I suspect this is causing the issue with parallel_tests not being found in the GitHub Actions workflow.

Comment thread Gemfile.lock Outdated
pg (1.6.3)
pghero (3.8.0)
activerecord (>= 7.2)
pghero (3.7.0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This dependency should not be changed

@akarki2005 akarki2005 force-pushed the parallelize-rspec-tests branch from f13a970 to cba0279 Compare June 2, 2026 18:20
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.

2 participants