Skip to content

ci: optimize test and build pipeline#1107

Merged
ding113 merged 13 commits into
devfrom
perf/ci-test-chain-tsgo-beta-20260425
Apr 25, 2026
Merged

ci: optimize test and build pipeline#1107
ding113 merged 13 commits into
devfrom
perf/ci-test-chain-tsgo-beta-20260425

Conversation

@ding113

@ding113 ding113 commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pin Bun via .bun-version and update @typescript/native-preview to 7.0.0-dev.20260425.1 for faster type checking.
  • Tune Vitest worker/concurrency defaults and serialize stateful suites to avoid DB/Redis/test-server contention.
  • Add Bun/Next caches and bounded timeouts to CI workflows; use no-lock bun install paths for workflows and Docker because this repo intentionally ignores lockfiles.

Verification

  • Baseline timing: /tmp/cch-ci-timing-baseline-3785825
  • Full local verify: /tmp/cch-ci-verify-final-1777123355
  • Exact CI integration after Oracle fix: /tmp/cch-oracle-fix-integration-1777126125/ci_integration.log (2 passed, 19 passed)
  • Public-status integration: /tmp/cch-public-status-verify-1777123966/public_status.log (3 passed, 18 passed)
  • E2E: /tmp/cch-e2e-verify-1777123991/e2e.log (3 passed, 36 passed)
  • Post-review final checklist: /tmp/cch-review-fix-precommit-rerun-1777128170 (build, lint, lint:fix, typecheck, test all exit 0; 548 files, 5189 tests)
  • Post-review Docker no-cache: /tmp/cch-review-fix-docker-1777128396 (deploy/root no-cache builds passed with RUN bun install)
  • Second review CI integration config: /tmp/cch-review-ci-integration-1777129283/ci_integration_config.log (2 passed, 19 passed)
  • Second review final checklist: /tmp/cch-review-second-fix-precommit-1777129308 (build, lint, lint:fix, typecheck, test all exit 0; 548 files, 5189 tests)
  • Oracle review: bg_e48f5f72; blocking findings fixed before PR.
  • GitHub Actions after first review-fix push: all checks passed.

Notes

  • The user requested develop, but this repository has no develop branch and project instructions specify PR target dev, so this PR targets dev.
  • No product behavior changes intended; changes are limited to tooling, CI, Docker install behavior, and test stability/configuration.
  • bun.lock / bun.lockb are intentionally ignored by this repository, so CI/Docker use non-frozen bun install and cache on package.json plus .bun-version instead of lockfiles.

Greptile Summary

This PR pins Bun to 1.3.10 via .bun-version, bumps @typescript/native-preview to the April 25 nightly, adds job-level timeouts and Bun/Next.js caches to all four CI workflows, switches to bun install (no lockfile) consistently across Docker and workflows, and tunes Vitest worker/concurrency/parallelism settings to reduce DB and Redis contention in stateful test suites.

The refactoring of vitest.config.ts to import shared helpers from tests/vitest.base.ts (rather than duplicating them) is a clean improvement. One concern: integration.config.ts now lists only 2 test files where it previously listed 12, so bun run test:integration silently skips auth, webhook, notification, and provider integration tests going forward.

Confidence Score: 5/5

Safe to merge; all changes are tooling and CI configuration with no product behavior impact.

No P0 or P1 findings. The single P2 (integration test scope reduction in bun run test:integration) is a coverage/discoverability concern but does not affect production code or CI pass/fail gates since those tests were already excluded from CI runs before this PR.

tests/configs/integration.config.ts — the pruned test file list may mislead developers running local integration tests.

Important Files Changed

