Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

ci: fan the gates out into short parallel jobs, and absorb the Windows flakes (#488)

Yaowei Zhengb50b0716aa02
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
new file mode 100644
index 00000000..2818be55
--- /dev/null
+++ b/.github/actions/setup/action.yml
@@ -0,0 +1,78 @@
+# Shared prologue for every CI job: pnpm on PATH, Node 24, dependencies installed.
+#
+# pnpm comes from corepack rather than pnpm/action-setup. The version is the one
+# `packageManager` pins either way, but the action was the single most expensive
+# step on the Windows runners — 21s typical and 63s at its worst against ~5s on
+# ubuntu — while `corepack enable` is a shim install with no download of its own.
+# It has to run before setup-node, whose `cache: pnpm` resolves the store path by
+# executing pnpm.
+name: Set up pnpm, Node and dependencies
+description: Enables pnpm via corepack, installs Node 24 with a warm pnpm store, and runs a frozen install.
+
+inputs:
+ build:
+ description: >-
+ pnpm --filter arguments naming what to build, comma separated (e.g.
+ "@prismshadow/penguin-core..."). Empty builds nothing — a job that only reads
+ sources, such as the Prettier gate, needs no dist at all.
+ required: false
+ default: ""
+
+runs:
+ using: composite
+ steps:
+ # corepack fetches the pinned pnpm tarball on first use -- ~20s on the Windows runner,
+ # which is most of what replacing pnpm/action-setup was meant to save. Cache what it
+ # unpacks, keyed on the packageManager pin, and the fetch happens once per pin per OS.
+ - name: Cache corepack's pnpm
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/node/corepack
+ ~/AppData/Local/node/corepack
+ key: corepack-${{ runner.os }}-${{ hashFiles('package.json') }}
+
+ - name: Enable pnpm (corepack)
+ shell: bash
+ env:
+ COREPACK_ENABLE_DOWNLOAD_PROMPT: "0"
+ run: |
+ corepack enable
+ # Materialise the pinned version now so the cache above has something to save, and
+ # so a download failure surfaces here rather than inside an unrelated step.
+ pnpm --version
+
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 24
+ cache: pnpm
+
+ - name: Install dependencies
+ shell: bash
+ run: pnpm install --frozen-lockfile
+
+ # Only the requested packages and their dependencies. A shard that tests core
+ # alone does not pay for the desktop bundle, which is the slowest target here.
+ # verify-deps-before-run is off because it wants a TTY it does not have on a runner.
+ #
+ # The empty check is in the script, not a step-level `if`. A composite step whose `if`
+ # reads `inputs` silently evaluated false here, so every job skipped its build and only
+ # the shards that never import a built package stayed green -- a failure that looks like
+ # a broken test, not a broken workflow. The echo makes the decision visible in the log.
+ - name: Build (tsup)
+ shell: bash
+ env:
+ BUILD_FILTERS: ${{ inputs.build }}
+ run: |
+ if [ -z "$BUILD_FILTERS" ]; then
+ echo "No build requested for this job."
+ exit 0
+ fi
+ args=""
+ IFS=','
+ for f in $BUILD_FILTERS; do
+ args="$args --filter $f"
+ done
+ unset IFS
+ echo "pnpm$args build"
+ pnpm --config.verify-deps-before-run=false $args build
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8165de6d..6566ee54 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,7 +1,15 @@
-# CI: build -> style (Prettier) -> typecheck (tsc) -> unit tests (vitest) -> live e2e (DeepSeek).
-# Build first: core's exports point at dist/, and cli's type resolution and runtime imports both need core's build output.
-# e2e needs the repo secret DEEPSEEK_API_KEY; when absent (e.g. forks) that step self-skips and the other checks run as usual.
-# Two more jobs repeat build/typecheck/test on macos-latest and windows-latest (ci-macos / ci-windows below).
+# CI: one gate (`ci`) over a fan-out of short jobs.
+#
+# The shape is chosen for wall clock. The old workflow ran build -> style -> typecheck ->
+# test -> installer -> e2e as six serial steps inside one job per platform, so every
+# platform paid for every gate in sequence and the slowest job — Windows, at 254s — set
+# the whole run's length. Here each gate is its own job, tests are sharded by package,
+# and every job builds only the packages its shard actually needs (see the shared setup
+# action). Nothing is dropped: every package's tests still run exactly once per platform.
+#
+# `ci` at the bottom is the aggregate gate. It is the one job worth marking required in
+# branch protection — the shard names below are an implementation detail and will change
+# again as the suite grows, whereas `ci` means what it has always meant.
name: CI
# Limit triggers to avoid duplicate runs: push runs only on main/dev; PRs always run once (no target-branch filter --
@@ -17,39 +25,88 @@ concurrency:
cancel-in-progress: true
jobs:
- ci:
+ # Prettier reads sources, so this needs no build at all — the cheapest job in the run.
+ style:
+ name: style (prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
-
- # pnpm version comes from package.json's packageManager field.
- - uses: pnpm/action-setup@v6
-
- - uses: actions/setup-node@v5
- with:
- node-version: 24
- cache: pnpm
-
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
-
- - name: Build (tsup)
- run: pnpm build
-
+ - uses: ./.github/actions/setup
- name: Code style (Prettier)
run: pnpm format:check
+ # A workflow that does not parse produces a run with zero jobs and no annotation
+ # anywhere useful -- the failure this very file shipped once, over a double-quoted
+ # string in a ${{ }} expression, where only single quotes are legal. Cheap to catch.
+ - name: Lint workflows (actionlint)
+ run: |
+ ver=1.7.12
+ curl -fsSL "https://github.com/rhysd/actionlint/releases/download/v${ver}/actionlint_${ver}_linux_amd64.tar.gz" \
+ | tar xz actionlint
+ # -shellcheck= turns off the bundled shellcheck pass: what is wanted here is the
+ # workflow-expression and schema check, and shellcheck's info-level findings in
+ # workflows this change does not touch are a separate conversation.
+ ./actionlint -shellcheck=
+
+ # tsc over every package, so this one does need the whole build. Results are
+ # platform-independent, which is why neither macOS nor Windows repeats it.
+ typecheck:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v5
+ # tsc runs over every package, so every package's dist has to exist -- core's test
+ # files read skills' emitted types, for one.
+ - uses: ./.github/actions/setup
+ with:
+ build: "@prismshadow/penguin-desktop...,@prismshadow/penguin-landing...,@prismshadow/penguin-docs...,@prismshadow/penguin-server...,@prismshadow/penguin-cli...,@prismshadow/penguin-web...,@prismshadow/penguin-skills..."
- name: Typecheck (tsc)
run: pnpm typecheck
+ # The unit suite, split four ways. Shards are drawn so that build cost and test cost
+ # roughly balance: core and server are the two long suites and get one each, the rest
+ # pair up behind them.
+ test:
+ name: test (${{ matrix.shard }})
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - shard: core
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-core test
+ - shard: server
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-server test
+ - shard: web-cli
+ build: "@prismshadow/penguin-core...,@prismshadow/penguin-web..."
+ tests: pnpm --filter @prismshadow/penguin-web --filter @prismshadow/penguin-cli test
+ - shard: rest
+ build: "@prismshadow/penguin-desktop..."
+ tests: >-
+ pnpm --filter @prismshadow/penguin-desktop --filter @prismshadow/penguin-landing
+ --filter @prismshadow/penguin-docs --filter @prismshadow/penguin-skills test
+ steps:
+ - uses: actions/checkout@v5
+ - uses: ./.github/actions/setup
+ with:
+ build: ${{ matrix.build }}
- name: Unit tests (vitest)
- run: pnpm test
+ run: ${{ matrix.tests }}
+ # The installer bundle and the live-LLM e2e, together because both want a full build and
+ # neither is long. The secret is exposed only in its own step (step-level env), so earlier
+ # steps and third-party actions cannot see it; the secrets context is not usable in `if`,
+ # so the skip happens inside the shell for forks, where it is absent.
+ installer-e2e:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v5
+ - uses: ./.github/actions/setup
+ with:
+ build: "@prismshadow/penguin-cli...,@prismshadow/penguin-server..."
- name: Installer bundle and POSIX installer tests
run: sh scripts/test-installer.sh
-
- # The secret is exposed only in this step (step-level env); earlier steps and third-party actions can't see it.
- # The secrets context can't be used in if expressions, so skip inside the shell when it's absent (e.g. forks).
- name: E2E (live LLM via DeepSeek)
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
@@ -60,95 +117,112 @@ jobs:
fi
pnpm test:e2e
- # macOS: the same build/typecheck/test gates on macos-latest (arm64). This is the only job
- # where the terminal's pty suites run on darwin — node-pty compiles against the runner's
- # toolchain and its darwin-only spawn-helper actually executes — and the terminal smoke
- # script then re-runs node-pty under Electron's own Node (ELECTRON_RUN_AS_NODE), resolved
- # from the built desktop bundle: the same module lookup, on the same runtime, that the
- # packaged app's server performs. It runs after the build because that staged copy is a
- # build output. A macOS terminal regression that once shipped as a silently empty panel
- # fails here instead. No format:check (same files as ubuntu) and no live-LLM e2e
- # (ubuntu-only budget).
- ci-macos:
+ # macOS (arm64). This is the only place the terminal's pty suites run on darwin —
+ # node-pty compiles against the runner's toolchain and its darwin-only spawn-helper
+ # actually executes — and the terminal smoke script then re-runs node-pty under
+ # Electron's own Node (ELECTRON_RUN_AS_NODE), resolved from the built desktop bundle:
+ # the same module lookup, on the same runtime, that the packaged app's server performs.
+ # A macOS terminal regression that once shipped as a silently empty panel fails here.
+ # No format:check and no typecheck (same files, platform-independent results, gated on
+ # ubuntu); no live-LLM e2e (ubuntu-only budget).
+ test-macos:
+ name: test-macos (${{ matrix.shard }})
runs-on: macos-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - shard: core
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-core test
+ smoke: false
+ - shard: server
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-server test
+ smoke: false
+ - shard: rest
+ build: "@prismshadow/penguin-desktop...,@prismshadow/penguin-cli..."
+ tests: >-
+ pnpm -r --filter '!@prismshadow/penguin-core' --filter '!@prismshadow/penguin-server' test
+ smoke: true
steps:
- uses: actions/checkout@v5
-
- # pnpm version comes from package.json's packageManager field.
- - uses: pnpm/action-setup@v6
-
- - uses: actions/setup-node@v5
+ - uses: ./.github/actions/setup
with:
- node-version: 24
- cache: pnpm
-
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
-
- - name: Build (tsup)
- run: pnpm build
-
- - name: Typecheck (tsc)
- run: pnpm typecheck
-
+ build: ${{ matrix.build }}
- name: Unit tests (vitest)
- run: pnpm test
-
+ run: ${{ matrix.tests }}
- name: Terminal smoke (node-pty under Electron's Node)
+ if: matrix.smoke
run: node packages/desktop/scripts/terminal-smoke.mjs
- # Windows: the same build/test gates on windows-latest (the ubuntu job above stays the
- # required one), split into two shards so the process-heavy suites don't share a small
- # runner: `server` gives the pty-streaming suites the whole machine and carries the
- # installer checks, while `packages` runs core alone first (its exec_command suites spawn
- # real shells and read their output under timeouts, races they lose when oversubscribed)
- # and the remaining packages together after it. Every package's tests run exactly once
- # across the two shards. The runner ships Git-Bash on PATH, so core's exec_command tests
- # run through the shell resolver's bash pick; genuinely POSIX-only tests skip themselves
- # via process.platform guards (not CI filters), so local Windows devs see the same
- # behavior. Line endings come from .gitattributes (LF working tree), keeping build
- # outputs and fixtures byte-identical. No format:check and no typecheck (same files as
- # ubuntu, and both results are platform-independent, so the ubuntu job gates them); no
- # live-LLM e2e here (ubuntu-only budget).
- ci-windows:
+ # Windows. The runner is the slowest and the most I/O-variable of the three, so the
+ # server suite — the longest here by a wide margin — is split across two vitest shards
+ # on top of the per-package split. core runs alone rather than beside anything else:
+ # its exec_command suites spawn real shells and read their output under timeouts, races
+ # they lose when oversubscribed. Every package's tests still run exactly once across the
+ # shards. The runner ships Git-Bash on PATH, so core's exec_command tests exercise
+ # the shell resolver's bash pick; genuinely POSIX-only tests skip themselves via
+ # process.platform guards rather than CI filters, so a local Windows dev sees the same
+ # behaviour. Every package's tests still run exactly once across the shards. Line
+ # endings come from .gitattributes (LF working tree), keeping build
+ # outputs and fixtures byte-identical. No format:check, no typecheck, no e2e — see the
+ # macOS note above.
+ test-windows:
+ name: test-windows (${{ matrix.shard }})
+ runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- - shard: server
- tests: pnpm --filter @prismshadow/penguin-server test
- installer: true
- - shard: packages
+ - shard: core
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-core test
+ - shard: server-1
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-server exec vitest run --shard=1/3
+ - shard: server-2
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-server exec vitest run --shard=2/3
+ - shard: server-3
+ build: "@prismshadow/penguin-core..."
+ tests: pnpm --filter @prismshadow/penguin-server exec vitest run --shard=3/3
+ - shard: rest
+ build: "@prismshadow/penguin-desktop...,@prismshadow/penguin-cli..."
tests: >-
- pnpm --filter @prismshadow/penguin-core test &&
pnpm -r --filter '!@prismshadow/penguin-core' --filter '!@prismshadow/penguin-server' test
- installer: false
- name: ci-windows (${{ matrix.shard }})
- runs-on: windows-latest
steps:
- uses: actions/checkout@v5
-
- # pnpm version comes from package.json's packageManager field.
- - uses: pnpm/action-setup@v6
-
- - uses: actions/setup-node@v5
+ - uses: ./.github/actions/setup
with:
- node-version: 24
- cache: pnpm
-
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
-
- - name: Build (tsup)
- run: pnpm build
+ build: ${{ matrix.build }}
+ # One retry, and only here. Per-test flakes are already absorbed inside vitest
+ # (`retry` in core's and the server's configs, Windows only); what this covers is the
+ # failure that has no failing test at all — a tinypool `ERR_IPC_CHANNEL_CLOSED` raised
+ # while the worker pool tears down, after every file has reported green. A real
+ # regression fails both attempts.
- name: Unit tests (vitest)
- run: ${{ matrix.tests }}
+ shell: bash
+ run: |
+ ${{ matrix.tests }} && exit 0
+ echo "::warning::vitest failed on Windows; retrying once (see the pool-teardown note in ci.yml)"
+ ${{ matrix.tests }}
+
+ # The Windows installer checks, in their own job rather than riding a test shard: they add
+ # ~20s and have nothing to do with the suite they were attached to, which happened to be
+ # the longest one in the run.
+ installer-windows:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v5
+ - uses: ./.github/actions/setup
+ with:
+ build: "@prismshadow/penguin-cli..."
# The Linux job cannot validate PowerShell syntax; parse (never execute) the installer
# scripts with the real PowerShell parser so a broken install.ps1 cannot ship.
- name: Parse installer scripts (PowerShell)
- if: matrix.installer
shell: pwsh
run: |
$failed = $false
@@ -168,20 +242,18 @@ jobs:
if ($failed) { exit 1 }
- name: Windows installer tests
- if: matrix.installer
shell: pwsh
run: ./scripts/test-installer.ps1
- # Runtime desktop app, in parallel with the test jobs: an unpacked Electron
- # shell that boots the server and WAITS for hot-reload requests (the
- # "runtime" form of the four-layer model). The platform units are the
- # existing packages (server = backend platform, web = frontend platform);
- # the artifact bakes a copy of both in so it works out of the box, and its
- # running platform is replaceable over /api/hmr. Built with electron-builder
- # `--dir` (an unpacked app directory including the Electron runtime, not an
- # installer): a runtime is meant to be dropped in and hot-updated, not
- # distributed through an installer channel — signed installers stay in
- # desktop-build.yml. Unsigned by design.
+ # Runtime desktop app, in parallel with the test jobs: an unpacked Electron shell that
+ # boots the server and WAITS for hot-reload requests (the "runtime" form of the
+ # four-layer model). The platform units are the existing packages (server = backend
+ # platform, web = frontend platform); the artifact bakes a copy of both in so it works
+ # out of the box, and its running platform is replaceable over /api/hmr. Built with
+ # electron-builder `--dir` (an unpacked app directory including the Electron runtime,
+ # not an installer): a runtime is meant to be dropped in and hot-updated, not distributed
+ # through an installer channel — signed installers stay in desktop-build.yml. Unsigned
+ # by design.
runtime:
strategy:
fail-fast: false
@@ -198,18 +270,9 @@ jobs:
contents: read
steps:
- uses: actions/checkout@v5
-
- # pnpm version comes from package.json's packageManager field.
- - uses: pnpm/action-setup@v6
-
- - uses: actions/setup-node@v5
+ - uses: ./.github/actions/setup
with:
- node-version: 24
- cache: pnpm
-
- - run: pnpm install --frozen-lockfile
-
- - run: pnpm build
+ build: "@prismshadow/penguin-desktop..."
- name: Build unpacked runtime
env:
@@ -236,3 +299,24 @@ jobs:
packages/desktop/out/mac
packages/desktop/out/mac-arm64
packages/desktop/out/mac-x64
+
+ # The aggregate gate: green only when every job above is. Mark THIS one required in
+ # branch protection — it survives the shard list changing, which the individual job
+ # names do not. `if: always()` so it still runs (and fails) when something upstream did.
+ ci:
+ if: always()
+ needs:
+ [style, typecheck, test, installer-e2e, test-macos, test-windows, installer-windows, runtime]
+ runs-on: ubuntu-latest
+ steps:
+ - name: Every gate passed
+ run: |
+ results='${{ join(needs.*.result, ' ') }}'
+ echo "upstream results: $results"
+ for r in $results; do
+ if [ "$r" != "success" ]; then
+ echo "::error::a CI job did not succeed ($results)"
+ exit 1
+ fi
+ done
+ echo "all green"
diff --git a/changelog/unreleased/2026-08-27-ci-parallel-gates.md b/changelog/unreleased/2026-08-27-ci-parallel-gates.md
new file mode 100644
index 00000000..503fb7ba
--- /dev/null
+++ b/changelog/unreleased/2026-08-27-ci-parallel-gates.md
@@ -0,0 +1,47 @@
+# CI runs as parallel shards instead of one serial job per platform
+
+- **Date:** 2026-08-27
+- **Type:** process
+- **Scope:** `ci`, `tooling`
+- **PR:** [#488](https://github.com/Prism-Shadow/penguin-harness/pull/488)
+
+[中文版](2026-08-27-ci-parallel-gates.zh.md)
+
+CI ran build, style, typecheck, test, installer and e2e as six serial steps inside one job per
+platform, so every platform paid for every gate in sequence and the slowest job set the run's
+length — 254s, of which the longest job spent 138s in vitest and 35s building all nine packages,
+most of which that job never loaded. Each gate is now its own job and the unit suite is sharded
+by package.
+
+## Details
+
+- Every job builds only the packages its shard loads. That is measured rather than derived from
+ the dependency graph: the server shards build `@prismshadow/penguin-core...` and not
+ `@prismshadow/penguin-server...`, which would drag in web because the server package ships
+ `web-dist` that its tests never read.
+- Coverage is unchanged. Every package's tests run exactly once per platform, and the shard sets
+ each sum to the repository's 297 test files.
+- Windows splits the core and server suites across vitest shards on top of the per-package split,
+ because setup alone costs 55–81s there before a test runs. ubuntu and macOS keep whole suites.
+- The Windows installer checks move out of the test matrix into their own job; they were riding
+ the longest shard and adding 20s to the critical path.
+- pnpm comes from corepack rather than `pnpm/action-setup`, with the tarball corepack fetches
+ cached on the `packageManager` pin.
+- `ci` becomes an aggregate job gated on every other one, so branch protection has one name to
+ require that survives the shard list changing.
+- The `style` job runs `actionlint` over every workflow. A workflow that does not parse produces
+ a run with zero jobs and leaves no annotation on the run, the check suite or the commit status.
+
+## Flaky tests
+
+- `retry` in core's and the server's vitest configs: two attempts on Windows, one on macOS, none
+ on Linux. Those suites spawn real shells and drive real ptys under deadlines, and the two
+ runners lose those races at a measurable rate — one batch of reruns failed four Windows
+ attempts in a row and then passed twice, on four different tests, from a change that could not
+ affect behaviour. A retry costs nothing when everything passes, and a real regression still
+ fails every attempt.
+- A failure with no failing test — a tinypool `ERR_IPC_CHANNEL_CLOSED` raised while the worker
+ pool tears down, after every file has reported green — is outside what a per-test retry can
+ reach, so the Windows test step retries its whole command once and warns when it does.
+- `dangerouslyIgnoreUnhandledErrors` would have silenced the teardown crash for nothing, and
+ would have silenced a genuine Windows-only unhandled rejection with it. It is not used.
diff --git a/changelog/unreleased/2026-08-27-ci-parallel-gates.zh.md b/changelog/unreleased/2026-08-27-ci-parallel-gates.zh.md
new file mode 100644
index 00000000..bc1256d4
--- /dev/null
+++ b/changelog/unreleased/2026-08-27-ci-parallel-gates.zh.md
@@ -0,0 +1,40 @@
+# CI 改为并行分片,不再是每个平台一个串行 job
+
+- **Date:** 2026-08-27
+- **Type:** process
+- **Scope:** `ci`, `tooling`
+- **PR:** [#488](https://github.com/Prism-Shadow/penguin-harness/pull/488)
+
+[English](2026-08-27-ci-parallel-gates.md)
+
+CI 此前把构建、代码风格、类型检查、测试、安装器与 e2e 作为六个串行步骤放在每个平台各一个 job 里,于是
+每个平台都要按顺序把每道门都付一遍,整条流水线的长度由最慢的那个 job 决定——254 秒,其中最长的 job
+有 138 秒花在 vitest 上、35 秒用来构建全部九个包,而那个 job 里的大部分包它根本不会加载。现在每道门
+各自成为一个 job,单元测试按包分片。
+
+## 细节
+
+- 每个 job 只构建自己这一片会加载的包。这是实测出来的,而不是从依赖图上推出来的:server 的分片构建
+ `@prismshadow/penguin-core...` 而非 `@prismshadow/penguin-server...`——后者会把 web 一并拽进来,
+ 因为 server 包需要交付 `web-dist`,而它的测试一个字节都不读。
+- 覆盖范围不变。每个包的测试在每个平台上恰好跑一次,各平台的分片集合分别加总都等于仓库的 297 个测试文件。
+- Windows 在按包分片之外,还把 core 与 server 两套测试再按 vitest 分片切开:那台 runner 光是准备工作
+ 就要 55–81 秒才轮得到第一个测试。ubuntu 与 macOS 保持整套不切。
+- Windows 的安装器检查从测试矩阵中挪出、独立成 job:它此前挂在最长的那一片上,白给关键路径添了 20 秒。
+- pnpm 改由 corepack 提供,不再用 `pnpm/action-setup`,并按 `packageManager` 中钉住的版本缓存
+ corepack 拉取的压缩包。
+- `ci` 成为汇总 job,依赖其余全部 job,这样分支保护只需要求这一个名字——分片列表变化时它依然成立。
+- `style` job 会对所有 workflow 运行 `actionlint`。一个无法解析的 workflow 产生的 run 里一个 job 都没有,
+ 且在 run、check suite 与 commit status 三处都不留下任何注解。
+
+## 不稳定的测试
+
+- core 与 server 的 vitest 配置中加入 `retry`:Windows 重试两次,macOS 一次,Linux 不重试。这两套测试
+ 会派生真实 shell、驱动真实 pty,并在限时内读取输出,而这两台 runner 输掉这类竞争的比例是可测的——
+ 某一批重跑中,Windows 连续四次失败后又连续两次通过,失败的是四个**不同**的测试,而当次改动根本不可能
+ 影响行为。全部通过时重试不产生任何代价,真正的回归仍然每次都失败。
+- 还有一类失败没有任何测试失败——worker 池拆解时抛出的 tinypool `ERR_IPC_CHANNEL_CLOSED`,此时所有
+ 文件都已报告通过——这超出了逐测试重试能覆盖的范围,因此 Windows 的测试步骤会把整条命令重试一次,
+ 并在重试时发出警告。
+- `dangerouslyIgnoreUnhandledErrors` 能不花代价地消掉这个崩溃,但也会连真正的、仅在 Windows 出现的
+ unhandled rejection 一起消掉,因此没有采用。
diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts
index 93af2750..b5345ae2 100644
--- a/packages/core/vitest.config.ts
+++ b/packages/core/vitest.config.ts
@@ -21,6 +21,14 @@
*
* A larger failure deadline changes nothing for passing tests; POSIX keeps the 5s
* default to fail fast during local development.
+ *
+ * `retry` on win32: the suites here spawn real shells and read their output under
+ * deadlines, and the Windows runners lose those races at a measurable rate — over one
+ * batch of reruns the Windows shard failed 4 attempts in a row and then passed twice, on
+ * four DIFFERENT tests, from a diff that could not change behaviour at all. Retrying the
+ * individual test costs nothing when everything passes and rescues the runs that would
+ * otherwise be re-triggered by hand; a real regression fails all three attempts. POSIX
+ * keeps 0 so a flake introduced there is seen the first time.
*/
import { defineConfig } from "vitest/config";
@@ -28,5 +36,6 @@ export default defineConfig({
test: {
environment: "node",
testTimeout: process.platform === "win32" ? 120_000 : 5_000,
+ retry: process.platform === "win32" ? 2 : process.platform === "darwin" ? 1 : 0,
},
});
diff --git a/packages/server/vitest.config.ts b/packages/server/vitest.config.ts
index f1fccb87..9df415da 100644
--- a/packages/server/vitest.config.ts
+++ b/packages/server/vitest.config.ts
@@ -20,6 +20,14 @@
* one at a time. The pool stays `forks` for that last reason: `process.env` is per-process,
* so a thread pool would let those env-mutating files race each other.
*
+ * `retry` on win32 mirrors core's: real SQLite files and full app trees against a runner
+ * whose I/O stalls at a measurable rate, retried per test rather than by re-running the
+ * job. Linux keeps 0. What it does NOT cover is a failure with no failing test — a pool
+ * teardown crash — which ci.yml absorbs with one retry of the whole command instead.
+ *
+ * macOS is retried once too: terminal-stream.test.ts drives a real pty and asserts on what
+ * came back through it, and that assertion has lost the race on the macOS runner.
+ *
* `restoreMocks` makes the spy half of that mechanical rather than a reading of the suite:
* a `vi.spyOn` whose inline `mockRestore()` is skipped by a failing assertion above it
* would otherwise stay installed for every later file in the same worker.
@@ -33,5 +41,6 @@ export default defineConfig({
restoreMocks: true,
testTimeout: process.platform === "win32" ? 30_000 : 5_000,
hookTimeout: process.platform === "win32" ? 30_000 : 10_000,
+ retry: process.platform === "win32" ? 2 : process.platform === "darwin" ? 1 : 0,
},
});