chore(test): カバレッジ計測の母数を整備する (#1038)#1047
Conversation
- 共通 coverage 設定モジュール (vitest.coverage.shared.ts) を追加 - フロント: src/types/ の型のみファイルと App.tsx を exclude - admin: i18n JSON とエントリポイントを exclude - 全ワークスペースの vitest.config に coverage 設定を追加 - server/mcp・server/hocuspocus に @vitest/coverage-v8 を追加 - bun run test:coverage で全ワークスペースの計測を実行可能に - CI: 各 job で coverage を計測・アップロード
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds shared Vitest V8 coverage helpers, applies them to frontend/packages/servers, introduces a workspace coverage runner script, updates root test:coverage, and modifies CI to run coverage per workspace and upload per-workspace coverage artifacts. ChangesMonorepo-Wide Coverage Configuration Consolidation
Sequence Diagram(s)sequenceDiagram
participant CI as CI Workflow
participant RootScript as run-workspace-coverage.mjs
participant Workspace as Workspace<br/>(admin/shared/ui/claude)
participant ServerWS as Server Workspace<br/>(api/mcp/hocuspocus)
CI->>RootScript: npm run test:coverage
RootScript->>RootScript: parse --with-servers flag
RootScript->>Workspace: for each frontend workspace
Workspace->>Workspace: bunx vitest run --coverage
Workspace->>Workspace: load vitest.config + createCoverageConfig
Workspace->>Workspace: generate coverage report
alt with --with-servers
RootScript->>ServerWS: for each server workspace
ServerWS->>ServerWS: bunx vitest run --coverage
ServerWS->>ServerWS: load vitest.config + createCoverageConfig
ServerWS->>ServerWS: generate coverage report
end
RootScript-->>CI: exit 0 if all pass
CI->>CI: upload coverage artifacts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request standardizes Vitest coverage configurations across the monorepo workspaces by introducing a shared helper createCoverageConfig in vitest.coverage.shared.ts and updating workspace-specific configurations. It also adds a workspace coverage runner script (scripts/run-workspace-coverage.mjs) and updates package scripts and lockfiles accordingly. Feedback on the changes highlights potential execution failures on Windows when using spawnSync directly with bun or bunx without a shell, recommending the use of shell: true on Windows and adding proper error handling for spawn failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function run(label, command, cwd) { | ||
| console.log(`\n=== Coverage: ${label} ===\n`); | ||
| const result = spawnSync("bunx", command, { | ||
| cwd, | ||
| stdio: "inherit", | ||
| env: process.env, | ||
| }); | ||
| if (result.status !== 0) { | ||
| process.exit(result.status ?? 1); | ||
| } | ||
| } |
There was a problem hiding this comment.
Windows環境において、bun や bunx などのコマンドを spawnSync で直接実行すると、シェル経由でないために ENOENT エラーが発生して実行に失敗することがあります。また、コマンドの起動自体に失敗した場合(result.error が存在する場合)、エラー内容がコンソールに出力されず、終了コード 1 でサイレントに終了してしまいます。\n\nこれを防ぐために、Windows環境では shell: true を有効にし、result.error が存在する場合はエラー内容を出力するように改善することを推奨します。
function run(label, command, cwd) {
console.log("\\n=== Coverage: \${label} ===\\n");
const result = spawnSync("bunx", command, {
cwd,
stdio: "inherit",
env: process.env,
shell: process.platform === "win32",
});
if (result.error) {
console.error(result.error);
process.exit(1);
}
if (result.status !== 0) {
process.exit(result.status ?? 1);
}
}| if (workspace.preInstall) { | ||
| console.log(`\n--- Installing dependencies for ${workspace.name} ---\n`); | ||
| const install = spawnSync("bun", ["install", "--frozen-lockfile"], { | ||
| cwd, | ||
| stdio: "inherit", | ||
| env: process.env, | ||
| }); | ||
| if (install.status !== 0) { | ||
| process.exit(install.status ?? 1); | ||
| } | ||
| } |
There was a problem hiding this comment.
依存関係のインストール処理(bun install)においても、Windows環境での実行失敗を防ぐために shell: true を有効にし、起動失敗時のエラーハンドリング(install.error の出力)を追加することを推奨します。
if (workspace.preInstall) {
console.log("\\n--- Installing dependencies for \${workspace.name} ---\\n");
const install = spawnSync("bun", ["install", "--frozen-lockfile"], {
cwd,
stdio: "inherit",
env: process.env,
shell: process.platform === "win32",
});
if (install.error) {
console.error(install.error);
process.exit(1);
}
if (install.status !== 0) {
process.exit(install.status ?? 1);
}
}
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d40d41ada8
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^25.3.3", | ||
| "@vitest/coverage-v8": "4.0.18", |
There was a problem hiding this comment.
Align coverage-v8 with Vitest in MCP tests
In the fresh server/mcp install used by the changed mcp-test workflow, the lockfile resolves vitest to 4.1.4 while this new provider is pinned to 4.0.18; @vitest/coverage-v8@4.0.18 declares an exact peer on vitest@4.0.18, so bun run test:coverage is now exercising a mismatched Vitest/provider pair. Pin both packages to the same patch (or update the lockfile so they resolve together) before enabling coverage in CI.
Useful? React with 👍 / 👎.
| "devDependencies": { | ||
| "@types/node": "^25.3.2", | ||
| "@types/pg": "^8.16.0", | ||
| "@vitest/coverage-v8": "4.0.18", |
There was a problem hiding this comment.
Align coverage-v8 with Vitest in Hocuspocus tests
The changed Hocuspocus CI path now runs bun run test:coverage, but this newly added provider is pinned to 4.0.18 while server/hocuspocus/bun.lock resolves vitest to 4.1.2. Because the coverage provider has an exact Vitest peer for its own patch version, fresh installs will run coverage with an unsupported provider/runtime combination; keep the two Vitest packages on the same version before making coverage mandatory.
Useful? React with 👍 / 👎.
- server/mcp・server/hocuspocus の vitest を 4.0.18 に固定(coverage-v8 と一致) - run-workspace-coverage.mjs: Windows 向け shell 有効化と spawn 失敗時のエラー出力
Align server/mcp vitest and @vitest/coverage-v8 to 4.1.4 after develop bump.
概要
カバレッジ数値の母数から、実行不能・テスト対象外のファイルを除外し、全ワークスペースで
--coverageが動作するよう整備しました。テストコードの追加はありません(設定のみの変更)。Closes #1038
変更点
フロントエンド (
vite.config.ts)src/types/の型のみファイル 9 件を exclude(ai.ts・storage.tsは関数・型ガードを含むため残す)src/App.tsxを excludeadmin (
admin/vitest.config.ts)src/i18n/locales/**(i18n JSON)とmain.tsx/App.tsxを excludeワークスペース coverage 設定の統一
vitest.coverage.shared.tsで provider / reporter / 共通 exclude を共通化vitest.config.tsに coverage 設定を追加server/mcp・server/hocuspocusに@vitest/coverage-v8を追加scripts/run-workspace-coverage.mjs+bun run test:coverageでローカル一括計測CI
testjob: ルート配下ワークスペースの coverage を計測(重複回避のため server/* は各専用 job)api-test/mcp-test/hocuspocus-test:--coverage実行 + レポート artifact アップロードpackages/ui
components/*.tsxを母数から除外(自前実装の hooks / lib / sidebar / resizable のみ計測)整備後の基準値(2026-06-11)
※ 型定義・JSON・エントリポイント除外により、以前より正確な母数になっています。admin / packages/ui は明示的 include により未テストの自前コードも母数に含まれるため、旧基準値より低く見える場合があります。
テスト
bun run test:coverage(全ワークスペース、--with-servers付き)がエラーなく完了関連
Summary by CodeRabbit