Filename Overview
.bun-version Pins Bun runtime to 1.3.10 for reproducible CI setup.
.github/workflows/test.yml Adds job-level timeouts, Bun version pinning, Bun/Next.js caches, and switches integration-tests to use the config file rather than inline file paths.
.github/workflows/dev.yml Adds 90-minute job timeout, Bun version pinning via .bun-version, and a Bun package cache step.
.github/workflows/pr-check.yml Adds per-job and per-step timeouts, Bun version pinning, and a Bun package cache; also adds a 45-minute timeout to the Docker build job.
.github/workflows/release.yml Adds 120-minute job timeout, Bun version pinning, and a Bun package cache step (conditional on needs_bump or workflow_dispatch).
Dockerfile Drops bun.lockb copy and frozen install in favor of plain bun install; matches stated policy of not tracking lockfiles.
package.json Bumps @typescript/native-preview from 7.0.0-dev.20260321.1 to 7.0.0-dev.20260425.1 for faster type checking.
tests/vitest.base.ts Exports three new env-var parsers (parsePositiveInt, parseWorkerLimit, parseBoolean) and extends TestRunnerConfigOptions with maxWorkers, maxConcurrency, fileParallelism, and pool; adds teardownTimeout and slowTestThreshold wired to env vars.
vitest.config.ts Removes duplicated local helpers, imports them from vitest.base, adds teardownTimeout/slowTestThreshold, and switches maxWorkers to a CPU-proportional default capped at 8.
tests/configs/integration.config.ts Adds fileParallelism: false for DB safety, but removes 10 integration test suites (auth, webhook, notification, provider, API action tests) from the config, meaning bun run test:integration now covers only 2 files.
tests/configs/e2e.config.ts Adds testTimeout, hookTimeout, and fileParallelism: false to serialize E2E files and cap per-test time.
tests/configs/public-status.integration.config.ts Adds maxWorkers: 2 and fileParallelism: false to avoid Redis contention across the public-status integration suite.
tests/integration/public-status/config-publish.test.ts Adds mockLoggerInfo to the logger mock to prevent unhandled mock calls on logger.info.
tests/unit/public-status/config-publisher.test.ts Increases per-test timeout from default/20_000 to 40_000ms for four slow unit tests to prevent CI flakiness.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[push / PR] --> B{Workflow}
    B --> C[test.yml]
    B --> D[pr-check.yml]
    B --> E[dev.yml]
    B --> F[release.yml]

    C --> G[quality job\ntimeout: 15m]
    C --> H[unit-tests job\ntimeout: 15m]
    C --> I[integration-tests job\ntimeout: 25m]
    C --> J[api-tests job\ntimeout: 35m]

    G --> K[bun install\nno lockfile]
    H --> K
    I --> K
    J --> K

    K --> L[(Bun pkg cache\nhashFiles package.json + .bun-version)]

    I --> M[vitest run\n--config integration.config.ts\n2 test files\nfileParallelism: false]
    J --> N[bun run build\nNext.js cache]
    N --> O[vitest run\n--config e2e.config.ts\nfileParallelism: false]

    style M fill:#f9f,stroke:#c66
    style L fill:#bbf,stroke:#66c
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: tests/configs/integration.config.ts
Line: 8-11

Comment:
**Ten integration test suites dropped from `bun run test:integration`**

`auth`, `webhook-targets-crud`, `notification-bindings`, `provider-endpoint-sync-race`, `provider-endpoint-regression-742`, `user-5h-reset-flow`, `non-chat-endpoint-fallback-observability`, `users-actions`, `providers-actions`, `keys-actions`, and `my-usage-readonly` were all listed in the previous `integration.config.ts`. They are now omitted, so `bun run test:integration` (and any local pre-commit run that calls it) will silently skip those suites. Since CI was already only running the two usage-ledger files directly, those tests are now effectively never executed. Was this intentional? If so, a comment or a separate config/CI job that re-adds them (e.g., `tests/configs/stateful-api.integration.config.ts`) would help clarify the intent.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (3): Last reviewed commit: "ci: document no-lock install strategy" | Re-trigger Greptile

ding113 and others added 6 commits April 25, 2026 14:21
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

本次变更新增仓库根目录的 .bun-version(1.3.10),为多个 GitHub Actions 工作流与 Docker 构建引入作业/步骤超时和 Bun 缓存/版本固定,调整若干 Vitest 测试配置与测试超时,并更新少量测试用例与依赖版本。

Changes

Cohort / File(s) Summary
Bun 版本文件
\.bun-version
新增文件,内容 1.3.10,用于固定 Bun 运行时版本。
GitHub Actions 工作流
\.github/workflows/dev.yml, \.github/workflows/pr-check.yml, \.github/workflows/release.yml, \.github/workflows/test.yml
为多个 job/step 添加超时(8–120 分钟)、将 Bun setup 改为从 .bun-version 读取并新增 ~/.bun/install/cacheactions/cache@v4 缓存步骤;若干 bun install --frozen-lockfile 更改为 bun install,并添加缓存键基于 package.json.bun-version
Docker 构建
Dockerfile
deps 阶段不再复制 bun.lockb*,并将 bun install --frozen-lockfile 改为 bun install
依赖版本
package.json
devDependencies@typescript/native-preview7.0.0-dev.20260321.1 升级至 7.0.0-dev.20260425.1
Vitest 配置(运行时/全局)
tests/vitest.base.ts, vitest.config.ts
新增并导出解析工具:parsePositiveIntparseWorkerLimitparseBoolean;扩展 TestRunnerConfigOptions;将 vitest.config.ts 改为使用 CPU 衍生默认 maxWorkers,并新增 teardownTimeoutslowTestThreshold 配置。
Vitest 配置(各套件)
tests/configs/e2e.config.ts, tests/configs/integration.config.ts, tests/configs/public-status.integration.config.ts
为测试与钩子设置显式超时,禁用文件级并行(fileParallelism: false),限制 maxWorkers(如适用);集成配置调整了测试文件列表,新增 tests/integration/my-usage-imported-ledger.test.ts
测试用例调整
tests/integration/public-status/config-publish.test.ts, tests/unit/public-status/config-publisher.test.ts
为测试桩添加 logger.info mock;将若干单元测试 it(...) 的超时提升到 40_000 ms。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'ci: optimize test and build pipeline' directly summarizes the main changes, which include CI workflow optimization, test pipeline tuning, and build performance improvements across multiple workflow files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR描述详细阐述了变更内容,包括Bun版本固定、TypeScript更新、Vitest配置调优、CI工作流改进和Docker构建优化,与变更集内容高度相关。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/ci-test-chain-tsgo-beta-20260425

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the project to Bun 1.3.10, modifies Dockerfiles to use bun ci, and significantly enhances the Vitest test configuration by introducing environment variable support for timeouts, worker limits, and parallelism. The review feedback identifies critical issues in the Dockerfiles where bun ci will fail because the lockfile is no longer being copied into the image. Additionally, there is a recommendation to export shared helper functions in the test configuration to eliminate code duplication between the base and global Vitest configs.

Comment thread Dockerfile Outdated
Comment on lines +4 to +5
COPY package.json ./
RUN bun ci

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The command bun ci requires a lockfile (bun.lockb) to be present in the working directory to function correctly. However, the current COPY instruction only includes package.json. This will cause the Docker build to fail because bun ci cannot verify the dependencies against a lockfile.

Additionally, the PR description mentions making builds work "without tracked lockfiles". If the project does not track bun.lockb, bun ci is not the appropriate command; you should use bun install instead. If you do track the lockfile, ensure it is copied into the image.

COPY package.json bun.lockb* ./
RUN bun ci

Comment thread deploy/Dockerfile Outdated
Comment on lines +8 to +9
COPY package.json ./
RUN bun install
RUN bun ci

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the root Dockerfile, bun ci will fail here because the lockfile is not copied. Please ensure bun.lockb is included in the COPY command to allow bun ci to verify the installation.

COPY package.json bun.lockb* ./
RUN bun ci

Comment thread tests/vitest.base.ts Outdated
Comment on lines +33 to +43
function parsePositiveInt(value: string | undefined, fallback: number): number {
if (!value) return fallback;
const parsed = Number.parseInt(value, 10);
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
}

function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {
if (!value) return fallback;
if (/^\d+%$/.test(value)) return value;
return parsePositiveInt(value, typeof fallback === "number" ? fallback : 2);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The helper functions parsePositiveInt and parseWorkerLimit are duplicated in vitest.config.ts. To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider exporting these helpers from this base configuration file and importing them in vitest.config.ts instead of redefining them.

Suggested change
function parsePositiveInt(value: string | undefined, fallback: number): number {
if (!value) return fallback;
const parsed = Number.parseInt(value, 10);
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
}
function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {
if (!value) return fallback;
if (/^\d+%$/.test(value)) return value;
return parsePositiveInt(value, typeof fallback === "number" ? fallback : 2);
}
export function parsePositiveInt(value: string | undefined, fallback: number): number {
if (!value) return fallback;
const parsed = Number.parseInt(value, 10);
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
}
export function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {
if (!value) return fallback;
if (/^\d+%$/.test(value)) return value;
return parsePositiveInt(value, typeof fallback === "number" ? fallback : 2);
}

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
coderabbitai[bot]
coderabbitai Bot previously requested changes Apr 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (6)
vitest.config.ts (1)

9-24: tests/vitest.base.ts 实现重复,建议复用同一组解析助手

parsePositiveInt(Line 9-13)与 parseWorkerLimit(Line 15-19)已经在 tests/vitest.base.ts 中存在等价实现。两处重复后续只要任一处调整(例如对负数、0%、空白字符的处理)就会出现行为漂移。建议从 tests/vitest.base.ts 导出后在此处直接 import,defaultMaxWorkers 保留在本文件即可。

建议改造

tests/vitest.base.ts 中将解析助手改为导出:

-function parsePositiveInt(value: string | undefined, fallback: number): number {
+export function parsePositiveInt(value: string | undefined, fallback: number): number {
...
-function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {
+export function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {

vitest.config.ts 复用:

-import { sharedResolve } from "./tests/vitest.base";
+import { parsePositiveInt, parseWorkerLimit, sharedResolve } from "./tests/vitest.base";
@@
-function parsePositiveInt(value: string | undefined, fallback: number): number {
-  if (!value) return fallback;
-  const parsed = Number.parseInt(value, 10);
-  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
-}
-
-function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {
-  if (!value) return fallback;
-  if (/^\d+%$/.test(value)) return value;
-  return parsePositiveInt(value, typeof fallback === "number" ? fallback : 8);
-}
-
 function defaultMaxWorkers(): number {
   const workerBudget = Math.floor(availableParallelism() * 0.75);
   return Math.min(8, Math.max(2, workerBudget));
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vitest.config.ts` around lines 9 - 24, parsePositiveInt and parseWorkerLimit
duplicate helpers already implemented in tests/vitest.base.ts; remove these
local implementations and import the exported parsePositiveInt and
parseWorkerLimit from tests/vitest.base.ts to avoid divergent behavior, keeping
defaultMaxWorkers in this file unchanged; update any type expectations so
parseWorkerLimit's fallback typing matches its exported signature and replace
local calls to parsePositiveInt/parseWorkerLimit with the imported functions.
tests/vitest.base.ts (1)

33-48: LGTM,但与 vitest.config.ts 中的实现高度重复

parsePositiveIntparseWorkerLimit 同时存在于本文件与 vitest.config.ts(见该文件 Line 9-19)。建议把这三个解析助手集中导出(例如从本文件 export),让 vitest.config.ts 直接复用,避免后续两处实现漂移。具体重构建议放在 vitest.config.ts 的评论中。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/vitest.base.ts` around lines 33 - 48, The three helper functions
parsePositiveInt, parseWorkerLimit, and parseBoolean are duplicated in
vitest.config.ts; export them from this file and have vitest.config.ts import
and reuse them to avoid drift. Concretely, add named exports for
parsePositiveInt, parseWorkerLimit, and parseBoolean in this file and remove the
duplicate implementations from vitest.config.ts, replacing them with imports
that reference the exported symbols so both places use the single shared
implementation.
package.json (1)

125-125: 确保 @typescript/native-preview 版本在 bun.lock 中锁定

7.0.0-dev.20260425.1 已确认在 npm registry 上可解析。由于该版本属于每日发布的 dev tag,建议通过 bun.lock 锁定具体的包哈希,以保证团队成员和 CI/CD 环境中的构建可重现。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 125, package.json currently references
"@typescript/native-preview": "7.0.0-dev.20260425.1" but the bun.lock must pin
the exact package hash for reproducible builds; regenerate/ensure bun.lock
contains the resolved integrity by running bun install (or bun add
`@typescript/native-preview`@7.0.0-dev.20260425.1) locally and committing the
updated bun.lock, verifying the entry for "@typescript/native-preview" includes
the concrete lock/hash rather than only the version tag so CI and teammates get
the same artifact.
.github/workflows/pr-check.yml (1)

36-46: LGTM,附一点 cold-cache 风险提示

缓存与 bun ci 设置正确。Install dependencies 步骤 5 分钟限时对热缓存非常充裕;但首次跑(缓存 miss)+ 网络抖动情况下(npm registry 偶发延迟、平台特定二进制如 sharp 拉取等)可能逼近上限。如果后续观察到偶发超时,可以把这一步的 timeout-minutes 略放宽到 8–10,或保留现值并依赖 restore-keys 的 fallback。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-check.yml around lines 36 - 46, The workflow's "Install
dependencies" step sets timeout-minutes: 5 which may be too short on cache
misses or network/registry delays; update the "Install dependencies" step to
increase timeout-minutes to 8–10 (or make it configurable) so bun ci has more
time on cold-cache runs, and optionally document the reason near the step and
keep the existing cache/restore-keys logic unchanged to preserve hot-cache
performance.
tests/unit/public-status/config-publisher.test.ts (1)

119-119: 单元测试超时设置不一致

第 119、173 行超时被提升至 30_000,但第 278 行的同类用例仍保留 20_000,第 227、328 行则无显式覆盖(走基础配置默认值)。如果 30s 是为了应对 CI 慢盘/动态 import 抖动,建议统一所有用例(或抽到 vitest.base.tstestTimeout),避免某个用例在压力下偶发翻车而其它用例已被放宽。

另:这是单元测试文件(所有外部依赖均通过 vi.mock/vi.hoisted mock 掉),30s 超时偏长,可能掩盖未来真正的性能回归——可以在 CI 稳定后再评估是否回收到更小的值。

♻️ 建议统一为相同超时
-  }, 20_000);
+  }, 30_000);

(应用到第 278 行;或对所有四个用例去除显式超时,由 vitest.base.ts 集中管理)

Also applies to: 173-173, 278-278

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/public-status/config-publisher.test.ts` at line 119, Several unit
tests in this file use inconsistent per-test timeouts (e.g., the snippet "},
30_000);" appears at lines like 119 and 173 while other cases at 278 use 20_000
and some (227, 328) rely on the default); make them consistent by either (A)
setting the same timeout for all these tests to 30_000 (change the trailing "},
20_000);" occurrences and add "}, 30_000);" where missing) or (B) remove all
per-test timeout overrides in this file so they inherit the centralized
testTimeout from vitest.base.ts—apply the chosen approach to the test cases
referenced around lines 119, 173, 227, 278, and 328.
.github/workflows/test.yml (1)

220-226: 缩窄 Next.js 缓存 key 的 hashFiles 范围,提升命中率

hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx', 'next.config.*') 的广泛模式会扫描整个仓库,包括 tests/scripts/vitest.config.tsdrizzle.config.ts 等与 Next.js 构建无关的文件。任何 PR 修改这些文件都会导致主 key 失效,缓存命中率低下。

建议收敛到实际影响 Next.js 构建的文件:

♻️ 缩窄 hashFiles 范围
-          key: ${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx', 'next.config.*') }}
+          key: ${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}-${{ hashFiles('src/**/*.{js,jsx,ts,tsx}', 'next.config.ts', 'tsconfig.json', 'postcss.config.mjs') }}

这样只会在 src/ 目录下源代码、TypeScript 配置、Next.js 配置或样式配置有变化时更新 key,避免不相关的文件变更触发缓存失效。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/test.yml around lines 220 - 226, 当前使用的 hashFiles
范围过宽(hashFiles('**/*.js','**/*.jsx','**/*.ts','**/*.tsx','next.config.*'))会把仓库内不相关文件纳入
key,导致缓存命中率低;请在 .github/workflows/test.yml 中调整 actions/cache@v4 的
key/restore-keys,改为只对影响 Next.js 构建的文件取哈希(例如
src/**/*.{js,jsx,ts,tsx}、next.config.*、tsconfig.json、tailwind.config.*、postcss.config.*
等),保持 path 为 ${{ github.workspace }}/.next/cache 并同步更新 restore-keys 模式以匹配新
key,从而避免无关文件变更使缓存失效。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/dev.yml:
- Line 16: CI currently fails because the workflow's "bun ci" step requires a
lockfile but the repository lacks bun.lock or bun.lockb; generate the lockfile
locally with bun install (or bun generate-lockfile), ensure bun.lock or
bun.lockb is not ignored by .gitignore, add and commit the lockfile to the repo,
then push so the "bun ci" step in the workflow can run successfully.

In `@Dockerfile`:
- Around line 4-5: The Dockerfiles invoke "bun ci" but only COPY package.json
and the repo lacks bun.lock, so image builds fail; either generate and commit
bun.lock (run bun install locally), then update Dockerfile, deploy/Dockerfile
and deploy/Dockerfile.dev to COPY bun.lock (and package.json) before running bun
ci, or change the two failing files (Dockerfile and deploy/Dockerfile) to use
"bun install" instead of "bun ci" to avoid requiring a lockfile; ensure
deploy/Dockerfile.dev stays consistent if already using bun install.

---

Nitpick comments:
In @.github/workflows/pr-check.yml:
- Around line 36-46: The workflow's "Install dependencies" step sets
timeout-minutes: 5 which may be too short on cache misses or network/registry
delays; update the "Install dependencies" step to increase timeout-minutes to
8–10 (or make it configurable) so bun ci has more time on cold-cache runs, and
optionally document the reason near the step and keep the existing
cache/restore-keys logic unchanged to preserve hot-cache performance.

In @.github/workflows/test.yml:
- Around line 220-226: 当前使用的 hashFiles
范围过宽(hashFiles('**/*.js','**/*.jsx','**/*.ts','**/*.tsx','next.config.*'))会把仓库内不相关文件纳入
key,导致缓存命中率低;请在 .github/workflows/test.yml 中调整 actions/cache@v4 的
key/restore-keys,改为只对影响 Next.js 构建的文件取哈希(例如
src/**/*.{js,jsx,ts,tsx}、next.config.*、tsconfig.json、tailwind.config.*、postcss.config.*
等),保持 path 为 ${{ github.workspace }}/.next/cache 并同步更新 restore-keys 模式以匹配新
key,从而避免无关文件变更使缓存失效。

In `@package.json`:
- Line 125: package.json currently references "@typescript/native-preview":
"7.0.0-dev.20260425.1" but the bun.lock must pin the exact package hash for
reproducible builds; regenerate/ensure bun.lock contains the resolved integrity
by running bun install (or bun add
`@typescript/native-preview`@7.0.0-dev.20260425.1) locally and committing the
updated bun.lock, verifying the entry for "@typescript/native-preview" includes
the concrete lock/hash rather than only the version tag so CI and teammates get
the same artifact.

In `@tests/unit/public-status/config-publisher.test.ts`:
- Line 119: Several unit tests in this file use inconsistent per-test timeouts
(e.g., the snippet "}, 30_000);" appears at lines like 119 and 173 while other
cases at 278 use 20_000 and some (227, 328) rely on the default); make them
consistent by either (A) setting the same timeout for all these tests to 30_000
(change the trailing "}, 20_000);" occurrences and add "}, 30_000);" where
missing) or (B) remove all per-test timeout overrides in this file so they
inherit the centralized testTimeout from vitest.base.ts—apply the chosen
approach to the test cases referenced around lines 119, 173, 227, 278, and 328.

In `@tests/vitest.base.ts`:
- Around line 33-48: The three helper functions parsePositiveInt,
parseWorkerLimit, and parseBoolean are duplicated in vitest.config.ts; export
them from this file and have vitest.config.ts import and reuse them to avoid
drift. Concretely, add named exports for parsePositiveInt, parseWorkerLimit, and
parseBoolean in this file and remove the duplicate implementations from
vitest.config.ts, replacing them with imports that reference the exported
symbols so both places use the single shared implementation.

In `@vitest.config.ts`:
- Around line 9-24: parsePositiveInt and parseWorkerLimit duplicate helpers
already implemented in tests/vitest.base.ts; remove these local implementations
and import the exported parsePositiveInt and parseWorkerLimit from
tests/vitest.base.ts to avoid divergent behavior, keeping defaultMaxWorkers in
this file unchanged; update any type expectations so parseWorkerLimit's fallback
typing matches its exported signature and replace local calls to
parsePositiveInt/parseWorkerLimit with the imported functions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9011335-851b-4274-9f48-a7acb5245c82

📥 Commits

Reviewing files that changed from the base of the PR and between 1381474 and bc18638.

📒 Files selected for processing (15)
  • .bun-version
  • .github/workflows/dev.yml
  • .github/workflows/pr-check.yml
  • .github/workflows/release.yml
  • .github/workflows/test.yml
  • Dockerfile
  • deploy/Dockerfile
  • package.json
  • tests/configs/e2e.config.ts
  • tests/configs/integration.config.ts
  • tests/configs/public-status.integration.config.ts
  • tests/integration/public-status/config-publish.test.ts
  • tests/unit/public-status/config-publisher.test.ts
  • tests/vitest.base.ts
  • vitest.config.ts

Comment thread .github/workflows/dev.yml
jobs:
dev-build-deploy:
runs-on: ubuntu-latest
timeout-minutes: 90

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
fd -HI -t f '^bun\.lock$' -x ls -l {}
fd -HI -t f '^bun\.lockb$' -x ls -l {}

Repository: ding113/claude-code-hub

Length of output: 49


缺少 bun.lock 文件,导致工作流将在 bun ci 步骤失败

虽然工作流配置本身正确(Bun 版本锁定、缓存设置、超时设置合理),但仓库中未找到 bun.lockbun.lockb 文件。bun ci 命令需要 lockfile 存在且使用 --frozen-lockfile 标志,缺失时会直接失败。

需要先提交 bun.lock 文件至仓库,工作流才能正常运行。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/dev.yml at line 16, CI currently fails because the
workflow's "bun ci" step requires a lockfile but the repository lacks bun.lock
or bun.lockb; generate the lockfile locally with bun install (or bun
generate-lockfile), ensure bun.lock or bun.lockb is not ignored by .gitignore,
add and commit the lockfile to the repo, then push so the "bun ci" step in the
workflow can run successfully.

Comment thread Dockerfile Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc18638a3b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/workflows/pr-check.yml Outdated
- name: 📦 Install dependencies
run: bun install
timeout-minutes: 5
run: bun ci

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop using bun ci without a committed lockfile

This step now runs bun ci, but this repository does not commit bun.lock (no lockfile exists in this commit), and Bun’s CI/CD docs define bun ci as frozen-lockfile install intended for a committed lockfile. On fresh checkouts this can break dependency installation (or at least remove reproducibility guarantees), and the same pattern is now repeated across multiple workflows and Dockerfiles in this commit.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/pr-check.yml Outdated
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a non-empty cache key input for Bun cache

The cache key is derived from hashFiles('bun.lock'), but this repo does not track bun.lock; in GitHub Actions, hashFiles returns an empty string when no files match, so the key becomes effectively constant (<os>-bun-). That prevents key rotation when dependencies change and undermines the intended CI speedup because updated package cache contents are not saved under a new key.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

Comment thread Dockerfile Outdated
Comment on lines +4 to +5
COPY package.json ./
RUN bun ci

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Lockfile not copied — non-deterministic dependency resolution in Docker

bun ci (= bun install --frozen-lockfile) requires a lockfile to produce a reproducible install. Without copying bun.lock into the deps stage, Bun either errors or falls back to a regular install, meaning Docker images may resolve different package versions on each build. The CI workflows correctly reference bun.lock via hashFiles('bun.lock'), so the file is tracked — it should be COPY'd here.

Suggested change
COPY package.json ./
RUN bun ci
COPY package.json bun.lock ./
RUN bun ci
Prompt To Fix With AI
This is a comment left during a code review.
Path: Dockerfile
Line: 4-5

Comment:
**Lockfile not copied — non-deterministic dependency resolution in Docker**

`bun ci` (= `bun install --frozen-lockfile`) requires a lockfile to produce a reproducible install. Without copying `bun.lock` into the `deps` stage, Bun either errors or falls back to a regular install, meaning Docker images may resolve different package versions on each build. The CI workflows correctly reference `bun.lock` via `hashFiles('bun.lock')`, so the file is tracked — it should be COPY'd here.

```suggestion
COPY package.json bun.lock ./
RUN bun ci
```

How can I resolve this? If you propose a fix, please make it concise.

Comment thread deploy/Dockerfile Outdated
Comment on lines +8 to +9
COPY package.json ./
RUN bun install
RUN bun ci

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Lockfile not copied — non-deterministic dependency resolution in Docker

Same as the root Dockerfile: bun ci needs bun.lock present to enforce a frozen install. Without it, each Docker build may resolve package versions independently of what the lockfile pins. Since bun.lock is tracked in git (CI caches it via hashFiles('bun.lock')), it should be COPY'd before bun ci.

Suggested change
COPY package.json ./
RUN bun install
RUN bun ci
COPY package.json bun.lock ./
RUN bun ci
Prompt To Fix With AI
This is a comment left during a code review.
Path: deploy/Dockerfile
Line: 8-9

Comment:
**Lockfile not copied — non-deterministic dependency resolution in Docker**

Same as the root `Dockerfile`: `bun ci` needs `bun.lock` present to enforce a frozen install. Without it, each Docker build may resolve package versions independently of what the lockfile pins. Since `bun.lock` is tracked in git (CI caches it via `hashFiles('bun.lock')`), it should be COPY'd before `bun ci`.

```suggestion
COPY package.json bun.lock ./
RUN bun ci
```

How can I resolve this? If you propose a fix, please make it concise.

Comment thread vitest.config.ts Outdated
Comment on lines +15 to +19
function parseWorkerLimit(value: string | undefined, fallback: number | string): number | string {
if (!value) return fallback;
if (/^\d+%$/.test(value)) return value;
return parsePositiveInt(value, typeof fallback === "number" ? fallback : 8);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Duplicated helpers with diverging fallback constants

parsePositiveInt and parseWorkerLimit are now defined in both vitest.config.ts and tests/vitest.base.ts. The inner numeric fallback in parseWorkerLimit differs between the two files: 8 here vs 2 in vitest.base.ts. While neither call-site currently passes a string fallback (so the branch is effectively dead), the duplication will cause subtle confusion if the functions drift further. Consider exporting them from tests/vitest.base.ts and importing them here.

Prompt To Fix With AI
This is a comment left during a code review.
Path: vitest.config.ts
Line: 15-19

Comment:
**Duplicated helpers with diverging fallback constants**

`parsePositiveInt` and `parseWorkerLimit` are now defined in both `vitest.config.ts` and `tests/vitest.base.ts`. The inner numeric fallback in `parseWorkerLimit` differs between the two files: `8` here vs `2` in `vitest.base.ts`. While neither call-site currently passes a string fallback (so the branch is effectively dead), the duplication will cause subtle confusion if the functions drift further. Consider exporting them from `tests/vitest.base.ts` and importing them here.

How can I resolve this? If you propose a fix, please make it concise.

@github-actions github-actions Bot added the size/M Medium PR (< 500 lines) label Apr 25, 2026
Comment thread .github/workflows/test.yml Outdated
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] [PERFORMANCE-ISSUE] Bun cache key is effectively constant -- cache never refreshes when dependencies change

hashFiles('bun.lock') references a file that is not tracked in this repository. Since bun.lock does not exist at checkout time, hashFiles returns an empty string, making the primary cache key identical to the restore-key prefix (${{ runner.os }}-bun-). This means:

  1. First CI run: cache miss, cache saved with the constant key.
  2. All subsequent runs: exact key match (cache hit), the post-save step is skipped.
  3. When package.json changes (new deps), the stale cache is restored and never updated -- new packages are re-downloaded on every run.

The same issue appears in all four workflow files:

  • .github/workflows/test.yml (lines 34, 70, 135, 209)
  • .github/workflows/dev.yml (line 72)
  • .github/workflows/pr-check.yml (line 40)
  • .github/workflows/release.yml (line 209)

Suggested fix:

key: ${{ runner.os }}-bun-${{ hashFiles('package.json') }}

Using package.json ensures the cache key changes when dependencies are added/updated, triggering a cache miss and a fresh save. The restore-keys prefix match will still restore the old cache as a warm start.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

This PR optimizes CI/test pipelines by pinning Bun, adding caching and timeouts, tuning Vitest parallelism, and updating Dockerfiles. The changes are well-scoped to tooling with no product behavior changes. One medium-severity performance issue was identified.

PR Size: M

  • Lines changed: 191 (171 additions, 20 deletions)
  • Files changed: 15

Issues Found

Category Critical High Medium Low
Logic/Bugs 0 0 0 0
Security 0 0 0 0
Error Handling 0 0 0 0
Types 0 0 0 0
Comments/Docs 0 0 0 0
Tests 0 0 0 0
Performance 0 0 1 0

Medium Priority Issues (Should Fix)

  1. Ineffective Bun cache key across all 4 workflow files - hashFiles('bun.lock') references a file not tracked in this repository. Since bun.lock does not exist at checkout time, the hash is constant, making the cache key identical to the restore-key prefix. After the first CI run saves the cache, all subsequent runs get a cache hit and the cache is never refreshed when package.json dependencies change. Fix: replace hashFiles('bun.lock') with hashFiles('package.json') in all cache key definitions.

    Affected files:

    • .github/workflows/test.yml (lines 34, 70, 135, 209)
    • .github/workflows/dev.yml (line 72)
    • .github/workflows/pr-check.yml (line 40)
    • .github/workflows/release.yml (line 209)

    Note: The Next.js cache key in test.yml line 224 also includes hashFiles('bun.lock') but is partially effective since it also hashes source files (**/*.{js,jsx,ts,tsx}, next.config.*). The bun.lock component there is dead weight but not harmful.

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate (no new product features; test config changes are reasonable)
  • Code clarity - Good

Automated review by Claude AI

ding113 and others added 4 commits April 25, 2026 14:52
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions

Copy link
Copy Markdown
Contributor

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

coderabbitai[bot]
coderabbitai Bot previously requested changes Apr 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/test.yml:
- Around line 30-40: The CI currently runs bun install without a frozen lockfile
while bun.lock is ignored, risking non-reproducible builds; either commit
bun.lock, restore the --frozen-lockfile flag on the "Install dependencies" steps
(all occurrences of the step named "Install dependencies") and update the cache
key hashFiles(...) to include 'bun.lock', or if you intentionally omit the
lockfile document that decision in the PR description; apply the chosen fix for
every matching "Install dependencies" step (lines referenced in the review).
- Around line 146-152: The CI step that runs Vitest is passing two positional
test paths which filter and override the 13-file list in the
integration.config.ts testFiles; update the "Run integration tests" step so the
intended full suite runs: either remove the positional arguments (the two
entries "tests/integration/usage-ledger.test.ts" and
"tests/integration/my-usage-imported-ledger.test.ts") so Vitest uses testFiles
from --config, or deliberately trim integration.config.ts.testFiles to only
include those two if you only want them in this job, or add separate CI jobs
that explicitly run the other 11 tests (e.g., create jobs that run vitest with
those specific file paths or configs) to ensure no declared tests are silently
skipped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1964ee31-50fd-41dd-8893-9e5ce4890ccc

📥 Commits

Reviewing files that changed from the base of the PR and between 4f3b4cd and d2523cf.

📒 Files selected for processing (8)
  • .github/workflows/dev.yml
  • .github/workflows/pr-check.yml
  • .github/workflows/release.yml
  • .github/workflows/test.yml
  • Dockerfile
  • tests/unit/public-status/config-publisher.test.ts
  • tests/vitest.base.ts
  • vitest.config.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • Dockerfile
  • .github/workflows/pr-check.yml
  • .github/workflows/dev.yml
  • tests/unit/public-status/config-publisher.test.ts
  • .github/workflows/release.yml
  • vitest.config.ts
  • tests/vitest.base.ts

Comment thread .github/workflows/test.yml
Comment thread .github/workflows/test.yml
ding113 and others added 2 commits April 25, 2026 15:06
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions

Copy link
Copy Markdown
Contributor

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

@ding113

ding113 commented Apr 25, 2026

Copy link
Copy Markdown
Owner Author

All actionable review comments have been addressed and re-verified. The remaining CodeRabbit inline comments now show "Addressed in commits 44a2d6d to 6529bdd", and all required checks are passing. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

@ding113: Sure! I'll kick off a fresh review of the PR now.


🧠 Learnings used
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-24T02:25:05.625Z
Learning: Before committing, always run pre-commit checklist: bun run build, bun run lint, bun run lint:fix, bun run typecheck, bun run test
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ding113
ding113 dismissed stale reviews from coderabbitai[bot] and coderabbitai[bot] April 25, 2026 15:23

Dismissed stale CodeRabbit changes-requested review after all actionable comments were addressed in commits 44a2d6d to 6529bdd and required checks passed.

@ding113
ding113 merged commit b0bf3ea into dev Apr 25, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Claude Code Hub Roadmap Apr 25, 2026
@github-actions github-actions Bot mentioned this pull request Apr 26, 2026
@ding113
ding113 deleted the perf/ci-test-chain-tsgo-beta-20260425 branch May 13, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:deployment size/M Medium PR (< 500 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant