name: Windows Setup E2E # End-to-end fresh-install gate for Windows. Builds a clean windows-latest # checkout and asserts the build completes, binaries resolve via # find-browse, and the gstack-paths state root resolves cleanly. Catches Bun # shell-parser regressions in package.json's build chain (#1538, #1537, # #1530, #1457, #1561) before they reach users. Then it runs `./setup` into # an isolated HOME and drives the installed runtime root's browse from an # unrelated directory: a piped two-command `chain` flow must print the page # text (the runtime root has no node_modules, so this is the checkout-bundle # path from #3026, and the piped-stdin path from #3039). Every compiled # binary must answer the side-effect-free --version that setup's Smart App # Control probe runs (#2595). Git Bash path spelling (#3088, # #3100): the hook check passes on this checkout, /gstack-upgrade's checkout # guard passes at its root, and an install stuck on a release whose checker # had the false positive recovers with the documented # `git pull --ff-only --autostash && ./setup`. # # setup.ps1 under Windows PowerShell 5.1 (powershell.exe, #3130): its cases # in test/setup-ps1.test.ts run with a space in the temp path, and a real # install runs from a checkout path with a space. The held-install job # (#3184) builds a prefix-mode v1.91.101.0 install behind this PR's tree in # three states (clean, dirty-conflicting, already-unmerged): the old updater # must log `HELD hook-check-unavailable`, the PowerShell recovery form that # docs/troubleshooting.md publishes must reach the PR's tree with every # local edit in a rescue ref, the trial and go-back forms must move the # install, and the new updater must then take a later release whose symlink # sorts before its target. Each job asserts the exact list of cases it ran. # # Separate from windows-free-tests.yml because that one runs a curated # unit-test subset; this one exercises the install path itself. # # Runs by path (ship-90-90 plan D): the paths below are the install files # this workflow runs or ./setup sources or runs. The windows-scope job then # drops a pull request whose only install change is package.json's version # line, which is what the merge-train stamp commit puts on every PR head. # windows-scope's list must match the paths list (pinned by # test/windows-path-scope-workflow.test.ts). # # Runner: GitHub-hosted free windows-latest, two parallel jobs. ~10-25 min. on: pull_request: branches: [main] paths: - 'package.json' - 'bun.lock' - 'scripts/build.sh' - 'scripts/write-version-files.sh' - 'scripts/windows-held-install-fixture.sh' - 'setup' - 'setup.ps1' - 'test/setup-ps1.test.ts' - 'docs/troubleshooting.md' - 'browse/src/cli.ts' - 'browse/src/find-browse.ts' - 'browse/src/server.ts' - 'browse/src/meta-commands.ts' - 'browse/scripts/build-node-server.sh' - 'design/src/cli.ts' - 'make-pdf/src/cli.ts' - 'bin/gstack-global-discover.ts' - 'bin/gstack-paths' - 'bin/gstack-doctor' - 'bin/gstack-launch-probe.sh' - 'bin/gstack-hook-check' - 'bin/gstack-session-update' - 'bin/gstack-ff-update' - 'bin/gstack-claude-root.sh' - 'bin/gstack-browser-ensure' - 'bin/gstack-path-spelling.sh' - 'bin/gstack-config' - 'bin/gstack-patch-names' - 'bin/gstack-state-root.sh' - 'bin/gstack-lock.sh' - 'bin/gstack-skill-name.sh' - 'bin/gstack-install-registry.sh' - 'bin/gstack-render-claude.sh' - 'bin/gstack-host-renders.sh' - 'bin/gstack-migrate-claude-code' - 'bin/gstack-settings-hook' - 'bin/gstack-relink' - 'bin/gstack-harness' - 'scripts/preflight-codex-overlap.ts' - 'lib/path-spelling.ts' - 'hosts/claude/hooks/**' - 'gstack-upgrade/**' - '.github/workflows/windows-setup-e2e.yml' workflow_dispatch: concurrency: # PR-number keyed: head_ref carries no fork prefix, so same-name branches # from two forks would share one group and cancel each other's runs. group: windows-setup-e2e-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: true # Install-path exercise only — no token writes. permissions: contents: read jobs: # Trunk Dynamic CI, LEARNING ONLY (GST-1847; free-tests.yml has the full # rationale). Trunk records whether it would have run or skipped windows-setup and held-install-journey # on same-repository pull requests; every job still runs. Trunk keys verdicts # by workflow file, so each observed workflow carries its own observer. No job # needs it, no condition reads it and it exports no outputs, so a mode change # in Trunk's dashboard cannot skip anything. It checks out nothing, runs no # pull-request code, holds no GITHUB_TOKEN scopes, never fails the run, and # skips fork pull requests, pushes and dispatches. docs/TESTING_INTERNALS.md. trunk-dynamic-ci: name: Trunk Dynamic CI (learning only, windows-setup-e2e) if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-24.04 timeout-minutes: 5 continue-on-error: true permissions: {} env: TRUNK_API_TOKEN: ${{ secrets.TRUNK_API_TOKEN }} steps: - name: Record Trunk's verdicts for the Windows setup and held-install jobs (nothing reads them) if: env.TRUNK_API_TOKEN != '' timeout-minutes: 3 continue-on-error: true uses: trunk-io/dynamic-ci@5bcddbf3615c2b032c21eed1b514c91164bda4a8 # v0.1.7 env: TRUNK_DISABLE_TELEMETRY: 'true' with: token: ${{ env.TRUNK_API_TOKEN }} job-keys: windows-setup,windows-setup-recovery,held-install-journey,held-install-trial,held-install-later-release github-token: '' enable-annotation: 'true' windows-scope: # The paths filter above starts this workflow; this job decides whether # the Windows jobs run. A workflow_dispatch run always runs them. runs-on: ubuntu-24.04 timeout-minutes: 5 outputs: install: ${{ steps.scope.outputs.install }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 if: github.event_name == 'pull_request' with: fetch-depth: 2 persist-credentials: false - id: scope name: Run unless the only install change is package.json's version line run: | set -euo pipefail if [ "$GITHUB_EVENT_NAME" != pull_request ]; then echo 'install=true' >> "$GITHUB_OUTPUT" exit 0 fi pkg_version_only=true if git diff -U0 --no-renames HEAD^1 HEAD -- package.json | grep -E '^[+-]' | grep -vE '^(\+\+\+|---) ' \ | grep -vE '^[+-] "version": "[^"]*",?$' > /dev/null; then pkg_version_only=false fi git diff --name-only --no-renames HEAD^1 HEAD | while IFS= read -r file; do if [ "$file" = package.json ] && [ "$pkg_version_only" = true ]; then continue; fi while IFS= read -r glob; do # shellcheck disable=SC2254 case "$file" in ${glob//\*\*/*}) echo "$file"; break ;; esac done <<'PATHS' package.json bun.lock scripts/build.sh scripts/write-version-files.sh scripts/windows-held-install-fixture.sh setup setup.ps1 test/setup-ps1.test.ts docs/troubleshooting.md browse/src/cli.ts browse/src/find-browse.ts browse/src/server.ts browse/src/meta-commands.ts browse/scripts/build-node-server.sh design/src/cli.ts make-pdf/src/cli.ts bin/gstack-global-discover.ts bin/gstack-paths bin/gstack-doctor bin/gstack-launch-probe.sh bin/gstack-hook-check bin/gstack-session-update bin/gstack-ff-update bin/gstack-claude-root.sh bin/gstack-browser-ensure bin/gstack-path-spelling.sh bin/gstack-config bin/gstack-patch-names bin/gstack-state-root.sh bin/gstack-lock.sh bin/gstack-skill-name.sh bin/gstack-install-registry.sh bin/gstack-render-claude.sh bin/gstack-host-renders.sh bin/gstack-migrate-claude-code bin/gstack-settings-hook bin/gstack-relink bin/gstack-harness scripts/preflight-codex-overlap.ts lib/path-spelling.ts hosts/claude/hooks/** gstack-upgrade/** .github/workflows/windows-setup-e2e.yml PATHS done > "$RUNNER_TEMP/install-files" if [ -s "$RUNNER_TEMP/install-files" ]; then echo 'install=true' >> "$GITHUB_OUTPUT" { echo 'Install files changed, so the Windows jobs run:'; sed 's/^/- /' "$RUNNER_TEMP/install-files"; } >> "$GITHUB_STEP_SUMMARY" else echo 'install=false' >> "$GITHUB_OUTPUT" echo "The only install change is package.json's version line (the merge-train stamp), so the Windows jobs do not run." >> "$GITHUB_STEP_SUMMARY" fi windows-setup: needs: windows-scope if: needs.windows-scope.outputs.install == 'true' runs-on: windows-latest timeout-minutes: 35 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 with: bun-version: 1.4.2 - name: Configure git identity run: | git config --global user.email "windows-setup-e2e@gstack.test" git config --global user.name "Windows Setup E2E" git config --global init.defaultBranch main shell: bash - name: Install dependencies run: bun install --frozen-lockfile shell: bash - name: setup.ps1 cases under Windows PowerShell 5.1 with a space in the temp path (#3130) # test/setup-ps1.test.ts runs powershell.exe on Windows: argv forwarding # with adversarial arguments, the empty-argument refusal, and pwsh. The # skips are its Linux-only cases: a missing prerequisite, and the Git # Bash resolution table, whose locations are injected into pwsh. run: | set -euo pipefail : > "$RUNNER_TEMP/setup-cases" # shellcheck disable=SC2016 MAJOR=$(powershell.exe -NoProfile -NonInteractive -Command '$PSVersionTable.PSVersion.Major' | tr -d '\r') test "$MAJOR" = 5 || (echo "powershell.exe is PowerShell '$MAJOR', not Windows PowerShell 5.1" && exit 1) echo ps51 >> "$RUNNER_TEMP/setup-cases" SPACED="$RUNNER_TEMP/tmp with space" mkdir -p "$SPACED" TEMP="$(cygpath -w "$SPACED")" export TEMP TMP="$TEMP" set +e OUT=$(bun test test/setup-ps1.test.ts 2>&1) CODE=$? set -e echo "$OUT" test "$CODE" -eq 0 || (echo "test/setup-ps1.test.ts exited $CODE" && exit 1) grep -qE '^ *4 pass$' <<< "$OUT" || (echo "expected exactly 4 executed setup.ps1 cases" && exit 1) grep -qE '^ *0 fail$' <<< "$OUT" || (echo "a setup.ps1 case failed" && exit 1) grep -qE '^ *31 skip$' <<< "$OUT" || (echo "expected exactly 31 skipped setup.ps1 cases (the Linux-only prerequisite case, the 14 pwsh-on-Linux Git Bash resolution rows and the 16 shared-table rows from test/fixtures/windows-bash-resolution.json)" && exit 1) echo setup-ps1-cases >> "$RUNNER_TEMP/setup-cases" shell: bash - name: Run bun run build (the previously-broken path) # This is the regression gate. Bun's Windows shell parser rejected # multiple constructs the old inline build chain used; the wave # moved the build to scripts/build.sh. If this step fails on # Windows, the build chain regressed. run: bun run build shell: bash env: GSTACK_SKIP_PLAYWRIGHT: '1' - name: Verify binaries exist (with .exe extension on Windows) run: | set -e test -f browse/dist/browse.exe || test -f browse/dist/browse || (echo "MISSING: browse" && exit 1) test -f browse/dist/find-browse.exe || test -f browse/dist/find-browse || (echo "MISSING: find-browse" && exit 1) test -f design/dist/design.exe || test -f design/dist/design || (echo "MISSING: design" && exit 1) test -f bin/gstack-global-discover.exe || test -f bin/gstack-global-discover || (echo "MISSING: gstack-global-discover" && exit 1) echo "All binaries present" shell: bash - name: 'Every compiled binary launches with --version (Smart App Control probe, #2595)' run: | set -euo pipefail . bin/gstack-launch-probe.sh gstack_launch_probe_all "$PWD" .exe printf 'blocked: %s\nbroken: %s\nmissing: %s\n' "$_glp_blocked" "$_glp_broken" "$_glp_missing" test -z "$_glp_blocked$_glp_broken$_glp_missing" || (echo "a compiled binary did not answer --version" && exit 1) shell: bash - name: Verify find-browse resolves to the .exe variant run: | set -e OUT=$(bun browse/src/find-browse.ts 2>&1) || true echo "find-browse output: $OUT" # On Windows, find-browse should successfully resolve to a binary, # whether or not it has the .exe extension on disk. Empty output # or "not found" means the .exe extension resolver regressed. echo "$OUT" | grep -qE '(browse\.exe|browse)$' || (echo "find-browse failed to resolve binary on Windows" && exit 1) shell: bash - name: Verify gstack-paths state root resolves run: | set -e eval "$(bash bin/gstack-paths)" test -n "$GSTACK_STATE_ROOT" || (echo "GSTACK_STATE_ROOT empty" && exit 1) test -n "$PLAN_ROOT" || (echo "PLAN_ROOT empty" && exit 1) test -n "$TMP_ROOT" || (echo "TMP_ROOT empty" && exit 1) echo "GSTACK_STATE_ROOT=$GSTACK_STATE_ROOT" echo "PLAN_ROOT=$PLAN_ROOT" echo "TMP_ROOT=$TMP_ROOT" shell: bash - name: Install with ./setup into an isolated HOME # A real install: the codex host's runtime root is a copy of the # runtime files with no node_modules beside it. setup installs # Playwright's Chromium (best-effort) for the journey below. run: | set -euo pipefail E2E_HOME="$RUNNER_TEMP/gstack-e2e-home" mkdir -p "$E2E_HOME" HOME="$E2E_HOME" USERPROFILE="$(cygpath -w "$E2E_HOME")" ./setup --host codex ROOT="$E2E_HOME/.codex/skills/gstack" test -f "$ROOT/.source-path" || (echo "MISSING: $ROOT/.source-path" && exit 1) test ! -e "$ROOT/node_modules" || (echo "UNEXPECTED: $ROOT/node_modules (the journey must exercise the copy without it)" && exit 1) echo "runtime root: $ROOT -> source $(cat "$ROOT/.source-path")" shell: bash - name: .\setup.ps1 installs from a checkout path with a space under Windows PowerShell 5.1 (#3130) # A copy of this built checkout (build outputs keep their mtimes, so # setup does not rebuild; node_modules is reinstalled) under a path # with a space, installed through powershell.exe into an isolated HOME. # -h stores symlinks as their targets: MSYS tar cannot extract a # symlink that precedes its target (connect-chrome, #3184). run: | set -euo pipefail SPACED="$(cygpath -u "$RUNNER_TEMP")/gstack checkout" mkdir -p "$SPACED" tar --exclude=./node_modules -chf - . | tar -xpf - -C "$SPACED" E2E_HOME="$RUNNER_TEMP/gstack-ps1-home" mkdir -p "$E2E_HOME" set +e OUT=$(HOME="$E2E_HOME" USERPROFILE="$(cygpath -w "$E2E_HOME")" GSTACK_SKIP_PLAYWRIGHT=1 \ powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$(cygpath -w "$SPACED/setup.ps1")" --host codex 2>&1) CODE=$? set -e echo "$OUT" | tail -n 40 test "$CODE" -eq 0 || (echo ".\\setup.ps1 exited $CODE" && exit 1) ! grep -q 'unexpected EOF' <<< "$OUT" || (echo "bash read a broken -c script (#3130)" && exit 1) ROOT="$E2E_HOME/.codex/skills/gstack" test -f "$ROOT/.source-path" || (echo "MISSING: $ROOT/.source-path" && exit 1) grep -q 'gstack checkout' "$ROOT/.source-path" || (echo "the runtime root does not come from the spaced checkout: $(cat "$ROOT/.source-path")" && exit 1) echo setup-ps1-install >> "$RUNNER_TEMP/setup-cases" shell: bash - name: Installed browse runs a piped chain flow from an unrelated directory run: | set -euo pipefail E2E_HOME="$RUNNER_TEMP/gstack-e2e-home" USERPROFILE="$(cygpath -w "$E2E_HOME")" export HOME="$E2E_HOME" USERPROFILE BROWSE="$E2E_HOME/.codex/skills/gstack/browse/dist/browse.exe" [ -f "$BROWSE" ] || BROWSE="$E2E_HOME/.codex/skills/gstack/browse/dist/browse" test -f "$BROWSE" || (echo "MISSING: installed browse" && exit 1) bun -e 'Bun.serve({ hostname: "127.0.0.1", port: 47123, fetch: () => new Response("