Repository navigation
ci(desktop): start git without forking in the release tooling and its tests - #2277
Conversation
… tests On the hosted macOS runners a forked copy of the pytest process sometimes never reached exec, so the parent waited inside Popen where the per-call timeout could not apply, and the test hit its 300-second deadline. The release scripts and the tests now run every git command through one helper that uses posix_spawn, takes the directory through git -C, gives each call a 120-second timeout that names the command, and reads no terminal input. A guard in the test module fails any subprocess that would fork pytest.
Independent adversarial review: APPROVEFrom: Grok The fix does what it says. Every git call in Tests at this head (Linux x86_64, locked desktop env)
The three things to attack
CI
Generality gate: these are generic release-tooling and test-harness changes with no app- or customer-specific terms. Pass. Limits: I couldn't run anything on macOS. The fix's real proof is a green macOS run, and one job (py3.11) gives that so far. Whether the merge run on main releases 0.30.2 and 0.30.3 is a release decision for the maintainers and isn't covered by this review. |
…dows (#2281) Since #2277 the test helper returns git output without text-mode newline translation. Two tests wrote a CRLF blob back with write_text, which on Windows turned each CRLF into CR CR LF, so the reversion was no longer exact and the feature commit stayed in the release intent. The tests now write the blob's bytes back, and the helper normalizes line endings as the text-mode call did.
…ng (#2279) * ci(desktop): keep native-release git calls and their tests from forking native_release.py now owns the git helper, and its three git calls and the git calls in tests/test_native_release.py go through it. The fork guard moves to conftest.py and covers both release test modules. The helper also holds descriptors 0, 1 and 2 open for the length of a call when the process was started with one closed, because Python otherwise falls back to fork. * test(desktop): restore exact host bytes in the reversion tests on Windows Since #2277 the test helper returns git output without text-mode newline translation. Two tests wrote a CRLF blob back with write_text, which on Windows turned each CRLF into CR CR LF, so the reversion was no longer exact and the feature commit stayed in the release intent. The tests now write the blob's bytes back, and the helper normalizes line endings as the text-mode call did.
) * ci(desktop): keep native-release git calls and their tests from forking native_release.py now owns the git helper, and its three git calls and the git calls in tests/test_native_release.py go through it. The fork guard moves to conftest.py and covers both release test modules. The helper also holds descriptors 0, 1 and 2 open for the length of a call when the process was started with one closed, because Python otherwise falls back to fork. * test(desktop): restore exact host bytes in the reversion tests on Windows Since #2277 the test helper returns git output without text-mode newline translation. Two tests wrote a CRLF blob back with write_text, which on Windows turned each CRLF into CR CR LF, so the reversion was no longer exact and the feature commit stayed in the release intent. The tests now write the blob's bytes back, and the helper normalizes line endings as the text-mode call did. * test(desktop): start every test subprocess without forking pytest The session now defaults close_fds to false, which lets Python start a child with posix_spawn, and fails any call that would still fork unless the test asks for the forking_allowed fixture. The summary prints how many subprocesses forked. The wheel tests no longer pass cwd, and the three installer launch tests that need a new session are the only ones allowed to fork. * test(desktop): give the engine's process tests Python's real subprocess defaults The session's close_fds default made the engine's own no-fork tests pass whatever the engine did. Those tests now ask for python_subprocess_defaults, which restores Popen's real behaviour for them, and their negative control passes close_fds=True explicitly.
Packages run 44545930563 (push to main at 108ee9b, the Desktop 0.30.2 release commit) failed on both macOS engine-test jobs: three tests in
packages/desktop/tests/test_release_intent.pyhit the 300-second deadline that #2237 added. The next Desktop run on main, 44550058867 (9eaa375, Desktop 0.30.3), failed the same way in two more tests. Both releases are blocked.Cause
A forked copy of the pytest process never reached
exec, and pytest waited for it insidePopen, where the 120-second git timeout cannot apply.The evidence, from the two failed jobs of run 44545930563:
All three tracebacks end at the same line, in the parent's wait for the child to exec. Two came from the release script's own
_git, one from the test fixture'sgit config:The git command differs each time (
ls-tree,cat-file -s,config), and so does the test. The py3.12 job stalled in the setup oftest_exact_reversion_after_combination_discards_merged_feature_intent[chore-None], not in either test the py3.11 job lost.The runner's cleanup step found leftover Python processes and no git process, one per stalled call: two in the py3.11 job (
Terminate orphan process: pid (57253) (python3.1…,pid (25563)) and one in the py3.12 job (pid (23924)).Run 44550058867 repeats the pattern on py3.11:
test_stateful_copy_histories_preserve_feature_bytes_at_every_prefix[fanout-True-chore]and[reversion-True-fix]both stopped atprepare_release.py:82in the sameos.read(errpipe_read, 50000), and the cleanup step ended two leftoverpython3.11processes (pids 20423 and 11284).The other 385 tests in the module took a median of about 1 second and at most 17 seconds in the same jobs, so nothing was slow; one call in tens of thousands stopped.
Only macOS is affected (image
macos-26-arm64, Homebrew Git 2.56). The Linux and Windows jobs of the same run passed.Which lock the child stops on is not established; I could not reproduce the stall on a local Mac (macOS 15). A local probe shows the condition that makes a fork risky on macOS: by the time these tests start, earlier tests in the same pytest process have loaded Foundation, CoreFoundation, AppKit and Quartz, and the process has a second native thread.
How often: macOS engine tests run only on pushes to main that touch Desktop. Since #2237 merged on November 14, three such runs have finished a macOS job: both jobs passed in run 43546222113, both failed in 44545930563, and one failed in 44550058867 (the other was cancelled). From November 11 to 13, before #2237, 12 macOS jobs were cancelled at the 45-minute limit and 4 passed in the runs the API returned.
Fix
Every git call in
prepare_release.py,check_release_intent.pyand the test module now goes through one helper,prepare_release.run_git. It follows the step #2237 named as next:posix_spawninstead offorkwhen the program path is absolute, nocwdis passed andclose_fdsis false. The helper meets those conditions and gives git its directory with-C. Python opens its own descriptors close-on-exec, so git still inherits only its pipes.GitTimeout)./dev/nullunless the call passes input (hash-object --stdin).A guard in the test module (
_no_fork) replaces the fork path with a failure for every test, wherever Python can spawn. A later change that brings backsubprocess.run(["git", ...], cwd=...)fails on the pull request's Linux lane instead of stalling on main.test_a_subprocess_that_would_fork_pytest_failsasserts the guard is active on macOS and that the old call pattern fails under it, andtest_a_stuck_git_command_fails_with_its_namechecks the timeout against a stand-in git that never returns.The 300-second deadline is unchanged, no test is skipped, and there are no retries.
The release workflow
Its git calls cannot stall this way.
prepare_release.pyruns on a developer's machine, not in a workflow.check_release_intent.pyruns onubuntu-latest. The other scripts that call git (native_release.py,check_source_boundary.py) run only onubuntu-22.04indesktop-release.ymlanddesktop-build.yml, in short single-threaded processes, so they are left alone. Other macOS jobs still fork for subprocesses that are not git; none of them has shown this stall.Release intent
The commit type is
ci, so this pull request needs no version bump. Its merge run on main will still release the Desktop versions already waiting (0.30.2 and 0.30.3) if it passes.python scripts/check_release_intent.py --base origin/main --head HEADreports "Desktop release intent is consistent."Proof
test_a_subprocess_that_would_fork_pytest_failsshows the guard refuses the old pattern, and it passed on macOS and on the pull request's Linux lane.