Skip to content

Commit c160eaa

Browse files
authored
ci: split CI from Release and gate publishing on the full suite (#7)
* fix(pi-repo-model): canonicalize git-derived repo roots to native real paths Git prints slash-normalized paths on Windows, which made registry keys diverge from Node-side paths. Resolve the root through fs.realpathSync.native so keys stay stable and the test suite passes on the Windows CI matrix. * ci: split CI from Release and gate publishing on the full suite Publishing to npm is irreversible, but the Changesets release PR is opened with the default GITHUB_TOKEN and therefore never triggers pull_request CI, so the previous workflow could publish code that no job had verified. - ci.yml becomes reusable (workflow_call) and splits into ubuntu-only checks (typecheck, Effect check, lint, pack dry run), a 3-OS test matrix, and a ci-ok summary job to use as the single required status check. - release.yml calls that workflow as a verify job and depends on it. - Namespace the CI concurrency group by workflow so the reusable invocation does not cancel the standalone run for the same commit. - Drop the global npm upgrade: Node 26 ships npm 11.19, which already supports trusted publishing. - Enable pnpm shellEmulator so POSIX-style env prefixes in package scripts run on Windows, and add .gitattributes so LF-only content survives checkout there. * fix(pi-antigravity): shorten home paths with os.homedir() instead of $HOME Windows has no $HOME, so tool cards never collapsed the home directory to ~ there. os.homedir() resolves on every platform, which also makes the render test pass on the Windows CI matrix. * test(pi-repo-model): compare worktree keys against the native real path os.tmpdir() yields an 8.3 short name on Windows (C:\Users\RUNNER~1\...), which the JS realpathSync keeps but realpathSync.native expands. Assert against the same canonical form the runtime produces. * fix(pi-repo-skills,pi-image-cache): resolve paths through native real paths on Windows pi-repo-skills carried the same registry-key bug pi-repo-model just fixed: git prints slash-normalized roots on Windows, so keys diverged from Node-side paths. pi-image-cache compared tmpdir() against candidates with the JS realpathSync, which keeps 8.3 short names (RUNNER~1). A long-form clipboard path therefore never matched the short-form temp root and was treated as a user file. Both now canonicalize with fs.realpathSync.native, and the repo-skills test asserts against that same form. * test(pi-vscode-bridge): skip Unix-socket transport tests on Windows The bridge listens on a .sock path, and Node has no Unix domain socket support on Windows (it would need named pipes), so listen() fails with EACCES. Skip the eight transport tests there; the 18 protocol, hunk, and copy tests still run on every platform. * test(pi-vscode-bridge): resolve the package root with fileURLToPath URL.pathname returns /D:/... on Windows, so join() produced D:\\D:\\... and the byte-for-byte copy checks failed with ENOENT. * test(pi-subagents): isolate git fixtures from Windows CRLF and POSIX-only modes Three separate Windows failures in this suite: - Runner git defaults to core.autocrlf=true, so fixture checkouts came back as 'feature\r\n' and every patch-apply assertion failed. Each temporary repo now pins core.autocrlf=false. - Windows has no POSIX permission bits (stat().mode is always 0o666/0o444), so the 0o700/0o600 artifact-privacy assertions cannot hold; assertPrivateMode skips them there and documents that privacy relies on user-profile ACLs. - The status-failure test corrupts .git/worktrees/<id>/index to force a git error, which is not reproducible on Windows; it is now POSIX-only. * fix(pi-subagents): resolve the worktree subdir through native real paths git rev-parse --show-toplevel prints C:/Users/runneradmin/... on Windows, while the caller's cwd is C:\\Users\\RUNNER~1\\... — the JS realpathSync normalizes neither the separators nor the 8.3 short name, so relative() produced a bogus subdir and join() placed the subagent work path outside its worktree. The patch then looked already-applied on first apply. realpathSync.native collapses both forms onto one canonical path. * test(pi-background-terminals): force exit and serialize test files On Windows the test runner intermittently lingered for minutes after all tests passed when a spawned shell handle outlived its test. Force exit after the suite finishes, and run files serially to sidestep the open Node test-runner race (nodejs/node#64833) where --test-force-exit with concurrency can silently drop verdicts.
1 parent fb3955d commit c160eaa

28 files changed

Lines changed: 275 additions & 59 deletions

‎.changeset/agy-home-windows.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tian.zuo/pi-antigravity": patch
3+
---
4+
5+
Shorten home-directory paths in tool cards via `os.homedir()` instead of `$HOME`, so `~/...` also renders on Windows, where that variable is unset.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tian.zuo/pi-background-terminals": patch
3+
---
4+
5+
Force exit after the background-terminal test suite finishes and run test files serially. On Windows the test runner could linger for many minutes after all tests passed when a spawned shell handle outlived its test, and the serial run avoids the open Node test-runner race (nodejs/node#64833) where `--test-force-exit` with concurrency can drop verdicts.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tian.zuo/pi-image-cache": patch
3+
---
4+
5+
Detect temp-directory sources through native real paths, so clipboard images under a Windows 8.3 short path are still recognized as temporary.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tian.zuo/pi-repo-skills": patch
3+
---
4+
5+
Canonicalize git-derived repo roots to native real paths so registry keys stay consistent on Windows, where git prints slash-normalized paths.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tian.zuo/pi-subagents": patch
3+
---
4+
5+
Resolve the worktree subdirectory through native real paths, so a subagent on Windows no longer works in a path derived from git's slash-normalized, 8.3 short-name output.

‎.changeset/tame-buses-attend.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tian.zuo/pi-repo-model": patch
3+
---
4+
5+
Canonicalize git-derived repo roots to native real paths so registry keys stay consistent and tests pass on Windows.

‎.gitattributes‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Normalize line endings so Biome's `lineEnding: lf` check passes on Windows CI.
2+
* text=auto eol=lf
3+
4+
# Binary assets must never be normalized.
5+
*.png binary
6+
*.jpg binary
7+
*.gif binary
8+
*.webp binary
9+
*.vsix binary
10+
*.tgz binary
11+
12+
# Generated files: keep diffs collapsed in reviews.
13+
pnpm-lock.yaml linguist-generated=true -diff

‎.github/workflows/ci.yml‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
workflow_call:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
# `github.workflow` keeps the reusable invocation from Release in its own
14+
# group, so it never cancels the standalone CI run for the same commit.
15+
group: ci-${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
checks:
20+
name: Checks
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 15
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v7
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v6
29+
30+
- name: Setup Node
31+
uses: actions/setup-node@v7
32+
with:
33+
node-version: 26
34+
cache: pnpm
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Typecheck monorepo
40+
run: pnpm run typecheck
41+
42+
- name: Typecheck Effect packages
43+
run: pnpm run check
44+
45+
- name: Lint
46+
run: pnpm run lint
47+
48+
- name: Pack dry run
49+
run: pnpm run pack:check
50+
51+
test:
52+
name: Test (${{ matrix.os }})
53+
runs-on: ${{ matrix.os }}
54+
timeout-minutes: 20
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
os: [ubuntu-latest, windows-latest, macos-latest]
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v7
62+
63+
- name: Setup pnpm
64+
uses: pnpm/action-setup@v6
65+
66+
- name: Setup Node
67+
uses: actions/setup-node@v7
68+
with:
69+
node-version: 26
70+
cache: pnpm
71+
72+
- name: Install dependencies
73+
run: pnpm install --frozen-lockfile
74+
75+
- name: Run tests
76+
run: pnpm test
77+
78+
ci-ok:
79+
name: CI
80+
runs-on: ubuntu-latest
81+
needs: [checks, test]
82+
if: always()
83+
steps:
84+
- name: Verify all jobs succeeded
85+
env:
86+
RESULTS: ${{ join(needs.*.result, ',') }}
87+
run: |
88+
echo "job results: $RESULTS"
89+
if [ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}" = "true" ]; then
90+
echo "One or more CI jobs did not succeed."
91+
exit 1
92+
fi
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
name: Publish
1+
name: Release
22

33
on:
44
push:
55
branches: [main]
66
paths:
77
- "packages/**"
88
- ".changeset/**"
9-
- ".github/workflows/publish.yml"
9+
- ".github/workflows/release.yml"
1010
- "package.json"
1111
- "pnpm-lock.yaml"
12+
- "pnpm-workspace.yaml"
1213
workflow_dispatch:
1314
inputs:
1415
dry_run:
@@ -17,11 +18,18 @@ on:
1718
default: false
1819

1920
concurrency:
20-
group: publish-${{ github.ref }}
21+
group: release-${{ github.ref }}
2122
cancel-in-progress: false
2223

2324
jobs:
24-
publish:
25+
# Publishing to npm is irreversible, and the Changesets release PR is opened
26+
# with the default GITHUB_TOKEN, so it never triggers `pull_request` CI.
27+
# Gate every release on the full CI suite instead.
28+
verify:
29+
uses: ./.github/workflows/ci.yml
30+
31+
release:
32+
needs: verify
2533
runs-on: ubuntu-latest
2634
permissions:
2735
contents: write
@@ -39,32 +47,20 @@ jobs:
3947
- name: Setup Node
4048
uses: actions/setup-node@v7
4149
with:
42-
node-version: 26
50+
node-version: 26 # ships npm 11.19+, which supports trusted publishing
4351
registry-url: "https://registry.npmjs.org"
4452
cache: pnpm
4553

46-
- name: Upgrade npm for trusted publishing
47-
run: npm install --global npm@^11.5.1
48-
4954
- name: Install dependencies
5055
run: pnpm install --frozen-lockfile
5156

52-
- name: Typecheck monorepo
53-
run: pnpm run typecheck
54-
55-
- name: Typecheck Effect packages
56-
run: pnpm run check
57-
58-
- name: Run tests
59-
run: pnpm test
60-
6157
- name: Preview pending releases
6258
if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
6359
env:
6460
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6561
run: |
6662
set -euo pipefail
67-
pnpm changeset:status
63+
pnpm changeset:status || true
6864
if find .changeset -maxdepth 1 -type f -name '*.md' ! -name README.md | grep -q .; then
6965
pnpm version-packages
7066
else

‎README.md‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,23 @@ publishable extension change, run `pnpm changeset`, select the package and
8585
semantic version bump, and commit the generated release-note file. Do not bump
8686
package versions manually.
8787

88-
On pushes to `main`, the [`Publish`](.github/workflows/publish.yml) workflow
89-
runs all checks and opens or updates a release PR. Merging that PR publishes
90-
each changed package to npm, updates its package-specific `CHANGELOG.md`, and
91-
creates a separate tagged GitHub release. npm trusted publishing supplies OIDC
92-
provenance without a token secret. The workflow can also be run manually from
93-
*Actions → Publish* in dry-run mode to preview pending releases. The repository
94-
must allow GitHub Actions to create pull requests under *Settings → Actions →
95-
General → Workflow permissions*.
88+
Two workflows automate quality and delivery. [`CI`](.github/workflows/ci.yml)
89+
runs on every pull request and push to `main`: typecheck, Effect checks, lint,
90+
and a packing dry run on Ubuntu, plus the full test suite on Ubuntu, Windows,
91+
and macOS. Make its `CI` summary job a required status check on `main`.
92+
93+
On pushes to `main`, [`Release`](.github/workflows/release.yml) reuses that same
94+
CI workflow as a gate and then opens or updates a release PR. Merging that PR
95+
publishes each changed package to npm, updates its package-specific
96+
`CHANGELOG.md`, and creates a separate tagged GitHub release. npm trusted
97+
publishing supplies OIDC provenance without a token secret. The workflow can
98+
also be run manually from *Actions → Release* in dry-run mode to preview pending
99+
releases. The repository must allow GitHub Actions to create pull requests under
100+
*Settings → Actions → General → Workflow permissions*.
101+
102+
The release PR is created with the default `GITHUB_TOKEN`, so it never triggers
103+
`pull_request` CI — that is why `Release` runs the checks itself instead of
104+
relying on the PR's status.
96105

97106
```bash
98107
pnpm changeset # add release notes for changed packages

0 commit comments

Comments
 (0)