Repository navigation
Run a node as several worker processes, each its own runner - #92
Open
benjaminwood wants to merge 1 commit into
Open
benjaminwood wants to merge 1 commit into
benjaminwood wants to merge 1 commit into
Conversation
benjaminwood
force-pushed
the
feat/workers
branch
from
November 21, 2026 22:07
7db1a12 to
0d41734
Compare
--workers N, SELECTIVE_WORKERS, or the suite's own parallelism (Rails parallelize, minitest-parallel_fork) runs N workers on the node. Each is a fresh selective process that boots the app with TEST_ENV_NUMBER and PARALLEL_TEST_GROUPS set as parallel_tests sets them, and connects as <runner id>-w<index>. The command's own process is worker 0: once its suite has loaded it starts the others from an environment snapshot taken before boot, forwards INT/TERM, waits for them before its own teardown and report so coverage merging sees every worker, and exits with the worst status. Workers stop if worker 0 dies. Rails apps get a database per worker: a database.yml that names them by TEST_ENV_NUMBER is used as is, with worker 0 creating the others' first; otherwise <name>_<index>, as Rails parallelize does. parallelize hooks run in each worker. parallel_tests/turbo_tests processes get distinct runner ids, and a process handed a slice of the suite is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGDurRE6Gen6LaFLhpq7Rf
benjaminwood
force-pushed
the
feat/workers
branch
from
November 21, 2026 22:19
0d41734 to
14dce90
Compare
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.
Runs a CI node as several worker processes, each connecting to Selective as its own runner (
<runner id>-w<index>).How it works
--workers NorSELECTIVE_WORKERS(auto= one per CPU). Without either, the framework adapter's setting applies (Railsparallelize, minitest-parallel_fork).SELECTIVE_WORKERS=1turns it off.Process.spawn, using the environment it captured before the app booted. Each boots the app itself with parallel_tests'TEST_ENV_NUMBER("","2", …;PARALLEL_TEST_FIRST_IS_1honored) andPARALLEL_TEST_GROUPSalready set. Config that reads them at boot (ports, Redis dbs, cache dirs) works as under parallel_tests.database.ymlthat names databases byTEST_ENV_NUMBERis used as is, and worker 0 creates the others' before they boot. Otherwise each worker gets<name>_<index>, as withparallelize. Both load from the schema.parallelize_setup/teardownrun in each worker, RSpec included. When Minitest loadsrails/test_help, Rails' own hook does this.after_run, so SimpleCov merges every worker under a sharedSIMPLECOV_RUN_ID. The node exits with the worst status and names any worker that failed, was killed, or was lost.-p<TEST_ENV_NUMBER>runner ids. A process handed a slice of the suite exits 1 and points at--workers.Worker 0 boots before starting the others because the
parallelizecount is only known after load, per-worker ERB databases must exist before the others boot, and it avoids racingmaintain_test_schema!on a shared database. The cost is about one app boot.Companion PRs
The adapters guard with
respond_to?, so each can ship before or after this one. This should be released as 0.4.0.Testing
bundle exec rspec: 143 examples, 0 failures. Workers specs spawn a stand-in script to check env, hooks, worst status, killed workers and signal forwarding.database.yml) and SQLite.SELECTIVE_WORKERS=3: 200/200, all 12 runners took work.Also fixes a race in
stdio_binary_spec: the transport can exit, and its/proc/<pid>/cmdlinedisappear, between the existence check and the read. It failed every Ruby 4.0.7 run of this PR.Not tested: JRuby and Windows (
Process.spawnshould work, but unverified).🤖 Generated with Claude Code
https://claude.ai/code/session_01LGDurRE6Gen6LaFLhpq7Rf