ci(console): 把 vitest.config.ts 纳入 tsc program,并把根 vitest 配置算进 turbo 的 cache key - #3513
Conversation
… include entry `apps/console/vitest.config.ts` was in ZERO tsc programs. CI runs `turbo run type-check` — per package — and neither console tsconfig reached the file: `tsconfig.json` includes only `src`/`dev`/ `objectstack.config.ts`, and `tsconfig.node.json` listed only `vite.config.ts` and a `vitest.setup.ts` that does not exist. Add `vitest.config.ts` to `tsconfig.node.json`'s include. Its import of `../../vitest.config.mts` has to be listed too — a composite project must list every file in its program (TS6307) — which incidentally gives the root Vitest config the gate it also lacked. Drop the `vitest.setup.ts` entry rather than repoint it. A literal, glob-less include entry matching nothing is silently ignored by tsc, so it read as coverage that was never there. The setup file `vitest.config.ts` really uses (repo-root `vitest.setup.dom.tsx`) is passed to Vitest as a runtime path string, never imported, so this program has no type edge to it; naming it here was measured red (one TS6307 + four TS2882). No flag changes were needed: `allowImportingTsExtensions` + `emitDeclarationOnly` from #3475 already cover the `.ts`/`.mts` spellings. Refs #3476 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
两条超出本 PR 文件面的发现已单独立项(均未指派):
顺带在量测中确认(省得后人重查):七个包的 Generated by Claude Code Generated by Claude Code |
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
The previous commit makes apps/console's type-check program span a second
repo-root file (`vitest.config.mts`, pulled in because
`apps/console/vitest.config.ts` imports it and a composite project must
list every file in its program). turbo's `type-check` inputs did not hash
it: `$TURBO_DEFAULT$` only covers files inside the package directory, and
`globalDependencies` is unset.
Measured A/B on this branch, same tree, same plant (a real type error in
the root `vitest.config.mts`):
old inputs -> cache hit, replaying logs 4214aa6ab3df0f18 -> exit 0
(a green replayed over a program that does not compile)
new inputs -> cache miss, executing 648e8a0633f2bff7 -> exit 1
../../vitest.config.mts(114,5): error TS2769
Not local-only: ci.yml persists .turbo/cache via actions/cache, and in
this container turbo resolves its cache to the shared checkout's .turbo,
so a stale green survives across worktrees too.
Symmetric with the `$TURBO_ROOT$/scripts/vite-*.ts` entry already present,
which exists for exactly this reason for the other root-level file in the
same program.
Refs #3476, #3514
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
更新(PM 裁决:方案 A,文件面已放宽) — 新增提交 同一棵树、同一次会话内重新做了 A/B,方向先预测后运行,两条都符合:
另量到一条加强证据:本容器里 turbo 的缓存落在共享主 checkout 的 全仓 Generated by Claude Code Generated by Claude Code |
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Fixes #3476
两个文件、两个提交:
apps/console/tsconfig.node.jsoninclude—— 把vitest.config.ts纳入 program,删掉幽灵条目vitest.setup.tsturbo.json$TURBO_ROOT$/vitest.config.mts加进type-check的inputs没有动任何编译选项:PR #3475 留下的
allowImportingTsExtensions+emitDeclarationOnly已经把.ts/.mts显式扩展名这一关过掉了,实测无需追加(见下方「flag 组合」)。前提复核(先证伪,再动手)
issue 的两条论断都在
origin/main(f995a45)上重新量过,均成立:apps/console/vitest.config.ts不在任何 CI 会跑的 tsc program 里tsconfig.node.json的 include 列了不存在的vitest.setup.tsapps/console/下从不存在turbo run type-check,根tsconfig.json只是编辑器配置package.json里type-check就是turbo run type-check,没有任何 script 跑根tsconfig.json补充一条 issue 没写、但顺手量到的:根
tsconfig.json的 program 里其实是有apps/console/vitest.config.ts的(include含apps,且它非 composite 所以不报 TS6307)—— 但既然没有任何 script 运行它,这只是编辑器里的绿,不构成门禁。issue 的判断没有被这一点推翻。改动一:
tsconfig.node.json的 include为什么
../../vitest.config.mts也得进来不是顺手扩大范围,是绕不过去:
vitest.config.ts导入它,而 composite 工程必须列出 program 里的每一个文件。只加vitest.config.ts的中间态实测:跟注释里
../../scripts/vite-*.ts是同一个形状、同一个理由,rootDir: "../.."本来就是为它准备的。附带收益:根 Vitest 配置此前同样不在任何门禁 program 里,现在有了(下方有反向验证)。随之而来的一条约束已写进注释:
vitest.config.mts里那句@ts-expect-error(压制 plain-JS 的vitest-invocation-guard.mjs导入)在这里保持正确,仅仅因为本工程的allowJs是默认的false。哪天有人把它打开,那条指令立刻变成 TS2578 —— 这不是假设,tsconfig.scripts.json选了allowJs: true并为此付过 5 处的代价,而此刻 main 上正红着的 #3504 就是第 6 处。幽灵条目:选择删除,而不是改指
vitest.config.ts真正用的 setup 文件是仓库根的vitest.setup.dom.tsx。但它是以运行期路径字符串交给 Vitest 的,不是 import:所以本 program 与它之间没有任何类型边,把它类型检查一遍并不校验本工程持有的任何契约。改指的代价也实测了 —— 它会把整个 DOM 测试 setup 图拖进一个 Node 构建配置工程:
要弄绿就得让这个「只为被类型检查而存在」的配置工程去依赖整个 workspace 构建图。它属于某个面向测试的 program,不属于这里。故:删掉。
(顺带记录:
vitest.setup.dom.tsx/.base.ts/.dom-light.tsx目前确实不在任何门禁 program 里 —— 已单独立为 #3515,observation 类,超出本 PR 文件面。)改动二:
turbo.json的 cache key"inputs": [ "$TURBO_DEFAULT$", - "$TURBO_ROOT$/scripts/vite-*.ts" + "$TURBO_ROOT$/scripts/vite-*.ts", + "$TURBO_ROOT$/vitest.config.mts" ]改动一让 console 的
type-check多读了一个仓库根文件,而$TURBO_DEFAULT$只覆盖包目录内的文件、globalDependencies未设置 —— 于是这个新增的 program 成员不进哈希,turbo 可以在它已经编译不过的情况下回放一条绿。已有的$TURBO_ROOT$/scripts/vite-*.ts正是为同一 program 的另一个根级文件加的,本行与之对称。turbo.json无注释先例(严格 JSON),故不加注释;理由写在 tsconfig 注释、commit message 与此处。验证
覆盖面前后对照(issue 指定的那条命令)
program 里的仓库文件(改动后,已滤掉 node_modules):
反向验证 A:类型门真的能红(方向先预测后运行,两次都符合)
覆盖面这类改动,「文件名出现在列表里」不算证明 —— 证明是门禁真的能红。故种入真实类型错误,用 CI 的同一条
type-check脚本跑两边:apps/console/vitest.config.ts的setupFiles: [42, ...]origin/main的vitest.config.ts(17,20): error TS2769 ... Type 'number' is not assignable to type 'string'vitest.config.mts的testTimeout: 'fifteen-seconds'origin/main的../../vitest.config.mts(114,5): error TS2769 ... Type 'string' is not assignable to type 'number'反向验证 B:turbo 那一行真的在起作用(同一棵树、同一次会话内的 A/B)
先把缓存跑绿落盘,再在根
vitest.config.mts种入同一个类型错误,只跑 console 这一个 filter:type-check的 inputsorigin/main)cache hit, replaying logs 4214aa6ab3df0f18/Tasks: 35 successful/FULL TURBO/ exit 0cache miss, executing 648e8a0633f2bff7/Failed: @object-ui/console#type-check/ exit 1,输出../../vitest.config.mts(114,5): error TS2769即:修之前 turbo 会把一条绿盖在编译不过的 program 上;修之后同样的改动立刻转红。
不只是本地现象,两条依据:
.github/workflows/ci.yml用actions/cache持久化.turbo/cache,暖缓存会跨 run 携带这条陈旧的绿;/home/user/objectui/.turbo(git worktree 共用 common dir),所以旧哈希4214aa6ab3df0f18在我的 worktree 删除重建之后仍然命中 —— 陈旧的绿会在并行 agent 的多个 worktree 之间旅行。两次种入均已还原,
git status只剩预期的改动文件。门禁
pnpm --filter @object-ui/console type-check(=tsc --noEmit && tsc -b tsconfig.node.json --force)turbo run type-check --concurrency=2(全仓,turbo.json 改后重跑)Tasks: 78 successful, 78 total,exit 0(36 cached / 42 重新执行 —— 改 turbo.json 令全局哈希失效,符合预期)node scripts/check-type-check-coverage.mjs43/45 via type-check ...exit 0pnpm exec vitest run apps/console/ --maxWorkers=2(仓库根)Test Files 23 passed (23)/Tests 212 passed (212)pnpm exec vitest list apps/console/(仓库根)node scripts/check-control-bytes.mjsOK (scanned 3686 tracked text file(s))grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]'自查两个被改文件turbo.json严格 JSON 解析node_modules/.cache/tsc/console-nodeflag 组合:实测「不需要改」
issue 备注提示可能要处理
allowImportingTsExtensions的搭档问题。实测结论是 #3475 已经把这件事做完了:allowImportingTsExtensions: true+emitDeclarationOnly: true对./vite.config.ts与../../vitest.config.mts两种显式扩展名一并成立,本 PR 一个编译选项都没动。--noEmit与本工程emitDeclarationOnly在 TS 6.0.3 下用于--listFilesOnly量测也不冲突(exit 0),故 issue 给的验证命令原样可用。Type Check 会红,且不是本 PR 的锅
净
origin/main(f995a45)上pnpm type-check:scripts目前就是红的:即 #3504,止血 PR #3505 仍是 draft、未合。本 PR 不碰
scripts/,两个被改文件都不在tsconfig.scripts.json的 program(scripts/**)里,不可能是成因。exit 2,导致 CI 从未跑到pnpm type-check—— 也就是说本 PR 自己那道门在 CI 上没被执行过,上表的绿是本地实测的。#3505 落地后需 update branch 复跑一次,让 CI 真正验证。Changeset
未加。
@object-ui/console确实是发布包,但本次只改开发期 tsconfig 的include与turbo.json(后者根本不是发布包),不进dist/,对使用者零可见变化 —— 与 PR #3475 对同一文件的处理一致。changeset:check两条守卫均绿。关联
includelists a file that doesn't exist #3476(本 PR 修复)type-check的手维护 inputs 名单已两次因"包程序越出包目录"失真 —— 评估从 tsconfig include 派生或加钉扎测试 #3514(turbo inputs 的长效解,PM 持有、改写为方案 C;本 PR 落地的是其中的一行止血)vitest.setup.*files are in zero tsc programs — #3476 one directory up #3515(仓库根四个vitest.setup.*不在任何门禁 program,observation 类)configLoader: 'native'#3475 / console vite/vitest configs rely on featuresconfigLoader: 'native'drops — a future Vite major turns 5 warnings into a broken config load #3384(flag 组合的来源)、apps/console/tsconfig.node.json never type-checks — 5 standing errors, including two that say the compression options are typed wrong #3305(本 program 的成因)、[ci] scripts/ 在零 tsconfig 覆盖内:turbo type-check 从不检查 scripts/__tests__/*.ts——一批门禁 pin 测试自身无类型门 #3494 / ci(scripts): 用独立 tsconfig.scripts.json 给 scripts/ 补上类型门 (#3494) #3498(scripts/的同形状)、main 的 Type Check job 全红:#3489 与 #3498 的语义冲突,check-doc-links.test.ts的@ts-expect-error在 allowJs 下变成 TS2578 #3504(live 的allowJs/ TS2578 交互)Generated by Claude Code