Add merge finalization ownership config#1216
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces an explicit configuration switch to decouple “storing mergeable worker resultsets” from “owning final merge/report finalization,” addressing the parallel-worker hang described in #1215 when workers write to sharded coverage destinations and a separate SimpleCov.collate step performs the final merge/report.
Changes:
- Adds
SimpleCov.finalize_merge(defaulting to true) andmerge_finalization_owner?to control whether a process performs wait/merge/format/threshold checks/.last_run.jsonfinalization. - Infers
finalize_merge false(with a one-time warning) for recognized multi-worker parallel runs with merging enabled and an explicitly customized coverage destination. - Updates result processing and exit handling so
SimpleCov.collatealways finalizes correctly, while non-owning workers only store their shard resultsets and exit without waiting or formatting; adds/updates specs and documentation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spec/simplecov_spec.rb | Adds coverage for merge_finalization_owner? gating, collate finalization behavior, and worker behavior when finalization is disabled. |
| spec/configuration_spec.rb | Adds tests for finalize_merge default/explicit values and inference + warning behavior. |
| README.md | Documents “merge finalization ownership” and recommended worker/collate setup. |
| lib/simplecov/result_processing.rb | Implements collate “finalizer context” flag and gates worker wait/merge on finalize_merge?. |
| lib/simplecov/exit_handling.rb | Updates readiness-to-process logic to respect merge-finalization ownership and collate flows. |
| lib/simplecov/configuration/merging.rb | Adds finalize_merge, inference logic, warning emission, and merge_finalization_owner?. |
| lib/simplecov/configuration.rb | Prevents formatting in at_exit when the process does not own merge finalization; tracks explicit coverage_dir changes for inference. |
| CHANGELOG.md | Notes the new option and the behavior change/fix for sharded parallel workers + external collation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sferik
left a comment
There was a problem hiding this comment.
The explicit finalize_merge API is clean and I’m 👍 on that part. I have some reservations about the auto-inference, but I’m willing to put it out in an RC and see what comes back.
My only nit is that the call to merging_enabled_for_inference? could be replaced with merging, at which point I believe merging_enabled_for_inference? could be deleted since it’s no longer called anywhere.
Summary
Adds
SimpleCov.finalize_mergeso parallel workers can store mergeable resultsets without also owning final report finalization.Fixes #1215.
Root cause
use_merging truecurrently covers two responsibilities: storing resultsets and finalizing the merged report. In setups like the repro, each worker writes to an isolatedcoverage_dirand a laterSimpleCov.collatecleanup step owns the final report. The selected final worker was polling only its own shard.resultset.json, so it waited for sibling workers that were intentionally writing different files.Changes
SimpleCov.finalize_mergewith explicit true/false support..last_run.jsonfinalization whenfinalize_merge false.SimpleCov.collateas a finalizer that writes.last_run.jsonfor the collated result.coverageconfiguration API and add changelog coverage.Validation
rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rbbundle exec turbo_tests2 specin https://github.com/G-Rath/simplecov-wat finishes in about 1 second and collates the final report successfully.