Repository navigation
Run Minitest in 4 parallel processes in CI - #12114
Merged
Merged
Conversation
Minitest was the slowest CI job (about 290s of tests on one process of a 4-core runner). PARALLEL_WORKERS=4 runs it across all four cores: locally the same 1893 tests (same assertions, same result) take 42-77s instead of 269s. Each worker writes its own Cobertura report (coverage/worker-N), rather than merging with the others as the run exits, which races the workers finishing. The main process's coverage.xml holds what loading the app covered, so the existing coverage report job merges it and the workers' reports with scripts/merge_coverage.rb. Merged that way, the coverage is line-for-line identical to a single-process run (12,993 of 16,179 lines in both, none lost or gained across all files). Parallel runs are opt-in (PARALLEL_WORKERS), so a plain `rails test` is unchanged; the macOS fork crash workaround is in agent-docs/testing.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd
Contributor
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Runs Minitest in 4 parallel processes in CI. Minitest was the slowest job (about 290s of tests, on one process of a 4-core runner); with this the suite takes ~42-77s locally on 4 workers instead of 269s serial, with the same result (1893 tests, 4101 assertions, 0 failures).
test/test_helper.rb:PARALLEL_WORKERS=N(N > 1) turns on Rails' process parallelization. It's opt-in, so a plainrails testis unchanged. Each worker writes its own Cobertura report tocoverage/worker-N/coverage.xml..github/workflows/ci.yml: the Minitest job setsPARALLEL_WORKERS: 4, and the existing coverage report job mergesminitest-coverage/coverage.xmlplusminitest-coverage/worker-*/coverage.xmlwithscripts/merge_coverage.rb(no new merge step).agent-docs/testing.md: how to run in parallel locally, including the macOS workaround (thepggem segfaults on fork unlessPGGSSENCMODE=disable OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YESis set; Linux CI isn't affected).Coverage is unchanged
I checked that nothing is lost: running the same code serially and in parallel, then merging with
scripts/merge_coverage.rb, gives 12,993 of 16,179 covered lines in both, with 0 lines lost or gained (compared per file and line). Two details worth knowing:coverage.xmlhas to be included in the merge: class bodies, field definitions and other things that run when the app loads are only counted there (e.g. 218 of the 228 covered lines ofconvention_type.rb). Merging only the workers' reports undercounts by about a third.To check on this PR
This is the first time it runs on Linux CI. I'd look at the Minitest job's time, that its tests pass, and that the "Test coverage report" job's merged numbers match recent runs on main (about 65.5% overall).
🤖 Generated with Claude Code
https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd