Skip to content

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

Closed

Description

@tianmind-studio

Problem

The repository's linked-worktree pre-push hook cannot run on Windows. A real push from PowerShell reaches .github/scripts/preflight_runner.py and crashes before the wrapped checks start:

AttributeError: module 'signal' has no attribute 'SIGHUP'
  at preflight_runner.py:183

The signal-forwarding block has two POSIX-only assumptions:

  • signal.SIGHUP is referenced unconditionally, but Windows Python does not define it.
  • os.killpg is used for forwarding, but Windows Python does not expose process-group signaling through that API.

This forces Windows contributors to bypass the pre-push hook even when their local checks pass.

Proposed fix

  • Register only signal constants that exist on the current platform.
  • Keep os.killpg process-group forwarding on POSIX.
  • Fall back to Popen.send_signal() when os.killpg is unavailable.
  • Preserve handler restoration and lock cleanup.
  • Add platform-simulation unit tests and run the existing single-flight tests on Windows.

Acceptance criteria

  • preflight_runner.py -- ... executes successfully on Windows Python.
  • A normal git push can enter and complete the pre-push single-flight checks without --no-verify.
  • POSIX process-group forwarding behavior remains unchanged.
  • Tests simulate missing SIGHUP and missing os.killpg.
  • No dependency changes.

Activity

  1. tianmind-studio commented on Jul 13, 2026

    @tianmind-studio
    ContributorAuthor

    Regression testing exposed a third Windows-only assumption: process_exists() calls os.kill(pid, 0). On Windows, signal 0 is CTRL_C_EVENT, so the joiner interrupts the shared console instead of probing process existence. I am including an OpenProcess-based existence check in this same fix; this is why the original single-flight test closed the test host stdout.

  2. tianmind-studio commented on Jul 13, 2026

    @tianmind-studio
    ContributorAuthor

    The first normal-push retest now passes signal registration and Windows PID probing, then reaches Popen and exposes one more POSIX assumption: scripts/pre-push-singleflight passes the extensionless Bash script scripts/pre-push directly to Windows CreateProcess, which returns WinError 2. I am fixing the wrapper to pass an explicit bash interpreter; I will not use shell=True or interpreter guessing.

  3. tianmind-studio commented on Jul 13, 2026

    @tianmind-studio
    ContributorAuthor

    The second normal-push retest now launches the Bash hook, then exposes a mixed-codepage log boundary: one child emitted a non-UTF-8 byte and the runner aborted while decoding stdout. I am making log decoding loss-tolerant with visible \xNN escapes and starting the runner with python3 -X utf8; a regression test writes an invalid byte and requires both the runner and its persisted log to complete.

  4. changed the title [-]fix(ci): make preflight signal handling portable to Windows[/-] [+]fix(ci): make pre-push preflight portable on Windows[/+] on Jul 13, 2026
  5. tianmind-studio commented on Jul 13, 2026

    @tianmind-studio
    ContributorAuthor

    A normal Windows push exposed one more interpreter-boundary failure after the signal/process fixes: passing a bare bash argv from native Python selected C:\Windows\System32\bash.exe (WSL) on this machine, not the Git Bash interpreter already running the hook. The hook then failed with HCS_E_HYPERV_NOT_INSTALLED before checks started.

    The branch now passes the current wrapper $BASH path to preflight_runner.py. A direct Git Bash -> native Windows Python -> same Git Bash probe succeeds, and a regression contract requires -- "$BASH" scripts/pre-push so PATH shadowing cannot return silently.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions