mirror of
https://ghproxy.cflmy.top/https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-11-28 08:09:35 +08:00
ci: build once and fan web snapshots out across weighted shards (#8861)
* ci: build once and fan web snapshots out across weighted shards * ci: stamp restored build output with the extraction time Build-time mtimes shifted past the clock made HMR treat freshly loaded lib/ modules as changed and reload a plugin context while it was still loading (plugin-manager-mcp headless snapshot). * ci(web): run the longest web snapshot files as round-robin test slices * ci: address review on the build-once fan-out
This commit is contained in:
1 parent
7598e5d640
commit
0ee562045e
23 files changed
+951
-67
No files matched your search
@@ -9,8 +9,8 @@
|
||||
en: bcdd24f3c39d593c
|
||||
zh: 3e576d09c8c3bfd4
|
||||
/agent-note-ci-failover-runbook-hosted-pools-in-house-pool/decision:
|
||||
en: fed13ca92e488b69
|
||||
zh: 9e5c9cdc118ab84e
|
||||
en: 23fc560e2c12be5e
|
||||
zh: 89071bd1735823ff
|
||||
/agent-note-ci-failover-runbook-hosted-pools-in-house-pool/decision/release-rehearsals-share-the-linux-switch:
|
||||
en: 01e74068e0a96375
|
||||
zh: aa811861ce30cb47
|
||||
|
||||
@@ -10,7 +10,7 @@ The three required Linux worker jobs in [CI](../../../../.github/workflows/ci.ym
|
||||
|
||||
## Decision
|
||||
|
||||
The three primary Linux jobs (`node-24`, `node-24-coverage`, `node-24-consumers`), the two `node-compat` matrix entries, and the `all-checks-passed`, `windows-checks-passed`, and `python-checks-passed` verdicts resolve through `DSH_CI_FAILOVER_LINUX`; the native Windows jobs resolve through `DSH_CI_FAILOVER_WINDOWS`. A platform switch does not redirect the other platform. Set to `selfhosted` by a repository writer, the applicable trusted jobs select `vm-backup` or `dsh-win-ci`; the `blacksmith` value routes the participating jobs per the [blacksmith failover leg note](2026-09-09-blacksmith-failover-leg.md); unset or any other value retains the workflow-defined hosted fallbacks. Node compatibility jobs require a same-repository, non-fork head and a non-Dependabot author, use isolated runtime setup, and retain the `ubuntu-latest` fallback under unset and non-special values; the blacksmith branch carries none of those predicates. Under the `selfhosted` value, Linux failover bounds snapshot concurrency and skips hosted package-cache restores. The three verdict jobs follow the Linux switch so they do not remain queued on an unavailable hosted pool. Each switch is writer-manageable repository state, not a merge, so it works while checks are red. The `serial / linux (self-hosted standby)` and `serial / windows (self-hosted standby)` lanes re-prove the complete unsharded aggregates on master pushes.
|
||||
The primary Linux jobs (`node-24`, `node-24-coverage`, `node-24-build`, `node-24-consumers`, which restores the `node-24-build` output, and both entries of the `node-24-web-snapshot` shard matrix), the two `node-compat` matrix entries, and the `all-checks-passed`, `windows-checks-passed`, and `python-checks-passed` verdicts resolve through `DSH_CI_FAILOVER_LINUX`; the native Windows jobs resolve through `DSH_CI_FAILOVER_WINDOWS`. A platform switch does not redirect the other platform. Set to `selfhosted` by a repository writer, the applicable trusted jobs select `vm-backup` or `dsh-win-ci`; the `blacksmith` value routes the participating jobs per the [blacksmith failover leg note](2026-09-09-blacksmith-failover-leg.md); unset or any other value retains the workflow-defined hosted fallbacks. Node compatibility jobs require a same-repository, non-fork head and a non-Dependabot author, use isolated runtime setup, and retain the `ubuntu-latest` fallback under unset and non-special values; the blacksmith branch carries none of those predicates. Under the `selfhosted` value, Linux failover bounds snapshot concurrency and skips hosted package-cache restores. The three verdict jobs follow the Linux switch so they do not remain queued on an unavailable hosted pool. Each switch is writer-manageable repository state, not a merge, so it works while checks are red. The `serial / linux (self-hosted standby)` and `serial / windows (self-hosted standby)` lanes re-prove the complete unsharded aggregates on master pushes.
|
||||
|
||||
The [superseded-CI cancellation policy](../../../../.github/workflows/ci.yml) governs master pushes and manual runs in the same workflow/ref group, including standby drills. Rapid master updates can starve a drill before it reaches a verdict. Use the latest completed standby verdict and check its age and commit before treating it as readiness evidence; a cancelled or merely scheduled run is not proof of readiness.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Status: implemented
|
||||
|
||||
## 决策
|
||||
|
||||
三个主要 Linux 作业(`node-24`、`node-24-coverage`、`node-24-consumers`)、两个 `node-compat` 矩阵条目,以及 `all-checks-passed`、`windows-checks-passed`、`python-checks-passed` 三个判定作业通过 `DSH_CI_FAILOVER_LINUX` 解析;原生 Windows 作业通过 `DSH_CI_FAILOVER_WINDOWS` 解析。一个平台的开关不会重定向另一个平台。仓库写者将变量设为 `selfhosted` 时,适用的可信作业选择 `vm-backup` 或 `dsh-win-ci`;`blacksmith` 取值按 [blacksmith 故障切换支路笔记](2026-09-09-blacksmith-failover-leg.zh.md) 路由参与切换的作业;未设置或任何其它值保留工作流定义的托管回退。Node 兼容性作业要求同仓库且非 fork 的头部以及非 Dependabot 作者,使用隔离运行时设置,并在未设置与非特殊值下保留 `ubuntu-latest` 回退;blacksmith 分支不带上述任何条件。在 `selfhosted` 取值下,Linux 故障切换会限制快照并发,并跳过托管软件包缓存恢复。三个判定作业跟随 Linux 开关,避免继续在不可用的托管池排队。每个开关都是写者可管理的仓库状态而非一次合并,因此在检查失败时仍然有效。`serial / linux (self-hosted standby)` 与 `serial / windows (self-hosted standby)` 通道在 master 推送上重新验证完整的未分片聚合流程。
|
||||
主要 Linux 作业(`node-24`、`node-24-coverage`、`node-24-build`、恢复 `node-24-build` 产物的 `node-24-consumers`,以及 `node-24-web-snapshot` 分片矩阵的两个条目)、两个 `node-compat` 矩阵条目,以及 `all-checks-passed`、`windows-checks-passed`、`python-checks-passed` 三个判定作业通过 `DSH_CI_FAILOVER_LINUX` 解析;原生 Windows 作业通过 `DSH_CI_FAILOVER_WINDOWS` 解析。一个平台的开关不会重定向另一个平台。仓库写者将变量设为 `selfhosted` 时,适用的可信作业选择 `vm-backup` 或 `dsh-win-ci`;`blacksmith` 取值按 [blacksmith 故障切换支路笔记](2026-09-09-blacksmith-failover-leg.zh.md) 路由参与切换的作业;未设置或任何其它值保留工作流定义的托管回退。Node 兼容性作业要求同仓库且非 fork 的头部以及非 Dependabot 作者,使用隔离运行时设置,并在未设置与非特殊值下保留 `ubuntu-latest` 回退;blacksmith 分支不带上述任何条件。在 `selfhosted` 取值下,Linux 故障切换会限制快照并发,并跳过托管软件包缓存恢复。三个判定作业跟随 Linux 开关,避免继续在不可用的托管池排队。每个开关都是写者可管理的仓库状态而非一次合并,因此在检查失败时仍然有效。`serial / linux (self-hosted standby)` 与 `serial / windows (self-hosted standby)` 通道在 master 推送上重新验证完整的未分片聚合流程。
|
||||
|
||||
[被取代 CI 的取消策略](../../../../.github/workflows/ci.yml) 管理同一工作流/引用组内的 master 推送和手动运行,包括热备演练。master 快速更新可能让演练因反复被取消而始终无法得出结论。判断就绪状态时,使用最近一次已完成的热备结论,并核对其时间和提交;已取消或仅被调度的运行不构成就绪证据。
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
en: 6a1b4ed0d9910133
|
||||
zh: f32c6882208ded71
|
||||
/agent-note-split-build-artifacts-and-build-check-with-build-running-both-concurrently/decision/callers:
|
||||
en: 895968956b86a9d2
|
||||
zh: 5218d9ab8c60a53a
|
||||
en: dad172a1cabc42cb
|
||||
zh: 0180238dcb53ee3f
|
||||
/agent-note-split-build-artifacts-and-build-check-with-build-running-both-concurrently/decision/measurements:
|
||||
en: b3a753ac2aab6073
|
||||
zh: 19cbd0e32751896f
|
||||
|
||||
@@ -50,7 +50,7 @@ Each command does only its own job.
|
||||
| `typecheck` (run by the pre-push hook) | `build.ts --scope typecheck`: host-typert (the source-only Typert pass `generate-typert.ts`) → package compilation, with `tsc -b tsconfig.{host,client}.json` after each face's package compilation; no bundle | Yes |
|
||||
| `dev:web` ([`scripts/dev-web.ts`](../../../../scripts/dev-web.ts)), `dev:desktop` (`apps/desktop/scripts/dev.ts`) | `build:artifacts` | None before launch; after `dev:web` launches, its `tsc -b tsconfig.client.json --watch` keeps checking the Client aggregate root program |
|
||||
| Prerequisite step of `lint`, `lint:fix`, `doc-typecheck`, and the CI Typert contracts gate | Source-only Typert generation before Host package compilation (`compile-referenced-projects.ts host-contracts`), without any bundle | None |
|
||||
| CI node 24 / snapshots and artifacts (`check:ci:consumers`), windows node 24 / build & observational (`check:ci:windows-blocking`) | `build` | Yes, the two required lanes |
|
||||
| CI node 24 / build (`check:ci:build`), whose restored output `node 24 / snapshots and artifacts` (`check:ci:consumers-prebuilt`) and `node 24 / web snapshots <shard>/2` consume, windows node 24 / build & observational (`check:ci:windows-blocking`) | `build` | Yes, the two required lanes |
|
||||
| CI node-compat 24.9 | `build:artifacts` (through run-gates) | None |
|
||||
| CI python runtime | `build-exe-for-python-sdk.ts --build-artifacts` | None |
|
||||
| PR rehearsals in `e2e.yml` and `release.yml` | `pnpm run build:artifacts --profile official` | None |
|
||||
|
||||
@@ -50,7 +50,7 @@ Status: implemented
|
||||
| `typecheck`(pre-push hook 运行它) | `build.ts --scope typecheck`:host-typert(只读源码的 Typert 生成 `generate-typert.ts`)→ 包编译,各 face 包编译后运行 `tsc -b tsconfig.{host,client}.json`;不含任何 bundle | 有 |
|
||||
| `dev:web`([`scripts/dev-web.ts`](../../../../scripts/dev-web.ts))、`dev:desktop`(`apps/desktop/scripts/dev.ts`) | `build:artifacts` | 启动前无;`dev:web` 启动后的 `tsc -b tsconfig.client.json --watch` 持续检查 Client 聚合根程序 |
|
||||
| `lint`、`lint:fix`、`doc-typecheck` 与 CI 的 Typert contracts gate 的前置步骤 | 仅源码 Typert 生成后进行 Host 包编译(`compile-referenced-projects.ts host-contracts`),不含任何 bundle | 无 |
|
||||
| CI node 24 / snapshots and artifacts(`check:ci:consumers`)、windows node 24 / build & observational(`check:ci:windows-blocking`) | `build` | 有,两个必需 lane |
|
||||
| CI node 24 / build(`check:ci:build`,`node 24 / snapshots and artifacts`(`check:ci:consumers-prebuilt`)与 `node 24 / web snapshots <shard>/2` 恢复并消费其产物)、windows node 24 / build & observational(`check:ci:windows-blocking`) | `build` | 有,两个必需 lane |
|
||||
| CI node-compat 24.9 | `build:artifacts`(经 run-gates) | 无 |
|
||||
| CI python runtime | `build-exe-for-python-sdk.ts --build-artifacts` | 无 |
|
||||
| `e2e.yml`、`release.yml` 的 PR 演练 | `pnpm run build:artifacts --profile official` | 无 |
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
en: c529437d4fbaeeb3
|
||||
zh: fe13551e56cba7df
|
||||
/agent-note-keyless-browser-e2e-lane-for-the-web-gui/decision/ci-stance:
|
||||
en: a4ed258cd19db1c0
|
||||
zh: 913e079a6250d7d7
|
||||
en: 2e5329f8291bd365
|
||||
zh: fb8c72b71232847d
|
||||
/agent-note-keyless-browser-e2e-lane-for-the-web-gui/prior-art:
|
||||
en: 7472e212043721dd
|
||||
zh: 61dd9f5a8e12730b
|
||||
|
||||
@@ -50,7 +50,7 @@ The lane covers three behavior families. Live-turn scenarios pin ordinary tool e
|
||||
|
||||
### CI stance
|
||||
|
||||
The lane is a required compare-only gate for Linux pull requests under the [browser snapshot CI reference](../../../../docs/testing.md). The `node 24 / snapshots and artifacts` consumer job owns the [single Linux build](../../archived/process/2026-07-30-independent-ci-consumer-build.md), installs the lockfile-selected Chromium and WebKit, restores their OS-and-lockfile-keyed cache, and runs the lane with `DSH_SNAPSHOT=replay`. This is an intentional plane split: the host and specs use the [tsx source-launch contract](../architecture/2026-07-29-dsh-source-launch-tsx-esm.md), while the browser consumes `apps/web/dist` and package `lib/client.js` artifacts, so the gate depends on `build` for those client artifacts. The self-hosted default-branch Linux serial standby runs the same gate; there is no hosted Linux serial producer of the browser cache consumed by pull requests, and the persistent self-hosted pool needs no hosted cache. CI never records or refreshes goldens. Scenarios remain POSIX-oriented and stay outside the Windows and macOS matrices.
|
||||
The lane is a required compare-only gate for Linux pull requests under the [browser snapshot CI reference](../../../../docs/testing.md). The `node 24 / build` job owns the single Linux build and publishes its output; the two entries of the `node 24 / web snapshots <shard>/2` matrix job restore that output, install the lockfile-selected Chromium and WebKit from their OS-and-lockfile-keyed cache, and each run one weighted shard of the lane with `DSH_SNAPSHOT=replay`. The longest files run as round-robin test slices, one Vitest project per slice, so no single file bounds a shard ([slice plan](../../../../scripts/web-snapshot-projects.ts)). The recorded-session corpus in `node 24 / snapshots and artifacts` does not run the Web adapters under `apps/web/tests/`. This is an intentional plane split: the host and specs use the [tsx source-launch contract](../architecture/2026-07-29-dsh-source-launch-tsx-esm.md), while the browser consumes `apps/web/dist` and package `lib/client.js` artifacts, so the gate depends on `build` for those client artifacts. The self-hosted default-branch Linux serial standby runs the same gate; there is no hosted Linux serial producer of the browser cache consumed by pull requests, and the persistent self-hosted pool needs no hosted cache. CI never records or refreshes goldens. Scenarios remain POSIX-oriented and stay outside the Windows and macOS matrices.
|
||||
|
||||
High-cardinality performance diagnostics use the separate opt-in `apps/web/tests/**/*.perf.ts` inventory selected only by `vitest.web.perf.config.ts`. The isolated `complex-history.perf.ts` cases reuse the real scaffold: the workspace case seeds 1,000 compact sessions plus one 500-turn history containing 500 tool calls, exhausts and remounts that history in Chat, and reports Chromium main-thread, DOM, listener, heap, paging, search, and Trajectory measurements. Two continuation cases seed the same long history but compare the default 24-turn Chat window with all 500 turns expanded before each continues eight identical turns through the real composer, agent loop, SSE wire, tools, and persistence; two turns execute a real `bash` call and assert its durable result, while the final turn fills an 8,232-character mixed-language prompt and replays 120 paced text deltas. A separate soak case starts from a blank session, drives 100 consecutive real composer turns with a `bash` call and result every tenth turn, forces GC every ten turns, and reports ten-turn latency windows plus retained browser state. It then submits a 101st text-only turn with a trusted browser click and measures browser-clock send-to-transcript-DOM and send-to-post-paint latency, excluding the composer's draft mirrors, separately from full-turn completion. Per-turn diagnostics cover composer fill, click-to-user-echo, click-to-first-chunk, completion, browser mutations, persisted chunks, and tool events; the synthetic replay model has enough context capacity to keep fixture cardinality stable instead of consuming scripted calls through compaction. Structural assertions pin the intended load, stream, and tool shapes, but timing remains threshold-free because machine speed is not a correctness contract. The required `vitest.web.config.ts` inventory remains limited to `*.e2e.ts` and `*.snapshot.ts`, so neither `test:web:built` nor its CI gate collects performance cases.
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ Web GUI 以一条真实组装链交付——chromium 页面 → client 插件 bu
|
||||
|
||||
### CI 立场
|
||||
|
||||
根据[浏览器快照 CI 说明](../../../../docs/testing.zh.md),该车道是 Linux 拉取请求必需的只比较门禁。`node 24 / snapshots and artifacts` 消费方任务在[消费方独立构建](../../archived/process/2026-07-30-independent-ci-consumer-build.md)中负责唯一一次 Linux 构建,安装锁文件选定的 Chromium 和 WebKit,恢复以操作系统和锁文件为键的缓存,并用 `DSH_SNAPSHOT=replay` 运行该车道。这是有意的平面切分:host 与 spec 使用 [tsx 源码启动约定](../architecture/2026-07-29-dsh-source-launch-tsx-esm.zh.md),浏览器则消费 `apps/web/dist` 和包的 `lib/client.js` 产物,因此门禁依赖 `build` 提供这些客户端产物。自托管的默认分支 Linux 串行热备运行同一门禁;不存在托管 Linux 串行生产者生成供 PR 消费的浏览器缓存,持久化自托管池则不需要托管侧缓存。CI 从不录制或刷新预期输出。场景仍面向 POSIX,并继续置于 Windows 和 macOS 矩阵之外。
|
||||
根据[浏览器快照 CI 说明](../../../../docs/testing.zh.md),该车道是 Linux 拉取请求必需的只比较门禁。`node 24 / build` 任务负责唯一一次 Linux 构建并发布其产物;`node 24 / web snapshots <shard>/2` 矩阵任务的两个条目恢复该产物,从以操作系统和锁文件为键的缓存安装锁文件选定的 Chromium 和 WebKit,并各自用 `DSH_SNAPSHOT=replay` 运行该车道的一个加权分片。最长的几个文件按测试轮转拆成切片,每个切片是一个 Vitest 项目,因此单个文件不会决定一个分片的耗时([切片计划](../../../../scripts/web-snapshot-projects.ts))。`node 24 / snapshots and artifacts` 中的录制会话语料不运行 `apps/web/tests/` 下的 Web 适配器。这是有意的平面切分:host 与 spec 使用 [tsx 源码启动约定](../architecture/2026-07-29-dsh-source-launch-tsx-esm.zh.md),浏览器则消费 `apps/web/dist` 和包的 `lib/client.js` 产物,因此门禁依赖 `build` 提供这些客户端产物。自托管的默认分支 Linux 串行热备运行同一门禁;不存在托管 Linux 串行生产者生成供 PR 消费的浏览器缓存,持久化自托管池则不需要托管侧缓存。CI 从不录制或刷新预期输出。场景仍面向 POSIX,并继续置于 Windows 和 macOS 矩阵之外。
|
||||
|
||||
高基数性能诊断使用单独按需启用的 `apps/web/tests/**/*.perf.ts` 清单,并且只由 `vitest.web.perf.config.ts` 选中。`complex-history.perf.ts` 的隔离用例复用真实 scaffold:工作区用例播种 1,000 个紧凑会话以及一份包含 500 次工具调用的 500 轮次历史,在 Chat 中穷尽并重新挂载该历史,并报告 Chromium 主线程、DOM、监听器、堆内存、分页、搜索和 Trajectory 测量结果。两个续聊用例播种同一份长历史,但比较默认的 24 轮次 Chat 窗口与展开全部 500 轮次的状态,然后各自通过真实输入框、agent loop、SSE wire、工具和持久化继续进行 8 个相同轮次;其中两轮执行真实 `bash` 调用并断言其持久化结果,最后一轮则填入一条包含 8,232 个字符的混合语言提示词,并回放 120 个带节奏的文本增量。一个单独的 soak 用例从空白会话开始,通过真实输入框连续驱动 100 轮,每第 10 轮执行一次 `bash` 调用并产生结果,每 10 轮强制执行一次 GC,并报告每 10 轮的延迟窗口及保留的浏览器状态。随后它通过受信任的浏览器点击提交第 101 个纯文本轮次,并使用浏览器时钟分别测量发送到 transcript DOM 和发送到绘制后的延迟,排除输入框的草稿镜像,并与完整轮次完成时间分开。逐轮诊断涵盖输入框填入、点击到用户消息回显、点击到首个分片、完成、浏览器变更、持久化分片和工具事件;合成回放模型拥有足够的上下文容量,可使 fixture 基数保持稳定,而不会因压缩(compaction)消耗脚本化调用。结构性断言钉住预期的负载、流和工具形状,但时间仍不设阈值,因为机器速度不属于正确性约定。必需的 `vitest.web.config.ts` 清单仍仅限 `*.e2e.ts` 和 `*.snapshot.ts`,因此 `test:web:built` 及其 CI 门禁都不会收集性能用例。
|
||||
|
||||
|
||||
+316
-24
@@ -56,16 +56,16 @@ jobs:
|
||||
run: node --import tsx tests/isolated-install.mjs
|
||||
|
||||
|
||||
# Three enterprise jobs isolate coverage, static analysis, and the
|
||||
# build-backed consumer tail. The consumer job owns the only Linux build so
|
||||
# all three jobs enter runner allocation independently.
|
||||
# Enterprise jobs isolate coverage, static analysis, and the build-backed
|
||||
# tail. The build job owns the only Linux artifact build; the consumer job
|
||||
# and the two web snapshot shards restore its output instead of rebuilding.
|
||||
#
|
||||
# FAILOVER (Linux): each Linux enterprise job resolves its pool through the
|
||||
# DSH_CI_FAILOVER_LINUX repository variable. Unset (normal), the expressions
|
||||
# pick the hosted enterprise pools below. Setting the variable to
|
||||
# 'selfhosted' (repo Settings → Actions → Variables; writer-manageable
|
||||
# repository state — not PR-editable, no merge required) retargets all
|
||||
# three onto the in-house
|
||||
# repository state — not PR-editable, no merge required) retargets them
|
||||
# all onto the in-house
|
||||
# vm-backup pool and re-running the failed jobs is the entire switch —
|
||||
# see .agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md.
|
||||
# Setting the variable to 'blacksmith' instead routes the same jobs onto
|
||||
@@ -387,7 +387,120 @@ jobs:
|
||||
if-no-files-found: warn
|
||||
retention-days: 7
|
||||
|
||||
# Build the artifacts once, run the cheap readers, and publish the output
|
||||
# for the downstream consumer and web snapshot jobs, which restore it
|
||||
# instead of rebuilding.
|
||||
node-24-build:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: >-
|
||||
${{ vars.DSH_CI_FAILOVER_LINUX == 'blacksmith' && 'blacksmith-16vcpu-ubuntu-2404'
|
||||
|| vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
|
||||
&& github.event.pull_request.user.login != 'dependabot[bot]'
|
||||
&& fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
|
||||
|| 'dsh-ubuntu-24-04-16core' }}
|
||||
name: node 24 / build
|
||||
env:
|
||||
# Shared hosts expose host CPUs, not an isolated allocation.
|
||||
DSH_GATE_CONCURRENCY: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '10' || '' }}
|
||||
DSH_OXLINT_THREADS: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '8' || '' }}
|
||||
DSH_PUBLINT_CONCURRENCY: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '8' || '' }}
|
||||
DSH_SNAPSHOT_MAX_CONCURRENCY: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '12' || '' }}
|
||||
DSH_NODE_COMPAT_SKIP_TYPECHECK: '1'
|
||||
# A failing gate aborts its running siblings.
|
||||
DSH_GATE_FAIL_FAST: '1'
|
||||
steps:
|
||||
# Runner cleanup owns tool caches and fixtures, including cancelled runs.
|
||||
- name: Use runner-owned temporary storage
|
||||
run: |
|
||||
echo "TMPDIR=${{ runner.temp }}" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# Redirect the Node compile cache (enabled by pnpm and TypeScript) off
|
||||
# the root partition's /tmp before the first pnpm call in this lane.
|
||||
- name: Redirect Node compile cache to runner temp
|
||||
run: echo "NODE_COMPILE_CACHE=${{ runner.temp }}/node-compile-cache" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: pnpm/action-setup@v5.0.0
|
||||
with:
|
||||
dest: ${{ runner.temp }}/setup-pnpm-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
|
||||
- uses: actions/setup-node@v7.0.0
|
||||
with:
|
||||
node-version: ${{ env.PRIMARY_NODE_VERSION }}
|
||||
|
||||
- name: Configure pnpm store path
|
||||
id: pnpm-store
|
||||
run: |
|
||||
store_root="$HOME/.local/share/pnpm/store"
|
||||
echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
|
||||
store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
|
||||
echo "path=$store_path" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Pull requests restore the pnpm store without paying compression and
|
||||
# upload on the required path. Self-hosted runners reuse the shared
|
||||
# persistent store instead of restoring the remote archive.
|
||||
- uses: actions/cache/restore@v6.1.0
|
||||
if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
with:
|
||||
path: ${{ steps.pnpm-store.outputs.path }}
|
||||
key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
# Everything the build adds to the ignored or untracked set is its output.
|
||||
- name: Record files before the build
|
||||
run: git status --porcelain=v1 --ignored --untracked-files=normal > "$RUNNER_TEMP/files-before.txt"
|
||||
|
||||
- name: Build artifacts and run the cheap readers
|
||||
run: pnpm run check:ci:build
|
||||
|
||||
- name: Pack build output
|
||||
env:
|
||||
# Compression costs well under a second at -T0; a smaller archive
|
||||
# shortens the upload and every download.
|
||||
ZSTD_LEVEL: '9'
|
||||
run: |
|
||||
set -o pipefail
|
||||
out="$RUNNER_TEMP/build-output"
|
||||
mkdir -p "$out"
|
||||
git status --porcelain=v1 --ignored --untracked-files=normal > "$RUNNER_TEMP/files-after.txt"
|
||||
comm -13 <(sort "$RUNNER_TEMP/files-before.txt") <(sort "$RUNNER_TEMP/files-after.txt") \
|
||||
| sed -n -E 's/^(!!|\?\?) //p' \
|
||||
| grep -v -E '(^|/)(node_modules|\.node-next-types-[^/]*|\.doc-typecheck-[^/]*|\.oxlint-contract-[^/]*|\.typert-[^/]*|\.cache)/?$' \
|
||||
| sed 's#/$##' > "$out/paths.txt"
|
||||
echo "build output entries: $(wc -l < "$out/paths.txt")"
|
||||
du -sch $(cat "$out/paths.txt") | tail -1
|
||||
tar -cf - -T "$out/paths.txt" | zstd -q -T0 -"$ZSTD_LEVEL" -o "$out/build-output.tar.zst"
|
||||
zstd -dc "$out/build-output.tar.zst" | tar -tf - > "$out/contents.txt"
|
||||
for required in apps/cli/lib/bin.js apps/web/dist/index.html .dsh-build/client-build-environment.json; do
|
||||
grep -qx "$required" "$out/contents.txt" || { echo "::error::build output is missing $required"; exit 1; }
|
||||
done
|
||||
echo "archive entries: $(wc -l < "$out/contents.txt")"
|
||||
rm "$out/contents.txt"
|
||||
|
||||
- name: Upload build output
|
||||
uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: build-output
|
||||
path: |
|
||||
${{ runner.temp }}/build-output/build-output.tar.zst
|
||||
${{ runner.temp }}/build-output/paths.txt
|
||||
# Re-running a failed downstream job does not rebuild; keep the output
|
||||
# for GitHub's 30-day re-run window.
|
||||
retention-days: 30
|
||||
compression-level: 0
|
||||
if-no-files-found: error
|
||||
# A re-run of this job replaces the previous attempt's output.
|
||||
overwrite: true
|
||||
|
||||
node-24-consumers:
|
||||
needs: node-24-build
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: >-
|
||||
${{ vars.DSH_CI_FAILOVER_LINUX == 'blacksmith' && 'blacksmith-16vcpu-ubuntu-2404'
|
||||
@@ -404,13 +517,150 @@ jobs:
|
||||
DSH_WEB_SNAPSHOT_WORKERS: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '6' || '' }}
|
||||
DSH_SNAPSHOT_MAX_CONCURRENCY: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '12' || '' }}
|
||||
DSH_NODE_COMPAT_SKIP_TYPECHECK: '1'
|
||||
# Browsers install beside the build; only the browser readers wait for them.
|
||||
# The persistent VM image owns Playwright's Linux system packages, so the
|
||||
# failover pool skips apt instead of mutating the shared host each run.
|
||||
DSH_CI_PLAYWRIGHT_INSTALL: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && 'browsers' || 'with-deps' }}
|
||||
# A failing gate aborts its running siblings: a failing build stops the
|
||||
# independent Node compatibility smoke, and a failing reader (e.g.
|
||||
# publint) stops the remaining artifact consumers.
|
||||
# A failing gate aborts its running siblings.
|
||||
DSH_GATE_FAIL_FAST: '1'
|
||||
steps:
|
||||
# Runner cleanup owns tool caches and fixtures, including cancelled runs.
|
||||
- name: Use runner-owned temporary storage
|
||||
run: |
|
||||
echo "TMPDIR=${{ runner.temp }}" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# Redirect the Node compile cache (enabled by pnpm and TypeScript) off
|
||||
# the root partition's /tmp before the first pnpm call in this lane.
|
||||
- name: Redirect Node compile cache to runner temp
|
||||
run: echo "NODE_COMPILE_CACHE=${{ runner.temp }}/node-compile-cache" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: pnpm/action-setup@v5.0.0
|
||||
with:
|
||||
dest: ${{ runner.temp }}/setup-pnpm-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
|
||||
- uses: actions/setup-node@v7.0.0
|
||||
with:
|
||||
node-version: ${{ env.PRIMARY_NODE_VERSION }}
|
||||
|
||||
- name: Configure pnpm store path
|
||||
id: pnpm-store
|
||||
run: |
|
||||
store_root="$HOME/.local/share/pnpm/store"
|
||||
echo "PNPM_CONFIG_STORE_DIR=$store_root" >> "$GITHUB_ENV"
|
||||
store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
|
||||
echo "path=$store_path" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Pull requests restore the pnpm store without paying compression and
|
||||
# upload on the required path. Self-hosted runners reuse the shared
|
||||
# persistent store instead of restoring the remote archive.
|
||||
- uses: actions/cache/restore@v6.1.0
|
||||
if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
with:
|
||||
path: ${{ steps.pnpm-store.outputs.path }}
|
||||
key: ${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-${{ env.PRIMARY_NODE_VERSION }}-pnpm-
|
||||
|
||||
# The persistent self-hosted pool keeps ~/.cache between jobs on its own
|
||||
# layout, so the archive cache follows the hosted-only pnpm store guard.
|
||||
- name: Restore verified bubblewrap archive
|
||||
id: bubblewrap-cache
|
||||
if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
uses: actions/cache/restore@v6.1.0
|
||||
with:
|
||||
path: ~/.cache/dsh-ci/bubblewrap
|
||||
key: bubblewrap-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/prepare-ci-bubblewrap.sh') }}
|
||||
|
||||
- name: Install dependencies and prepare bubblewrap
|
||||
run: |
|
||||
pnpm install --frozen-lockfile &
|
||||
install_pid=$!
|
||||
bash scripts/prepare-ci-bubblewrap.sh &
|
||||
sandbox_pid=$!
|
||||
install_status=0
|
||||
wait "$install_pid" || install_status=$?
|
||||
sandbox_status=0
|
||||
wait "$sandbox_pid" || sandbox_status=$?
|
||||
if (( install_status != 0 )); then exit "$install_status"; fi
|
||||
exit "$sandbox_status"
|
||||
|
||||
- name: Save verified bubblewrap archive
|
||||
if: (vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]') && steps.bubblewrap-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v6.1.0
|
||||
with:
|
||||
path: ~/.cache/dsh-ci/bubblewrap
|
||||
key: bubblewrap-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/prepare-ci-bubblewrap.sh') }}
|
||||
|
||||
# Restore the build job's output after the install, so no install or
|
||||
# postinstall step can replace restored files. The fixed artifact name
|
||||
# resolves within this run, including a re-run of this job alone.
|
||||
- name: Download build output
|
||||
uses: actions/download-artifact@v8.0.1
|
||||
with:
|
||||
name: build-output
|
||||
path: ${{ runner.temp }}/build-output
|
||||
|
||||
- name: Unpack build output
|
||||
run: |
|
||||
set -o pipefail
|
||||
archive="$RUNNER_TEMP/build-output/build-output.tar.zst"
|
||||
# -m stamps restored files with the extraction time: newer than this
|
||||
# checkout and never in the future. Build-time mtimes ahead of the
|
||||
# clock make HMR treat freshly loaded lib/ modules as changed.
|
||||
zstd -dc -T0 "$archive" | tar -xmf -
|
||||
test -f apps/cli/lib/bin.js && test -f apps/web/dist/index.html && test -f .dsh-build/client-build-environment.json
|
||||
|
||||
# No gate reads the Office runtime output, so it builds beside the gates.
|
||||
# GitHub runners keep a background process started in one step alive for
|
||||
# the later steps of the same job; the final step collects its status.
|
||||
- name: Start the Linux Office runtime build
|
||||
id: office-runtime
|
||||
run: |
|
||||
(
|
||||
status=0
|
||||
CI=true pnpm run prepare:primary-runtime --target linux-x64 --output "$RUNNER_TEMP/office-runtime" --cache "$RUNNER_TEMP/office-runtime-downloads" || status=$?
|
||||
echo "$status" > "$RUNNER_TEMP/office-runtime.status"
|
||||
) > "$RUNNER_TEMP/office-runtime.log" 2>&1 &
|
||||
echo "$!" > "$RUNNER_TEMP/office-runtime.pid"
|
||||
|
||||
- name: Run compatibility, snapshot, and artifact gates
|
||||
run: pnpm run check:ci:consumers-prebuilt
|
||||
|
||||
- name: Wait for the Linux Office runtime
|
||||
if: ${{ !cancelled() && steps.office-runtime.outcome == 'success' }}
|
||||
run: |
|
||||
pid=$(cat "$RUNNER_TEMP/office-runtime.pid")
|
||||
while kill -0 "$pid" 2>/dev/null; do sleep 1; done
|
||||
cat "$RUNNER_TEMP/office-runtime.log"
|
||||
status=$(cat "$RUNNER_TEMP/office-runtime.status" 2>/dev/null || echo missing)
|
||||
if [[ "$status" != 0 ]]; then
|
||||
echo "::error::Linux Office runtime build failed with status $status"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
node-24-web-snapshot:
|
||||
needs: node-24-build
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: >-
|
||||
${{ vars.DSH_CI_FAILOVER_LINUX == 'blacksmith' && 'blacksmith-16vcpu-ubuntu-2404'
|
||||
|| vars.DSH_CI_FAILOVER_LINUX == 'selfhosted'
|
||||
&& github.event.pull_request.user.login != 'dependabot[bot]'
|
||||
&& fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
|
||||
|| 'dsh-ubuntu-24-04-16core' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2]
|
||||
name: node 24 / web snapshots ${{ matrix.shard }}/2
|
||||
env:
|
||||
# Shared hosts expose host CPUs, not an isolated allocation.
|
||||
DSH_GATE_CONCURRENCY: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '10' || '' }}
|
||||
DSH_WEB_SNAPSHOT_WORKERS: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && '6' || '' }}
|
||||
DSH_WEB_SNAPSHOT_SHARD: ${{ matrix.shard }}/2
|
||||
# Every shard reads these shares. Each shard runs alone on its
|
||||
# machine; the last shard also runs the ~40s of serial files first.
|
||||
DSH_WEB_SNAPSHOT_SHARD_SHARES: '0.54,0.46'
|
||||
# A failing gate aborts its running siblings.
|
||||
DSH_GATE_FAIL_FAST: '1'
|
||||
steps:
|
||||
# Runner cleanup owns tool caches and fixtures, including cancelled runs.
|
||||
@@ -444,11 +694,9 @@ jobs:
|
||||
store_path=$(PNPM_CONFIG_STORE_DIR="$store_root" pnpm store path --silent)
|
||||
echo "path=$store_path" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Pull requests restore the pnpm store and Playwright caches without paying
|
||||
# compression and upload on the required path. No master job saves these
|
||||
# hosted cache keys, so each restore-keys fallback hits the matching archived
|
||||
# entry until it evicts, after which the store is cold. Self-hosted runners
|
||||
# reuse the shared persistent store instead of restoring the remote archive.
|
||||
# Pull requests restore the pnpm store without paying compression and
|
||||
# upload on the required path. Self-hosted runners reuse the shared
|
||||
# persistent store instead of restoring the remote archive.
|
||||
- uses: actions/cache/restore@v6.1.0
|
||||
if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
with:
|
||||
@@ -497,8 +745,8 @@ jobs:
|
||||
key: bubblewrap-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/prepare-ci-bubblewrap.sh') }}
|
||||
|
||||
# Ubuntu HTTP archive mirrors can stall for tens of seconds per package
|
||||
# (Blacksmith lists http://azure.archive.ubuntu.com first), so ephemeral
|
||||
# runners fetch the archive over HTTPS before the Playwright gate's apt.
|
||||
# (Blacksmith lists http://azure.archive.ubuntu.com first), so every
|
||||
# ephemeral runner fetches the archive over HTTPS before Playwright's apt.
|
||||
- name: Use HTTPS for Ubuntu archives
|
||||
if: vars.DSH_CI_FAILOVER_LINUX != 'selfhosted' || github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
run: |
|
||||
@@ -517,12 +765,56 @@ jobs:
|
||||
r'https://\1.ubuntu.com/', source.read_text()))
|
||||
PY
|
||||
|
||||
- name: Build and execute the Linux Office runtime
|
||||
run: CI=true pnpm run prepare:primary-runtime --target linux-x64 --output "$RUNNER_TEMP/office-runtime" --cache "$RUNNER_TEMP/office-runtime-downloads"
|
||||
# The browser install overlaps the artifact download and unpack. GitHub
|
||||
# runners keep a background process started in one step alive for the
|
||||
# later steps of the same job, and the wait step below collects its exit
|
||||
# status. The persistent VM image owns Playwright's Linux system packages,
|
||||
# so the failover pool skips apt instead of mutating the shared host.
|
||||
- name: Start Playwright browser install
|
||||
env:
|
||||
PLAYWRIGHT_INSTALL_MODE: ${{ vars.DSH_CI_FAILOVER_LINUX == 'selfhosted' && github.event.pull_request.user.login != 'dependabot[bot]' && 'browsers' || 'with-deps' }}
|
||||
run: |
|
||||
deps=()
|
||||
if [[ "$PLAYWRIGHT_INSTALL_MODE" == with-deps ]]; then deps=(--with-deps); fi
|
||||
(
|
||||
status=0
|
||||
pnpm --filter @deepseek-ai/dsh-web-frontend exec playwright install "${deps[@]}" chromium webkit || status=$?
|
||||
echo "$status" > "$RUNNER_TEMP/playwright-install.status"
|
||||
) > "$RUNNER_TEMP/playwright-install.log" 2>&1 &
|
||||
echo "$!" > "$RUNNER_TEMP/playwright-install.pid"
|
||||
|
||||
- name: Run compatibility, snapshot, and artifact gates
|
||||
run: pnpm run check:ci:consumers
|
||||
# Restore the build job's output after the install, so no install or
|
||||
# postinstall step can replace restored files. The fixed artifact name
|
||||
# resolves within this run, including a re-run of this job alone.
|
||||
- name: Download build output
|
||||
uses: actions/download-artifact@v8.0.1
|
||||
with:
|
||||
name: build-output
|
||||
path: ${{ runner.temp }}/build-output
|
||||
|
||||
- name: Unpack build output
|
||||
run: |
|
||||
set -o pipefail
|
||||
archive="$RUNNER_TEMP/build-output/build-output.tar.zst"
|
||||
# -m stamps restored files with the extraction time: newer than this
|
||||
# checkout and never in the future. Build-time mtimes ahead of the
|
||||
# clock make HMR treat freshly loaded lib/ modules as changed.
|
||||
zstd -dc -T0 "$archive" | tar -xmf -
|
||||
test -f apps/cli/lib/bin.js && test -f apps/web/dist/index.html && test -f .dsh-build/client-build-environment.json
|
||||
|
||||
- name: Wait for Playwright browsers
|
||||
run: |
|
||||
pid=$(cat "$RUNNER_TEMP/playwright-install.pid")
|
||||
while kill -0 "$pid" 2>/dev/null; do sleep 1; done
|
||||
cat "$RUNNER_TEMP/playwright-install.log"
|
||||
status=$(cat "$RUNNER_TEMP/playwright-install.status" 2>/dev/null || echo missing)
|
||||
if [[ "$status" != 0 ]]; then
|
||||
echo "::error::Playwright browser install failed with status $status"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run web browser snapshot shard
|
||||
run: pnpm run check:ci:web-snapshot-prebuilt
|
||||
|
||||
node-compat:
|
||||
needs: publisher-isolated
|
||||
@@ -656,7 +948,7 @@ jobs:
|
||||
&& github.event.pull_request.user.login != 'dependabot[bot]'
|
||||
&& fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
|
||||
|| 'ubuntu-latest' }}
|
||||
needs: [publisher-isolated, node-24, node-24-coverage, node-24-lint, node-24-bench, node-24-consumers, node-compat]
|
||||
needs: [publisher-isolated, node-24, node-24-coverage, node-24-lint, node-24-bench, node-24-build, node-24-consumers, node-24-web-snapshot, node-compat]
|
||||
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
|
||||
steps:
|
||||
- name: Fail if any needed job did not succeed
|
||||
|
||||
@@ -97,6 +97,9 @@
|
||||
"check:ci:snapshot": "tsx scripts/run-gates.ts ci-snapshot",
|
||||
"check:ci:artifacts": "tsx scripts/run-gates.ts ci-artifacts",
|
||||
"check:ci:consumers": "tsx scripts/run-gates.ts ci-consumers",
|
||||
"check:ci:build": "tsx scripts/run-gates.ts ci-build",
|
||||
"check:ci:consumers-prebuilt": "tsx scripts/run-gates.ts ci-consumers-prebuilt",
|
||||
"check:ci:web-snapshot-prebuilt": "tsx scripts/run-gates.ts ci-web-snapshot-prebuilt",
|
||||
"check:windows-wine": "bash scripts/wine-windows-gates.sh",
|
||||
"check:ci:windows-blocking": "tsx scripts/run-gates.ts ci-windows-blocking",
|
||||
"check:ci:windows-complete": "tsx scripts/run-gates.ts ci-windows-complete",
|
||||
|
||||
+60
-10
@@ -15,7 +15,7 @@ const runnerPrivatePnpmDestination = /^\$\{\{ runner\.temp \}\}\/setup-pnpm-\$\{
|
||||
const nativeWindowsPnpmDestination = '${{ runner.temp }}/setup-pnpm-js-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}'
|
||||
|
||||
describe('CI workflow', () => {
|
||||
it('keeps at most eleven worker jobs active across PR workflows while Python runtime targets follow the SDK suite', () => {
|
||||
it('keeps at most fourteen worker jobs active across PR workflows while Python runtime targets follow the SDK suite', () => {
|
||||
const ci = loadWorkflow('.github/workflows/ci.yml')
|
||||
const ciWindows = loadWorkflow('.github/workflows/ci-windows.yml')
|
||||
const ciPython = loadWorkflow('.github/workflows/ci-python.yml')
|
||||
@@ -40,8 +40,13 @@ describe('CI workflow', () => {
|
||||
matrix: { include: [{ node: '24.9' }, { node: 26 }] },
|
||||
})
|
||||
expect(workflowJob(ci, 'all-checks-passed').needs).toContain('node-compat')
|
||||
// The web snapshot shards are the only other matrix: one job, one runner per shard.
|
||||
const webSnapshot = workflowJob(ci, 'node-24-web-snapshot')
|
||||
expect(webSnapshot.strategy).toEqual({ 'fail-fast': false, matrix: { shard: [1, 2] } })
|
||||
const webSnapshotShards = isRecord(webSnapshot.strategy) && isRecord(webSnapshot.strategy.matrix)
|
||||
&& Array.isArray(webSnapshot.strategy.matrix.shard) ? webSnapshot.strategy.matrix.shard.length : 0
|
||||
const ordinaryJobs = Object.entries(ci.jobs)
|
||||
.filter(([name]) => !['node-compat', 'all-checks-passed', 'publisher-isolated'].includes(name))
|
||||
.filter(([name]) => !['node-compat', 'all-checks-passed', 'publisher-isolated', 'node-24-web-snapshot'].includes(name))
|
||||
for (const [name, job] of ordinaryJobs) {
|
||||
if (!isRecord(job)) throw new TypeError(`${name} must define a job`)
|
||||
expect(job).not.toHaveProperty('strategy')
|
||||
@@ -94,10 +99,13 @@ describe('CI workflow', () => {
|
||||
const windowsActive = windowsJobs.length
|
||||
// The lint lane owns its own runner, so it raises the ceiling by one; the
|
||||
// self-hosted failover pool is still admitted only up to its own limit.
|
||||
const beforeSdk = ordinaryJobs.length + compatibilityLimit + windowsActive + 1
|
||||
const afterSdk = ordinaryJobs.length + compatibilityLimit + windowsActive + Math.max(1, targets.split(',').length)
|
||||
expect(beforeSdk).toBeLessThanOrEqual(11)
|
||||
expect(afterSdk).toBeLessThanOrEqual(11)
|
||||
// The build job finishes before its downstream jobs start, so the
|
||||
// static count overstates the peak by one.
|
||||
const linuxActive = ordinaryJobs.length + webSnapshotShards
|
||||
const beforeSdk = linuxActive + compatibilityLimit + windowsActive + 1
|
||||
const afterSdk = linuxActive + compatibilityLimit + windowsActive + Math.max(1, targets.split(',').length)
|
||||
expect(beforeSdk).toBeLessThanOrEqual(14)
|
||||
expect(afterSdk).toBeLessThanOrEqual(14)
|
||||
})
|
||||
|
||||
it('keeps required PR verdicts covering runtime and publisher jobs', () => {
|
||||
@@ -121,9 +129,11 @@ describe('CI workflow', () => {
|
||||
expect(blocking.sort()).toEqual([
|
||||
'node-24',
|
||||
'node-24-bench',
|
||||
'node-24-build',
|
||||
'node-24-consumers',
|
||||
'node-24-coverage',
|
||||
'node-24-lint',
|
||||
'node-24-web-snapshot',
|
||||
'node-compat',
|
||||
'publisher-isolated',
|
||||
'python-runtime',
|
||||
@@ -136,7 +146,9 @@ describe('CI workflow', () => {
|
||||
|
||||
it('retains aggregate diagnostics in required builds and protected publication', () => {
|
||||
for (const [file, name, command] of [
|
||||
['ci.yml', 'node-24-consumers', 'pnpm run check:ci:consumers'],
|
||||
['ci.yml', 'node-24-build', 'pnpm run check:ci:build'],
|
||||
['ci.yml', 'node-24-consumers', 'pnpm run check:ci:consumers-prebuilt'],
|
||||
['ci.yml', 'node-24-web-snapshot', 'pnpm run check:ci:web-snapshot-prebuilt'],
|
||||
['ci-windows.yml', 'windows-build', 'pnpm run check:ci:windows-blocking'],
|
||||
] as const) {
|
||||
const job = workflowJob(loadWorkflow('.github/workflows/' + file), name)
|
||||
@@ -158,6 +170,41 @@ describe('CI workflow', () => {
|
||||
expect(scripts.scripts.typecheck).toBe('tsx scripts/build.ts --scope typecheck')
|
||||
})
|
||||
|
||||
it('node-24-web-snapshot installs browsers over HTTPS archives while the build output downloads', () => {
|
||||
const jobName = 'node-24-web-snapshot'
|
||||
const job = workflowJob(loadWorkflow('.github/workflows/ci.yml'), jobName)
|
||||
if (!Array.isArray(job.steps)) throw new TypeError(`${jobName} must define steps`)
|
||||
const names = job.steps.map(step => isRecord(step) ? step.name : undefined)
|
||||
const order = ['Install dependencies and prepare bubblewrap', 'Use HTTPS for Ubuntu archives',
|
||||
'Start Playwright browser install', 'Download build output', 'Unpack build output',
|
||||
'Wait for Playwright browsers', 'Run web browser snapshot shard'].map(name => names.indexOf(name))
|
||||
expect(order).not.toContain(-1)
|
||||
expect([...order].sort((a, b) => a - b)).toEqual(order)
|
||||
expect(isRecord(job.env) && 'DSH_CI_PLAYWRIGHT_INSTALL' in job.env).toBe(false)
|
||||
const start: unknown = job.steps.find(step => isRecord(step) && step.name === 'Start Playwright browser install')
|
||||
if (!isRecord(start) || !isRecord(start.env)) throw new TypeError('the Playwright install step must define env')
|
||||
expect(String(start.env.PLAYWRIGHT_INSTALL_MODE)).toContain("&& 'browsers' || 'with-deps'")
|
||||
expect(String(start.run)).toContain('exec playwright install "${deps[@]}" chromium webkit')
|
||||
})
|
||||
|
||||
it('writes the web snapshot shard shares once for every shard', () => {
|
||||
const job = workflowJob(loadWorkflow('.github/workflows/ci.yml'), 'node-24-web-snapshot')
|
||||
expect(job.name).toBe('node 24 / web snapshots ${{ matrix.shard }}/2')
|
||||
expect(job.env).toMatchObject({ DSH_WEB_SNAPSHOT_SHARD: '${{ matrix.shard }}/2', DSH_WEB_SNAPSHOT_SHARD_SHARES: '0.54,0.46' })
|
||||
})
|
||||
|
||||
it('builds the Linux Office runtime beside the consumer gates and fails on its status', () => {
|
||||
const job = workflowJob(loadWorkflow('.github/workflows/ci.yml'), 'node-24-consumers')
|
||||
if (!Array.isArray(job.steps)) throw new TypeError('node-24-consumers must define steps')
|
||||
const names = job.steps.map(step => isRecord(step) ? step.name : undefined)
|
||||
expect(names.slice(-3)).toEqual(['Start the Linux Office runtime build', 'Run compatibility, snapshot, and artifact gates', 'Wait for the Linux Office runtime'])
|
||||
expect(job.steps.at(-1)).toMatchObject({ if: "${{ !cancelled() && steps.office-runtime.outcome == 'success' }}" })
|
||||
const start: unknown = job.steps.at(-3)
|
||||
if (!isRecord(start)) throw new TypeError('the Office runtime step must be a mapping')
|
||||
expect(start.id).toBe('office-runtime')
|
||||
expect(String(start.run)).toContain('pnpm run prepare:primary-runtime --target linux-x64')
|
||||
})
|
||||
|
||||
it('selects artifact builds only for PR release and API rehearsals', () => {
|
||||
const official = "${{ github.event_name == 'pull_request' && 'pnpm run build:artifacts --profile official' || 'pnpm run build:official' }}"
|
||||
const vendor = "${{ github.event_name == 'pull_request' && 'pnpm exec tsx scripts/compile-referenced-projects.ts host-libraries' || 'pnpm run build:lib:host' }}"
|
||||
@@ -310,7 +357,7 @@ describe('CI workflow', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it.each(['node-24', 'node-24-coverage', 'node-24-consumers'])(
|
||||
it.each(['node-24', 'node-24-coverage', 'node-24-build', 'node-24-consumers', 'node-24-web-snapshot'])(
|
||||
'%s keeps tool and fixture temporary files under runner cleanup',
|
||||
(jobName) => {
|
||||
const job = workflowJob(loadWorkflow('.github/workflows/ci.yml'), jobName)
|
||||
@@ -319,13 +366,13 @@ describe('CI workflow', () => {
|
||||
name: 'Use runner-owned temporary storage',
|
||||
run: [
|
||||
'echo "TMPDIR=${{ runner.temp }}" >> "$GITHUB_ENV"',
|
||||
...(jobName === 'node-24-consumers'
|
||||
...(jobName === 'node-24-web-snapshot'
|
||||
? ['echo "PLAYWRIGHT_BROWSERS_PATH=${RUNNER_TEMP%/*}/ms-playwright" >> "$GITHUB_ENV"']
|
||||
: []),
|
||||
'',
|
||||
].join('\n'),
|
||||
})
|
||||
if (jobName === 'node-24-consumers') {
|
||||
if (jobName === 'node-24-web-snapshot') {
|
||||
const browserCache: unknown = job.steps.find(step => isRecord(step) && isRecord(step.with)
|
||||
&& step.with.path === '${{ env.PLAYWRIGHT_BROWSERS_PATH }}')
|
||||
expect(browserCache).toMatchObject({ uses: 'actions/cache/restore@v6.1.0' })
|
||||
@@ -889,7 +936,9 @@ describe('CI workflow', () => {
|
||||
const redirectLanes = [
|
||||
[prWorkflow, 'node-24'],
|
||||
[prWorkflow, 'node-24-coverage'],
|
||||
[prWorkflow, 'node-24-build'],
|
||||
[prWorkflow, 'node-24-consumers'],
|
||||
[prWorkflow, 'node-24-web-snapshot'],
|
||||
[masterWorkflow, 'serial-linux-selfhosted'],
|
||||
] as const
|
||||
for (const [workflow, jobKey] of redirectLanes) {
|
||||
@@ -1136,6 +1185,7 @@ describe('bubblewrap preparation script', () => {
|
||||
const cachedJobs = new Map<string, string | undefined>([
|
||||
['ci.yml:node-24-coverage', hostedOnly],
|
||||
['ci.yml:node-24-consumers', hostedOnly],
|
||||
['ci.yml:node-24-web-snapshot', hostedOnly],
|
||||
['ci.yml:node-compat', hostedOnly],
|
||||
['e2e.yml:e2e', undefined],
|
||||
])
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
taskkillArgs,
|
||||
type Gate,
|
||||
type GateResult,
|
||||
type Mode,
|
||||
} from './run-gates.ts'
|
||||
|
||||
// Graph fixtures select their own browser pool instead of inheriting the CI
|
||||
@@ -254,6 +255,9 @@ describe('gate graph validation', () => {
|
||||
'ci-snapshot',
|
||||
'ci-artifacts',
|
||||
'ci-consumers',
|
||||
'ci-build',
|
||||
'ci-consumers-prebuilt',
|
||||
'ci-web-snapshot-prebuilt',
|
||||
'ci-windows-blocking',
|
||||
'ci-windows-complete',
|
||||
'ci-windows-observational-ready',
|
||||
@@ -886,6 +890,55 @@ describe('Typert contract preparation', () => {
|
||||
expect(needsOf('expected-output')).toEqual(['build'])
|
||||
})
|
||||
|
||||
it('starts web snapshots after the build-artifact readers', () => {
|
||||
vi.stubEnv('DSH_WEB_SNAPSHOT_WORKERS', '16')
|
||||
const subject = withPnpmEntrypoint(() => gatesForMode('ci-consumers')).find(item => item.id === 'web-snapshot')
|
||||
|
||||
expect(subject?.after).toEqual(['publint', 'snapshot', 'expected-output', 'doc-typecheck', 'node-next-types', 'built-bin-smoke'])
|
||||
})
|
||||
|
||||
it('builds once and runs only the cheap readers in the build lane', () => {
|
||||
vi.stubEnv('DSH_CI_PLAYWRIGHT_INSTALL', 'with-deps')
|
||||
const subject = withPnpmEntrypoint(() => gatesForMode('ci-build'))
|
||||
|
||||
expect(subject.map(item => [item.id, item.needs ?? []])).toEqual([
|
||||
['build', []],
|
||||
['publint', ['build']],
|
||||
['node-next-types', ['build']],
|
||||
])
|
||||
expect(subject[0]).toMatchObject({ displayCommand: 'pnpm run build:artifacts', env: { DSH_BUILD_CLIENT_PROFILE: 'official' } })
|
||||
})
|
||||
|
||||
it('runs restored-artifact consumers without a build or browsers', () => {
|
||||
vi.stubEnv('DSH_CI_PLAYWRIGHT_INSTALL', 'with-deps')
|
||||
const subject = withPnpmEntrypoint(() => gatesForMode('ci-consumers-prebuilt'))
|
||||
|
||||
expect(subject.map(item => [item.id, item.needs ?? [], item.after ?? []])).toEqual([
|
||||
['node-compat', [], []],
|
||||
['snapshot', [], []],
|
||||
['expected-output', [], []],
|
||||
['doc-typecheck', [], []],
|
||||
['built-bin-smoke', [], []],
|
||||
])
|
||||
expect(subject.find(item => item.id === 'doc-typecheck')?.env).toMatchObject({ DSH_DOC_TYPECHECK_USE_BUILD_OUTPUT: '1' })
|
||||
})
|
||||
|
||||
it('leaves the web snapshot adapters to the web shards only in the restored-artifact consumers', () => {
|
||||
const snapshotEnv = (mode: Mode) => withPnpmEntrypoint(() => gatesForMode(mode)).find(item => item.id === 'snapshot')?.env
|
||||
|
||||
expect(snapshotEnv('ci-consumers-prebuilt')).toEqual({ DSH_EXAMPLE_MODE: 'lib', DSH_SNAPSHOT_SKIP_WEB_ADAPTERS: '1' })
|
||||
for (const mode of ['ci-primary', 'check-all', 'ci-snapshot', 'ci-linux-primary', 'ci-consumers'] as const) {
|
||||
expect(snapshotEnv(mode), mode).toEqual({ DSH_EXAMPLE_MODE: 'lib' })
|
||||
}
|
||||
})
|
||||
|
||||
it('runs one restored-artifact web snapshot shard without installing browsers', () => {
|
||||
vi.stubEnv('DSH_CI_PLAYWRIGHT_INSTALL', 'with-deps')
|
||||
const subject = withPnpmEntrypoint(() => gatesForMode('ci-web-snapshot-prebuilt'))
|
||||
|
||||
expect(subject.map(item => [item.id, item.needs ?? [], item.after ?? []])).toEqual([['web-snapshot', [], []]])
|
||||
})
|
||||
|
||||
it('rejects an unknown Playwright install mode', () => {
|
||||
vi.stubEnv('DSH_CI_PLAYWRIGHT_INSTALL', 'deps')
|
||||
|
||||
|
||||
+65
-6
@@ -27,6 +27,9 @@ export type Mode =
|
||||
| 'ci-snapshot'
|
||||
| 'ci-artifacts'
|
||||
| 'ci-consumers'
|
||||
| 'ci-build'
|
||||
| 'ci-consumers-prebuilt'
|
||||
| 'ci-web-snapshot-prebuilt'
|
||||
| 'ci-windows-blocking'
|
||||
| 'ci-windows-complete'
|
||||
| 'ci-windows-observational-ready'
|
||||
@@ -167,6 +170,9 @@ function parseMode(raw: string | undefined): Mode {
|
||||
case 'ci-snapshot':
|
||||
case 'ci-artifacts':
|
||||
case 'ci-consumers':
|
||||
case 'ci-build':
|
||||
case 'ci-consumers-prebuilt':
|
||||
case 'ci-web-snapshot-prebuilt':
|
||||
case 'ci-windows-blocking':
|
||||
case 'ci-windows-complete':
|
||||
case 'ci-windows-observational-ready':
|
||||
@@ -179,7 +185,7 @@ function parseMode(raw: string | undefined): Mode {
|
||||
return raw
|
||||
default:
|
||||
throw new Error(
|
||||
`run-gates: expected mode ci-primary | ci-linux-primary | ci-static | ci-lint-contracts-ready | ci-coverage | ci-unit | ci-bench | ci-snapshot | ci-artifacts | ci-consumers | ci-windows-blocking | ci-windows-complete | ci-windows-observational-ready | node-compat | check-all | hygiene | doc-sync | doc-quick | i18n, got ${JSON.stringify(raw)}.`,
|
||||
`run-gates: expected mode ci-primary | ci-linux-primary | ci-static | ci-lint-contracts-ready | ci-coverage | ci-unit | ci-bench | ci-snapshot | ci-artifacts | ci-consumers | ci-build | ci-consumers-prebuilt | ci-web-snapshot-prebuilt | ci-windows-blocking | ci-windows-complete | ci-windows-observational-ready | node-compat | check-all | hygiene | doc-sync | doc-quick | i18n, got ${JSON.stringify(raw)}.`,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -334,6 +340,12 @@ export function gatesForMode(selected: Mode): Gate[] {
|
||||
return ciArtifactGates()
|
||||
case 'ci-consumers':
|
||||
return ciConsumerGates()
|
||||
case 'ci-build':
|
||||
return ciBuildOnceGates()
|
||||
case 'ci-consumers-prebuilt':
|
||||
return ciPrebuiltConsumerGates()
|
||||
case 'ci-web-snapshot-prebuilt':
|
||||
return ciPrebuiltWebSnapshotGates()
|
||||
case 'ci-windows-blocking':
|
||||
return ciWindowsBlockingGates()
|
||||
case 'ci-windows-complete':
|
||||
@@ -549,8 +561,9 @@ function ciConsumerGates(): Gate[] {
|
||||
const playwrightInstall = ciPlaywrightInstallGate()
|
||||
const browserTree = playwrightInstall === undefined ? builtTree : [...builtTree, playwrightInstall.id]
|
||||
// The HMR web test starts `dev:web`, which rewrites the shared `lib/` and
|
||||
// `apps/web/dist/` trees. Let every build-artifact reader settle before that
|
||||
// writer starts; `after` preserves the web diagnostic even if a reader fails.
|
||||
// `apps/web/dist/` trees, and a browser pool beside the readers starves their
|
||||
// timing-sensitive child processes of CPU. Let every build-artifact reader
|
||||
// settle first; `after` preserves the web diagnostic even if a reader fails.
|
||||
const buildArtifactReaders = [
|
||||
'publint',
|
||||
'snapshot',
|
||||
@@ -584,7 +597,7 @@ function ciConsumerGates(): Gate[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the Playwright browsers as a gate that runs beside the build; only the browser readers need it.
|
||||
* Install the web snapshot browsers beside the build instead of before the aggregate.
|
||||
* `DSH_CI_PLAYWRIGHT_INSTALL` selects `with-deps` (ephemeral runners, which also install
|
||||
* system packages through apt) or `browsers` (persistent hosts whose image owns those packages);
|
||||
* unset leaves browser installation to the caller.
|
||||
@@ -605,6 +618,50 @@ function ciPlaywrightInstallGate(): Gate | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build-once CI lane: emit official client artifacts once and run the cheap
|
||||
* readers beside the packing job; downstream jobs restore this output.
|
||||
*/
|
||||
function ciBuildOnceGates(): Gate[] {
|
||||
return [
|
||||
ciArtifactBuildGate(),
|
||||
pnpmScript('publint', 'publint', { needs: ['build'] }),
|
||||
pnpmScript('node-next-types', 'verify-node-next-types', {
|
||||
label: 'node-next types',
|
||||
needs: ['build'],
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Artifact consumers on a checkout whose build output was restored from the
|
||||
* `ci-build` lane, so no gate builds or waits for a build. Node compatibility
|
||||
* reads only source and runs here, off the build job's critical path.
|
||||
*/
|
||||
function ciPrebuiltConsumerGates(): Gate[] {
|
||||
return [
|
||||
pnpmScript('node-compat', 'check:node-compat', {
|
||||
label: 'Node compatibility',
|
||||
env: { [CLIENT_BUILD_PROFILE_SELECTOR]: 'official' },
|
||||
}),
|
||||
// The web snapshot shards run the apps/web/tests/*.snapshot.ts adapters.
|
||||
snapshotGate([], { skipWebAdapters: true }),
|
||||
expectedOutputGate([]),
|
||||
pnpmScript('doc-typecheck', 'doc-typecheck:contracts-ready', {
|
||||
env: { DSH_DOC_TYPECHECK_USE_BUILD_OUTPUT: '1' },
|
||||
}),
|
||||
builtBinSmokeGate([]),
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* One web snapshot shard on a checkout with restored build output. The CI job
|
||||
* installs the browsers itself, overlapped with the artifact download.
|
||||
*/
|
||||
function ciPrebuiltWebSnapshotGates(): Gate[] {
|
||||
return [webSnapshotGate([])]
|
||||
}
|
||||
|
||||
function webSnapshotGate(needs: string[], after?: string[]): Gate {
|
||||
const order = after === undefined ? { needs } : { needs, after }
|
||||
const workerRaw = process.env.DSH_WEB_SNAPSHOT_WORKERS
|
||||
@@ -808,9 +865,11 @@ function ciUnitGates(): Gate[] {
|
||||
|
||||
// Recorded-session adapters boot process scenarios in `lib` mode. Callers wait
|
||||
// either on `build` or on a validation gate that transitively owns that build.
|
||||
function snapshotGate(needs: string[] = ['build']): Gate {
|
||||
// `skipWebAdapters` leaves the browser-backed apps/web/tests adapters to a lane
|
||||
// that already runs them (vitest.snapshot.config.ts).
|
||||
function snapshotGate(needs: string[] = ['build'], options: { skipWebAdapters?: boolean } = {}): Gate {
|
||||
return pnpmScript('snapshot', 'test:snapshot', {
|
||||
env: { DSH_EXAMPLE_MODE: 'lib' },
|
||||
env: { DSH_EXAMPLE_MODE: 'lib', ...options.skipWebAdapters === true ? { DSH_SNAPSHOT_SKIP_WEB_ADAPTERS: '1' } : {} },
|
||||
needs,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,30 +1,41 @@
|
||||
/** Run serial browser owners before one bounded snapshot pool. */
|
||||
/**
|
||||
* Run serial browser owners before one bounded snapshot pool of the other projects
|
||||
* (scripts/web-snapshot-projects.ts).
|
||||
* `DSH_WEB_SNAPSHOT_SHARD=<index>/<count>` runs one weighted shard of the pool
|
||||
* (scripts/web-snapshot-sequencer.ts); the serial files, which rewrite the shared
|
||||
* build output, run only in the last shard so no other shard needs to wait for them.
|
||||
*/
|
||||
import { spawn } from 'node:child_process'
|
||||
import { pnpmInvocation } from './pnpm-invocation.ts'
|
||||
import {
|
||||
WEB_SNAPSHOT_POOL_PROJECTS,
|
||||
WEB_SNAPSHOT_SERIAL_FILES,
|
||||
WEB_SNAPSHOT_SERIAL_PROJECT,
|
||||
ownsWebSnapshotSerialFiles,
|
||||
parseWebSnapshotShard,
|
||||
} from './web-snapshot-projects.ts'
|
||||
|
||||
const serialFiles = [
|
||||
'apps/web/tests/hmr-live.e2e.ts',
|
||||
'apps/web/tests/client-plugin-live.e2e.ts',
|
||||
// Recorded SVG streaming retains live heartbeat assertions; reserve its browser CPU budget.
|
||||
'apps/web/tests/present-svg.e2e.ts',
|
||||
]
|
||||
const workerRaw = process.env.DSH_WEB_SNAPSHOT_WORKERS
|
||||
const workers = Number.parseInt(workerRaw ?? '', 10)
|
||||
if (!Number.isSafeInteger(workers) || workers < 1 || String(workers) !== workerRaw) {
|
||||
throw new Error(`DSH_WEB_SNAPSHOT_WORKERS must be a positive integer, got ${JSON.stringify(workerRaw)}.`)
|
||||
}
|
||||
const shard = parseWebSnapshotShard(process.env.DSH_WEB_SNAPSHOT_SHARD)
|
||||
const shardArgs = shard === undefined ? [] : [`--shard=${String(shard.index)}/${String(shard.count)}`]
|
||||
const ownsSerialFiles = ownsWebSnapshotSerialFiles(shard)
|
||||
const invocation = pnpmInvocation(['exec', 'vitest', 'run', '--config', 'vitest.web.config.ts'])
|
||||
let serialStatus = 0
|
||||
for (const file of serialFiles) {
|
||||
serialStatus = await run(invocation.command, [...invocation.args, file])
|
||||
for (const file of ownsSerialFiles ? WEB_SNAPSHOT_SERIAL_FILES : []) {
|
||||
serialStatus = await run(invocation.command, [...invocation.args, `--project=${WEB_SNAPSHOT_SERIAL_PROJECT}`, file])
|
||||
if (serialStatus !== 0) break
|
||||
}
|
||||
if (serialStatus === 0) {
|
||||
process.exitCode = await run(invocation.command, [
|
||||
...invocation.args,
|
||||
...serialFiles.map(file => `--exclude=${file}`),
|
||||
...WEB_SNAPSHOT_POOL_PROJECTS.map(project => `--project=${project}`),
|
||||
'--fileParallelism',
|
||||
`--maxWorkers=${String(workers)}`,
|
||||
...shardArgs,
|
||||
])
|
||||
} else {
|
||||
process.exitCode = serialStatus
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
WEB_SNAPSHOT_SERIAL_FILES,
|
||||
WEB_SNAPSHOT_SLICE_COUNTS,
|
||||
ownsWebSnapshotSerialFiles,
|
||||
parseWebSnapshotShard,
|
||||
sliceOfTest,
|
||||
sliceProjectName,
|
||||
webSnapshotProjects,
|
||||
} from './web-snapshot-projects.ts'
|
||||
|
||||
describe('web snapshot test slices', () => {
|
||||
it('assigns tests to slices round-robin by depth-first index', () => {
|
||||
expect(Array.from({ length: 7 }, (_, index) => sliceOfTest(index, 3))).toEqual([1, 2, 3, 1, 2, 3, 1])
|
||||
})
|
||||
|
||||
it('names one project per slice by file stem', () => {
|
||||
expect(sliceProjectName('apps/web/tests/document-preview.e2e.ts', 2)).toBe('web-slice:document-preview:2')
|
||||
})
|
||||
|
||||
// The slice setup file checks at runtime that each slice receives a test.
|
||||
it('plans only existing, non-serial files, each with at least two slices', () => {
|
||||
const plans = Object.entries(WEB_SNAPSHOT_SLICE_COUNTS)
|
||||
|
||||
expect(plans.length).toBeGreaterThan(0)
|
||||
for (const [file, count] of plans) {
|
||||
expect(existsSync(file), file).toBe(true)
|
||||
expect(WEB_SNAPSHOT_SERIAL_FILES, file).not.toContain(file)
|
||||
expect(Number.isSafeInteger(count) && count >= 2, file).toBe(true)
|
||||
}
|
||||
})
|
||||
|
||||
it('runs each sliced file only in its slice projects', () => {
|
||||
const projects = webSnapshotProjects(['apps/web/tests/**/*.e2e.ts'], ['**/node_modules/**'])
|
||||
const main = projects.find(project => project.test.name === 'web')
|
||||
|
||||
for (const [file, count] of Object.entries(WEB_SNAPSHOT_SLICE_COUNTS)) {
|
||||
expect(main?.test.exclude, file).toContain(file)
|
||||
const slices = projects.filter(project => project.test.include.includes(file)).map(project => project.test.name)
|
||||
expect(slices, file).toEqual(Array.from({ length: count }, (_, index) => sliceProjectName(file, index + 1)))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('web snapshot shards', () => {
|
||||
it('parses an in-range shard', () => {
|
||||
expect(parseWebSnapshotShard('1/2')).toEqual({ index: 1, count: 2 })
|
||||
expect(parseWebSnapshotShard('2/2')).toEqual({ index: 2, count: 2 })
|
||||
})
|
||||
|
||||
it.each(['3/2', '0/2', 'a/b'])('rejects shard %s', (raw) => {
|
||||
expect(() => parseWebSnapshotShard(raw)).toThrow(
|
||||
`DSH_WEB_SNAPSHOT_SHARD must be <index>/<count> with 1 <= index <= count, got ${JSON.stringify(raw)}.`,
|
||||
)
|
||||
})
|
||||
|
||||
it('runs the whole pool and the serial files when unset', () => {
|
||||
expect(parseWebSnapshotShard(undefined)).toBeUndefined()
|
||||
expect(parseWebSnapshotShard('')).toBeUndefined()
|
||||
expect(ownsWebSnapshotSerialFiles(undefined)).toBe(true)
|
||||
})
|
||||
|
||||
it('runs the serial files only in the last shard', () => {
|
||||
expect(ownsWebSnapshotSerialFiles({ index: 1, count: 2 })).toBe(false)
|
||||
expect(ownsWebSnapshotSerialFiles({ index: 2, count: 2 })).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('web perf inventory', () => {
|
||||
it('collects only the perf files, without the browser lane projects or sequencer', async () => {
|
||||
// A runtime URL keeps the root Vitest configs outside the scripts type program.
|
||||
const perfConfigUrl = pathToFileURL(resolve(import.meta.dirname, '../vitest.web.perf.config.ts')).href
|
||||
const { default: webPerfConfig } = await import(perfConfigUrl) as { default: { test?: Record<string, unknown> } }
|
||||
expect(webPerfConfig.test).not.toHaveProperty('projects')
|
||||
expect(webPerfConfig.test).not.toHaveProperty('sequence')
|
||||
expect(webPerfConfig.test?.include).toEqual([
|
||||
'apps/web/tests/**/*.perf.ts',
|
||||
'packages/client/ui-conversation/tests/**/*.perf.client.ts',
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Vitest projects of the web snapshot lane (vitest.web.config.ts).
|
||||
*
|
||||
* Project `web-serial` holds the files that rewrite the shared build output; scripts/run-web-snapshots.ts
|
||||
* runs them one at a time before the pool of every other project. Project `web` holds the remaining
|
||||
* files except the sliced ones. Vitest applies a CLI `--exclude` to the root configuration only, not to
|
||||
* `test.projects`, so the runner selects projects with `--project` instead of excluding files.
|
||||
*
|
||||
* A Vitest worker runs one file at about one CPU core, so a long browser file bounds the wall time of
|
||||
* its shard. Each file in {@link WEB_SNAPSHOT_SLICE_COUNTS} runs as `count` Vitest projects named
|
||||
* `web-slice:<file stem>:<k>`, each of which includes only that file. Every slice imports the whole
|
||||
* file and runs its file-level hooks, and `web-snapshot-slice.setup.ts` skips the tests outside slice
|
||||
* `k` before they run, which also skips their `beforeEach`/`afterEach` hooks and every `describe`
|
||||
* without a test in the slice.
|
||||
*
|
||||
* Test `i` of a file, counted depth-first in collection order from zero, belongs to slice `(i mod
|
||||
* count) + 1`. Every slice computes the assignment from the same collected test list, so the slices of
|
||||
* a file run each test exactly once. A file joins the plan only when no test reads state that an
|
||||
* earlier test of the same file creates, and when concurrent copies of its hooks share no fixed port
|
||||
* or path.
|
||||
*/
|
||||
import { basename } from 'node:path'
|
||||
|
||||
/** Files that rewrite the shared build output, in the order the CI runner runs them alone. */
|
||||
export const WEB_SNAPSHOT_SERIAL_FILES: readonly string[] = [
|
||||
'apps/web/tests/hmr-live.e2e.ts',
|
||||
'apps/web/tests/client-plugin-live.e2e.ts',
|
||||
// Recorded SVG streaming retains live heartbeat assertions; reserve its browser CPU budget.
|
||||
'apps/web/tests/present-svg.e2e.ts',
|
||||
]
|
||||
|
||||
/** Name of the project that holds {@link WEB_SNAPSHOT_SERIAL_FILES}. */
|
||||
export const WEB_SNAPSHOT_SERIAL_PROJECT = 'web-serial'
|
||||
|
||||
/** `--project` patterns that select every project of the parallel pool. */
|
||||
export const WEB_SNAPSHOT_POOL_PROJECTS: readonly string[] = ['web', 'web-slice:*']
|
||||
|
||||
/** One weighted shard of the parallel pool, from `DSH_WEB_SNAPSHOT_SHARD=<index>/<count>`. */
|
||||
export interface WebSnapshotShard {
|
||||
readonly index: number
|
||||
readonly count: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse `DSH_WEB_SNAPSHOT_SHARD`.
|
||||
* @param raw - The variable's value; unset or empty selects the whole pool.
|
||||
* @returns The shard, or `undefined` for the whole pool.
|
||||
* @throws Error when the value is not `<index>/<count>` with 1 <= index <= count.
|
||||
*/
|
||||
export function parseWebSnapshotShard(raw: string | undefined): WebSnapshotShard | undefined {
|
||||
if (raw === undefined || raw === '') return undefined
|
||||
const match = /^([1-9]\d*)\/([1-9]\d*)$/.exec(raw)
|
||||
if (match === null || Number(match[1]) > Number(match[2])) {
|
||||
throw new Error(`DSH_WEB_SNAPSHOT_SHARD must be <index>/<count> with 1 <= index <= count, got ${JSON.stringify(raw)}.`)
|
||||
}
|
||||
return { index: Number(match[1]), count: Number(match[2]) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a run owns {@link WEB_SNAPSHOT_SERIAL_FILES}: an unsharded run, or the last shard only, so no
|
||||
* other shard waits for them.
|
||||
* @param shard - The parsed shard, or `undefined` for the whole pool.
|
||||
* @returns `true` when the run executes the serial files.
|
||||
*/
|
||||
export function ownsWebSnapshotSerialFiles(shard: WebSnapshotShard | undefined): boolean {
|
||||
return shard === undefined || shard.index === shard.count
|
||||
}
|
||||
|
||||
/** Environment variable that tells a slice project's workers which slice they run, as `<file>#<k>`. */
|
||||
export const WEB_SNAPSHOT_SLICE_ENV = 'DSH_WEB_SNAPSHOT_SLICE'
|
||||
|
||||
/**
|
||||
* Slice count of each sliced file, keyed by its root-relative path. These files bound their shard's
|
||||
* wall time when they run whole in one worker; each count must be at least two.
|
||||
*/
|
||||
export const WEB_SNAPSHOT_SLICE_COUNTS: Readonly<Record<string, number>> = {
|
||||
'apps/web/tests/forge-panel.e2e.ts': 4,
|
||||
'apps/web/tests/fold-blank-matrix.e2e.ts': 3,
|
||||
'apps/web/tests/document-preview.e2e.ts': 2,
|
||||
'apps/web/tests/chat-scroll-contract.e2e.ts': 2,
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the Vitest project that runs one slice of a file.
|
||||
* @param file - root-relative path of the sliced file.
|
||||
* @param slice - one-based slice index.
|
||||
* @returns `web-slice:<file stem>:<slice>`.
|
||||
*/
|
||||
export function sliceProjectName(file: string, slice: number): string {
|
||||
return `web-slice:${basename(file).replace(/\.[^.]*\.ts$/, '')}:${String(slice)}`
|
||||
}
|
||||
|
||||
/**
|
||||
* One-based slice of a test under round-robin assignment.
|
||||
* @param index - zero-based depth-first index of the test within its file.
|
||||
* @param count - slice count of the file.
|
||||
* @returns `(index mod count) + 1`.
|
||||
*/
|
||||
export function sliceOfTest(index: number, count: number): number {
|
||||
return (index % count) + 1
|
||||
}
|
||||
|
||||
/** Inline Vitest project entry; every entry extends the root configuration. */
|
||||
export interface WebSnapshotProject {
|
||||
readonly extends: true
|
||||
readonly test: {
|
||||
readonly name: string
|
||||
readonly include: string[]
|
||||
readonly exclude?: string[]
|
||||
readonly env?: Record<string, string>
|
||||
readonly setupFiles?: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Projects of the web snapshot lane.
|
||||
* @param include - globs of every web snapshot file.
|
||||
* @param defaultExclude - Vitest's default exclude globs, which a project-level `exclude` replaces.
|
||||
* @returns the serial project, the main project, and one project per slice of each sliced file.
|
||||
*/
|
||||
export function webSnapshotProjects(include: readonly string[], defaultExclude: readonly string[]): WebSnapshotProject[] {
|
||||
return [
|
||||
{ extends: true, test: { name: WEB_SNAPSHOT_SERIAL_PROJECT, include: [...WEB_SNAPSHOT_SERIAL_FILES] } },
|
||||
{ extends: true, test: { name: 'web', include: [...include], exclude: [...defaultExclude, ...WEB_SNAPSHOT_SERIAL_FILES, ...Object.keys(WEB_SNAPSHOT_SLICE_COUNTS)] } },
|
||||
...Object.entries(WEB_SNAPSHOT_SLICE_COUNTS).flatMap(([file, count]) =>
|
||||
Array.from({ length: count }, (_, index): WebSnapshotProject => ({
|
||||
extends: true,
|
||||
test: {
|
||||
name: sliceProjectName(file, index + 1),
|
||||
include: [file],
|
||||
env: { [WEB_SNAPSHOT_SLICE_ENV]: `${file}#${String(index + 1)}` },
|
||||
setupFiles: ['./scripts/web-snapshot-slice.setup.ts'],
|
||||
},
|
||||
}))),
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { assignWeightedShards, parseShardShares } from './web-snapshot-sequencer.ts'
|
||||
|
||||
describe('web snapshot shard assignment', () => {
|
||||
const files = [
|
||||
{ key: 'a.e2e.ts', weight: 90 },
|
||||
{ key: 'b.e2e.ts', weight: 60 },
|
||||
{ key: 'c.e2e.ts', weight: 50 },
|
||||
{ key: 'd.e2e.ts', weight: 30 },
|
||||
{ key: 'e.e2e.ts', weight: 20 },
|
||||
]
|
||||
|
||||
it('partitions every file exactly once and balances load longest-first', () => {
|
||||
const shards = assignWeightedShards(files, [1, 1])
|
||||
|
||||
expect(shards.flat().sort()).toEqual(files.map(file => file.key))
|
||||
expect(shards).toEqual([['a.e2e.ts', 'd.e2e.ts'], ['b.e2e.ts', 'c.e2e.ts', 'e.e2e.ts']])
|
||||
})
|
||||
|
||||
it('gives a larger share proportionally more weight', () => {
|
||||
const shards = assignWeightedShards(files, [1, 3])
|
||||
const load = (keys: readonly string[]) => keys.reduce((sum, key) => sum + (files.find(file => file.key === key)?.weight ?? 0), 0)
|
||||
|
||||
expect(load(shards[0] ?? [])).toBeLessThan(load(shards[1] ?? []))
|
||||
})
|
||||
|
||||
it('places the slice specs of one file as separate weights', () => {
|
||||
const slices = [1, 2, 3].map(slice => ({ key: `web-slice:long:${String(slice)}:long.e2e.ts`, weight: 40 }))
|
||||
const shards = assignWeightedShards([...slices, { key: 'web:a.e2e.ts', weight: 60 }], [1, 1])
|
||||
|
||||
expect(shards).toEqual([['web:a.e2e.ts', 'web-slice:long:3:long.e2e.ts'], ['web-slice:long:1:long.e2e.ts', 'web-slice:long:2:long.e2e.ts']])
|
||||
})
|
||||
|
||||
it('returns the same assignment for any input order', () => {
|
||||
expect(assignWeightedShards([...files].reverse(), [1, 1])).toEqual(assignWeightedShards(files, [1, 1]))
|
||||
})
|
||||
|
||||
it('defaults to equal shares and rejects a malformed share list', () => {
|
||||
expect(parseShardShares(undefined, 3)).toEqual([1, 1, 1])
|
||||
expect(parseShardShares('0.45, 0.55', 2)).toEqual([0.45, 0.55])
|
||||
expect(() => parseShardShares('1', 2)).toThrow(/must list 2 positive numbers/)
|
||||
expect(() => parseShardShares('1,0', 2)).toThrow(/must list 2 positive numbers/)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Vitest sequencer that splits the web snapshot lane into capacity-weighted shards.
|
||||
*
|
||||
* Vitest's default `--shard` splits a hash-ordered file list into equal file counts, so one shard can
|
||||
* receive most of the long browser files. This sequencer assigns files longest-first to the shard with
|
||||
* the lowest load relative to its capacity share. A file's weight is its byte size, which tracks its
|
||||
* serial browser time closely enough for balancing and needs no recorded history. A slice project of a
|
||||
* long file (scripts/web-snapshot-projects.ts) weighs the file's size divided by its slice count. Every
|
||||
* shard computes the same assignment from the same checkout, so the shards partition the spec set exactly.
|
||||
*
|
||||
* `DSH_WEB_SNAPSHOT_SHARD_SHARES` lists one positive capacity share per shard, comma-separated; unset
|
||||
* gives every shard the same share.
|
||||
*/
|
||||
import { statSync } from 'node:fs'
|
||||
import { relative } from 'node:path'
|
||||
import { BaseSequencer } from 'vitest/node'
|
||||
import type { TestSpecification } from 'vitest/node'
|
||||
import { WEB_SNAPSHOT_SLICE_COUNTS } from './web-snapshot-projects.ts'
|
||||
|
||||
/** Environment variable listing the capacity share of each web snapshot shard. */
|
||||
export const WEB_SNAPSHOT_SHARD_SHARES_ENV = 'DSH_WEB_SNAPSHOT_SHARD_SHARES'
|
||||
|
||||
/** One spec to place, identified by its project name and root-relative path. */
|
||||
export interface WeightedFile {
|
||||
readonly key: string
|
||||
readonly weight: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the per-shard capacity shares.
|
||||
* @param raw - comma-separated positive numbers, or undefined for equal shares.
|
||||
* @param count - number of shards.
|
||||
* @returns one share per shard.
|
||||
* @throws If the list length differs from `count` or a share is not a positive finite number.
|
||||
*/
|
||||
export function parseShardShares(raw: string | undefined, count: number): number[] {
|
||||
if (raw === undefined || raw === '') return Array.from({ length: count }, () => 1)
|
||||
const shares = raw.split(',').map(part => Number(part.trim()))
|
||||
if (shares.length !== count || shares.some(share => !Number.isFinite(share) || share <= 0)) {
|
||||
throw new Error(`${WEB_SNAPSHOT_SHARD_SHARES_ENV} must list ${String(count)} positive numbers, got ${JSON.stringify(raw)}.`)
|
||||
}
|
||||
return shares
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign files to shards longest-first, each to the shard with the lowest load per unit of share.
|
||||
* Ties break by key and then by lower shard index, so the result depends only on the inputs.
|
||||
* @param files - files with their weights.
|
||||
* @param shares - capacity share of each shard.
|
||||
* @returns the file keys of each shard.
|
||||
*/
|
||||
export function assignWeightedShards(files: readonly WeightedFile[], shares: readonly number[]): string[][] {
|
||||
const loads = shares.map(() => 0)
|
||||
const shards: string[][] = shares.map(() => [])
|
||||
const ordered = [...files].sort((a, b) => b.weight - a.weight || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
||||
for (const file of ordered) {
|
||||
let target = 0
|
||||
for (let index = 1; index < shares.length; index++) {
|
||||
if ((loads[index] ?? 0) / (shares[index] ?? 1) < (loads[target] ?? 0) / (shares[target] ?? 1)) target = index
|
||||
}
|
||||
loads[target] = (loads[target] ?? 0) + file.weight
|
||||
shards[target]?.push(file.key)
|
||||
}
|
||||
return shards
|
||||
}
|
||||
|
||||
/** Web snapshot sequencer: weighted sharding, default ordering. */
|
||||
export default class WebSnapshotSequencer extends BaseSequencer {
|
||||
override shard(files: TestSpecification[]): Promise<TestSpecification[]> {
|
||||
const { index, count } = this.ctx.config.shard ?? { index: 1, count: 1 }
|
||||
const root = this.ctx.config.root
|
||||
const pathOf = (spec: TestSpecification) => relative(root, spec.moduleId).replaceAll('\\', '/')
|
||||
const keyOf = (spec: TestSpecification) => `${spec.project.name}:${pathOf(spec)}`
|
||||
// Only slice projects include a sliced file.
|
||||
const weightOf = (spec: TestSpecification) => statSync(spec.moduleId).size / (WEB_SNAPSHOT_SLICE_COUNTS[pathOf(spec)] ?? 1)
|
||||
const shards = assignWeightedShards(
|
||||
files.map(spec => ({ key: keyOf(spec), weight: weightOf(spec) })),
|
||||
parseShardShares(process.env[WEB_SNAPSHOT_SHARD_SHARES_ENV], count),
|
||||
)
|
||||
const selected = new Set(shards[index - 1])
|
||||
return Promise.resolve(files.filter(spec => selected.has(keyOf(spec))))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Setup file of the web snapshot slice projects (scripts/web-snapshot-projects.ts).
|
||||
*
|
||||
* Its `beforeAll` runs after Vitest collects the file and before the file's own hooks. It sets the
|
||||
* runner task mode of every test outside this worker's slice, and of every `describe` left without a
|
||||
* test in the slice, to `'skip'`, so their tests and `beforeEach`/`afterEach` hooks do not run.
|
||||
* Changing `task.mode` after collection relies on Vitest runner internals that are not public API,
|
||||
* verified on Vitest 4.1.11. A worker fails instead of running the whole file when its collected file
|
||||
* is not the planned file or when the file has fewer tests than slices.
|
||||
*/
|
||||
import type { RunnerTestCase, RunnerTestFile, RunnerTestSuite } from 'vitest'
|
||||
import { beforeAll } from 'vitest'
|
||||
import { WEB_SNAPSHOT_SLICE_COUNTS, WEB_SNAPSHOT_SLICE_ENV, sliceOfTest } from './web-snapshot-projects.ts'
|
||||
|
||||
const sliceMatch = /^(.+)#([1-9]\d*)$/.exec(process.env[WEB_SNAPSHOT_SLICE_ENV] ?? '')
|
||||
if (sliceMatch === null) throw new Error(`${WEB_SNAPSHOT_SLICE_ENV} must be <file>#<slice>, got ${JSON.stringify(process.env[WEB_SNAPSHOT_SLICE_ENV])}.`)
|
||||
const [, slicedFile = '', sliceRaw = ''] = sliceMatch
|
||||
const count = WEB_SNAPSHOT_SLICE_COUNTS[slicedFile]
|
||||
if (count === undefined) throw new Error(`${slicedFile} has no entry in WEB_SNAPSHOT_SLICE_COUNTS (scripts/web-snapshot-projects.ts).`)
|
||||
const slice = Number(sliceRaw)
|
||||
|
||||
// The first argument must destructure: Vitest parses hook parameters as fixtures.
|
||||
beforeAll(({}, suite) => {
|
||||
const file = suite.file
|
||||
// A file task's name is its path relative to the project root.
|
||||
const collected = file.name.replaceAll('\\', '/')
|
||||
if (collected !== slicedFile) throw new Error(`Slice project for ${slicedFile} collected ${collected}.`)
|
||||
const tests: RunnerTestCase[] = []
|
||||
const collect = (parent: RunnerTestFile | RunnerTestSuite) => {
|
||||
for (const task of parent.tasks) {
|
||||
if (task.type === 'test') tests.push(task)
|
||||
else collect(task)
|
||||
}
|
||||
}
|
||||
collect(file)
|
||||
if (tests.length < count) {
|
||||
throw new Error(`${slicedFile} has ${String(tests.length)} tests but WEB_SNAPSHOT_SLICE_COUNTS gives it ${String(count)} slices; lower its count in scripts/web-snapshot-projects.ts.`)
|
||||
}
|
||||
tests.forEach((test, index) => {
|
||||
if (sliceOfTest(index, count) !== slice) test.mode = 'skip'
|
||||
})
|
||||
const settle = (parent: RunnerTestFile | RunnerTestSuite): boolean => {
|
||||
let runs = false
|
||||
for (const task of parent.tasks) {
|
||||
const taskRuns = task.type === 'test' ? task.mode === 'run' : settle(task)
|
||||
if (task.type === 'suite' && !taskRuns && task.mode === 'run') task.mode = 'skip'
|
||||
runs ||= taskRuns
|
||||
}
|
||||
return runs
|
||||
}
|
||||
settle(file)
|
||||
})
|
||||
@@ -21,6 +21,12 @@ const snapshotMaxConcurrency = positiveIntFromEnv(
|
||||
Math.min(DEFAULT_SNAPSHOT_MAX_CONCURRENCY, availableParallelism()),
|
||||
)
|
||||
|
||||
const skipWebAdaptersRaw = process.env.DSH_SNAPSHOT_SKIP_WEB_ADAPTERS
|
||||
if (skipWebAdaptersRaw !== undefined && skipWebAdaptersRaw !== '' && skipWebAdaptersRaw !== '1') {
|
||||
throw new Error(`DSH_SNAPSHOT_SKIP_WEB_ADAPTERS must be 1 when set, got ${JSON.stringify(skipWebAdaptersRaw)}`)
|
||||
}
|
||||
const skipWebAdapters = skipWebAdaptersRaw === '1'
|
||||
|
||||
const snapshotMaxWorkers = process.env.DSH_SNAPSHOT_MAX_WORKERS
|
||||
? positiveIntFromEnv('DSH_SNAPSHOT_MAX_WORKERS', availableParallelism())
|
||||
: undefined
|
||||
@@ -52,7 +58,9 @@ export default defineConfig({
|
||||
'scripts/session-snapshot-corpus.corpus.ts',
|
||||
// The assembled Web snapshot executes generated client bundles; source
|
||||
// mode remains the zero-build path, while lib mode requires a prior build.
|
||||
...(process.env.DSH_EXAMPLE_MODE === 'lib' ? ['apps/web/tests/**/*.snapshot.ts'] : []),
|
||||
// DSH_SNAPSHOT_SKIP_WEB_ADAPTERS=1 (only unset or 1) drops them for a CI
|
||||
// lane whose web snapshot shards already run these files.
|
||||
...(process.env.DSH_EXAMPLE_MODE === 'lib' && !skipWebAdapters ? ['apps/web/tests/**/*.snapshot.ts'] : []),
|
||||
'snapshots/**/*.snapshot.ts',
|
||||
],
|
||||
// Replay never writes committed outputs and every scenario owns its
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import { configDefaults, defineConfig } from 'vitest/config'
|
||||
import WebSnapshotSequencer from './scripts/web-snapshot-sequencer.ts'
|
||||
import { webSnapshotProjects } from './scripts/web-snapshot-projects.ts'
|
||||
import { standardDecoratorPlugin, vitestExecArgv } from './vitest.shared.ts'
|
||||
|
||||
// Web browser lane: real host entry points, built-client interaction snapshots,
|
||||
@@ -23,15 +25,18 @@ export default defineConfig({
|
||||
],
|
||||
test: {
|
||||
execArgv: vitestExecArgv,
|
||||
include: [
|
||||
// Serial, main, and sliced long-file projects; see scripts/web-snapshot-projects.ts.
|
||||
projects: webSnapshotProjects([
|
||||
'apps/web/tests/**/*.e2e.ts',
|
||||
'apps/web/tests/**/*.snapshot.ts',
|
||||
'packages/experimental/inspector/tests/client-browser.e2e.ts',
|
||||
],
|
||||
], configDefaults.exclude),
|
||||
// Local and record runs stay serial. CI runs workspace-mutating HMR and
|
||||
// dynamic Cordis lifecycle coverage before parallelizing the remaining files.
|
||||
testTimeout: 180_000,
|
||||
hookTimeout: 120_000,
|
||||
fileParallelism: false,
|
||||
// `--shard` splits CI's two web snapshot machines by file weight, not file count.
|
||||
sequence: { sequencer: WebSnapshotSequencer },
|
||||
},
|
||||
})
|
||||
@@ -2,12 +2,16 @@ import { defineConfig } from 'vitest/config'
|
||||
import webConfig from './vitest.web.config.ts'
|
||||
import { vitestExecArgv } from './vitest.shared.ts'
|
||||
|
||||
// The browser lane's `projects` and `sequence` would replace this root
|
||||
// `include`, so the perf inventory keeps only the shared test options.
|
||||
const { projects: _projects, sequence: _sequence, ...webTest } = webConfig.test ?? {}
|
||||
|
||||
// Manual high-cardinality diagnostics stay outside every default Vitest
|
||||
// inventory and therefore outside CI's executed test lanes.
|
||||
export default defineConfig({
|
||||
...webConfig,
|
||||
test: {
|
||||
...webConfig.test,
|
||||
...webTest,
|
||||
// Memory diagnostics use forced-GC baselines only in this manual inventory.
|
||||
execArgv: [...vitestExecArgv, '--expose-gc'],
|
||||
include: [
|
||||
|
||||
Reference in new issue
Block a user