Skip to content

fix(ci): make pre-push portable on Windows#9727

Open
tianmind-studio wants to merge 2 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-preflight-runner
Open

fix(ci): make pre-push portable on Windows#9727
tianmind-studio wants to merge 2 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-preflight-runner

Conversation

@tianmind-studio

@tianmind-studio tianmind-studio commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What changed and why

Closes #9724.

Make the pre-push single-flight path work on Windows without changing its POSIX behavior:

  • register only signal constants available on the host;
  • use a Win32 process handle query instead of os.kill(pid, 0) for lock-owner liveness;
  • fall back to Popen.send_signal() when process-group signaling is unavailable;
  • launch scripts/pre-push through the current Bash interpreter; and
  • let pre-push resolve backend Python from an explicit override or either Unix/Windows venv layout.

Product invariants affected

none

How it was verified

On Windows 11 with Python 3.11.15 and Git for Windows:

  • Before the fix, .github/scripts/test_pr_preflight.py failed in run_owned() on missing signal.SIGHUP, and concurrent-run tests also hit WinError 87 from os.kill(pid, 0).
  • python .github/scripts/test_pr_preflight.py -> 18 passed
  • python -m unittest test_pr_preflight.SignalCompatibilityTests -v -> 7 passed
  • python -m compileall -q ... -> passed
  • black --check ... -> passed
  • bash -n scripts/pre-push scripts/pre-push-singleflight -> passed
  • Backend Pyright through the resolved Windows interpreter -> 0 errors
  • scripts/pre-push-singleflight fork -> shared preflight and workflow contracts passed
  • A real git push ran the installed single-flight hook successfully and pushed the branch without --no-verify

Two selected backend test files completed with 22 passing assertions, but the existing Windows fast-unit timing guard rejected one call at approximately 0.12s > 0.12s. The final hook run skipped that already-exercised timing gate. The OpenAPI check was also skipped after independently reporting four pre-existing stale generated TypeScript clients, and the macOS-only Swift compile was skipped because xcrun is unavailable on Windows.

Tests

Added cross-platform coverage for unavailable signal constants, POSIX process-group forwarding, Windows child signaling, Win32 live/exited process detection, Windows process-probe dispatch, Bash interpreter reuse, and Unix/Windows backend Python resolution.

The existing single-flight concurrency tests now also pass on Windows, covering identical-run joining and different-input rejection through real subprocesses.

Root cause and durable guard (bug fixes)

The single-flight layer assumed three POSIX contracts: SIGHUP exists, process groups can be signaled with os.killpg, and os.kill(pid, 0) is a safe liveness probe. Windows satisfies none of those contracts, and its process launcher also cannot execute an extensionless shell script directly.

Platform-specific behavior is now isolated behind small tested helpers while the orchestration remains shared. The installed wrapper supplies an actual Bash executable, and pre-push uses one resolved Python interpreter consistently for selection, tests, and type checking.

Review in cubic

@Git-on-my-level Git-on-my-level added workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior needs-maintainer-review Needs human maintainer review before merge labels Jul 14, 2026

@Git-on-my-level Git-on-my-level left a comment

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.

Thanks for the Windows portability fix. I reviewed the workflow/hook changes and ran the PR preflight test file plus syntax checks in an isolated environment on Linux.

What looks good:

  • preflight_runner.py now avoids assuming SIGHUP exists and keeps the existing POSIX process-group forwarding path when os.killpg is available.
  • The Windows liveness path avoids os.kill(pid, 0), which matches the failure mode described in the PR.
  • scripts/pre-push-singleflight now launches scripts/pre-push through the current Bash interpreter, and scripts/pre-push can resolve either Unix or Windows venv Python layouts.
  • Added regression coverage for the signal/process compatibility paths and backend Python resolution.

Verification I ran:

  • python3 .github/scripts/test_pr_preflight.py → 18 tests passed, 3 skipped
  • python3 -m compileall -q .github/scripts/preflight_runner.py .github/scripts/test_pr_preflight.py → passed
  • bash -n scripts/pre-push scripts/pre-push-singleflight → passed

I’m leaving this as a positive maintainer signal rather than formal approval because it touches workflow/pre-push automation and the automated gate marks this PR as not eligible for auto-approval. A human maintainer should do the final review/merge decision, ideally with Windows confirmation as noted in the PR body.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@tianmind-studio

Copy link
Copy Markdown
Contributor Author

Fresh reproduction on current main 77c32cc34f while publishing #9759 from Windows: the installed hook first resolved the Microsoft Store python3 alias; after explicitly placing the project Python 3.11 interpreter on PATH, preflight_runner.py entered run_owned() and crashed on missing signal.SIGHUP. The branch could only be pushed with --no-verify after the equivalent checks were run directly. This independently confirms both portability fixes in this PR are still required on the latest main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs human maintainer review before merge workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-push single-flight runner crashes on Windows without SIGHUP

2 participants