Skip to content

ci: Test Core 按包两路分片,verify-CLI 拆为独立并行 job(PR 关键路径 ~13min → ~7min) - #4505

Merged
os-zhuang merged 2 commits into
mainfrom
claude/ci-speed-optimization-7wnr5b
Aug 1, 2026
Merged

ci: Test Core 按包两路分片,verify-CLI 拆为独立并行 job(PR 关键路径 ~13min → ~7min)#4505
os-zhuang merged 2 commits into
mainfrom
claude/ci-speed-optimization-7wnr5b

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

背景

对 2026-08-01 的真实 PR 运行(如 run 30699899662)做了逐 job 计时分析:

Job 时长 瓶颈
Test Core 12.8 min affected 测试单机跑 11m35s
Dogfood shard 1 11.8 min 测试 6.3 min 后 verify-CLI 串行再跑 4.5 min
Dogfood shard 2 6.6 min

改动

1. Test Core 按包两路分片

  • 新增 scripts/partition-test-shards.mjs:读取 turbo ls [--affected] --output=json,以每包测试文件数为权重做确定性 LPT 均衡分片(当前全量 573/572),带 --self-test
  • 不用 dogfood 的 vitest --shard 透传方案,已实测排除:vitest 4.1.10 对测试文件数少于分片数的包直接报错 --shard <count> must be a smaller than count of test files;加 --passWithNoTests 后该包的测试在所有分片上都不执行——静默丢失覆盖。当前有 3 个单测试文件的包(sdui-parsercreate-objectstackembedder-openai)。
  • 空分片列表会短路测试步骤(零 --filterturbo run test 会跑整个 workspace)。
  • required check 契约:新增 test-gate 聚合 job 以裸 Test Core 上下文报告(与 dogfood-gate 同一 chore(ci): cut PR wall-clock ~9.5min → ~5-6min — dedupe dogfood, shard it, cache lint's build #3622 模式),分支保护无需改动;cancelled 语义同 dogfood-gate。
  • Turbo 缓存键、stall 报告 artifact 名均按分片隔离(同 dogfood 模式)。

2. verify-CLI 拆为并行 job

objectstack verify(app-crm + app-showcase,~4.5 min)原来串行挂在 dogfood shard 1 尾部,使 shard 1 接近 shard 2 的两倍时长。现拆为 dogfood-verify 并行 job(Turbo 缓存回退到 build-core 命名空间,CLI 构建闭包基本命中),结果并入既有 Dogfood Regression Gate 聚合,分支保护无需改动

3. 连带修正

temporal-conformance 的 Turbo 缓存回退键从 turbo-test-* 改指 turbo-build-core-*:test 命名空间分片化后单个分片不再是构建闭包的超集,Build Core 构建全部包才是。

验证

  • partition-test-shards.mjs --self-test 通过(覆盖性/确定性/均衡界/退化输入)。
  • 对全量 77 包实跑分片:33+43 包、权重 573/572,dogfood 正确排除。
  • 模拟分片步骤 shell 逻辑($FILTERS 展开 + turbo run test)实跑通过。
  • 所有改动后的 YAML 解析通过;pnpm check:node-version 通过。

预期效果

PR 关键路径 ~12.8 min → ~7 min(Test Core 每片约一半 + dogfood 两片均衡);merge queue 同样受益(full run 也分片)。

未做(需管理员决策)

Turbo 远程缓存(Vercel Remote Cache 或自托管)可根治"PR 只读缓存导致同 PR 重复 push 全量重跑"和 10 GB 缓存池驱逐问题,但需要组织级 token/基础设施,不在本 PR 范围。

🤖 Generated with Claude Code

https://claude.ai/code/session_01U8Ms7unkKxTrmNCX2r1dfs


Generated by Claude Code

CI 提速:PR 关键路径从 ~13 分钟降到 ~7 分钟。

- Test Core 改为 2 路矩阵,按包分片:scripts/partition-test-shards.mjs 以
  测试文件数为权重做确定性 LPT 均衡(当前全量 573/572)。不用 dogfood 的
  vitest --shard 透传,因为 vitest 4 对测试文件数少于分片数的包直接报错,
  加 --passWithNoTests 后该包在所有分片上都不执行(静默丢覆盖);今天有
  3 个单测试文件的包。required check 名称契约由新增的 test-gate 聚合 job
  以裸 "Test Core" 上下文承载(#3622 教训,同 dogfood-gate)。
- `objectstack verify` CLI 步骤从 dogfood shard 1 尾部(串行 +4.5 分钟)
  拆为并行的 dogfood-verify job,结果并入既有 Dogfood Regression Gate,
  分支保护无需变更。
- temporal-conformance 的 Turbo 缓存回退键从 turbo-test-* 改指
  turbo-build-core-*:test 命名空间分片化后,单个分片不再是其构建闭包
  的超集,而 Build Core 构建全部包。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U8Ms7unkKxTrmNCX2r1dfs
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 1, 2026 1:47pm

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci/cd tooling size/m labels Aug 1, 2026
verify 步骤挂在 dogfood shard 1 时,workspace 已被测试步骤全量构建,
--filter=@objectstack/cli 就够;独立成 job 后,打包的 objectstack.config
在运行时还要导入示例 app 自身的依赖(如 app-showcase 的
@objectstack/connector-mcp),其 dist 无人构建 → verify 时
ERR_MODULE_NOT_FOUND。改用 pkg... 闭包过滤同时构建 CLI 与两个示例 app
的依赖闭包,依赖变动时自维护。已本地实测 app-showcase verify 通过。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U8Ms7unkKxTrmNCX2r1dfs
@os-zhuang
os-zhuang marked this pull request as ready for review August 1, 2026 14:19
@os-zhuang
os-zhuang added this pull request to the merge queue Aug 1, 2026
Merged via the queue into main with commit d7759f3 Aug 1, 2026
19 checks passed
@os-zhuang
os-zhuang deleted the claude/ci-speed-optimization-7wnr5b branch August 1, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd documentation Improvements or additions to documentation size/m tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants