Skip to content

Commit 04f8ca7

Browse files
rekmarksclaude
andauthored
refactor(coverage): Replace per-package thresholds with GitHub Actions workflow (#759)
## Summary - Remove per-package coverage thresholds from `vitest.config.ts` - These had become completely meaningless since we stopped running coverage in CI. - Add GitHub Actions workflow that runs coverage on push to main and PRs - Deploy HTML coverage report to GitHub Pages - Post PR comments with coverage diff and link to full report ## Changes - Removed 130+ lines of per-package thresholds from `vitest.config.ts` - Deleted `scripts/reset-coverage-thresholds.sh` and pretest hook - Created `.github/workflows/coverage-report.yml` ## Coverage Report - **PR comments**: Coverage diff posted automatically, with link to HTML report for `main` - **HTML report**: https://metamask.github.io/ocap-kernel/coverage/ (after first merge) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Introduces CI-driven coverage and removes brittle per-package thresholds. > > - Adds `coverage-report.yml` workflow: downloads coverage artifact, publishes HTML to GitHub Pages on `main`, fetches baseline on PRs, posts coverage diff via `davelosert/vitest-coverage-report-action`, and comments a link to the full report > - Wires workflow into `main.yml` after `lint-build-test`; skips on `merge_group` > - Updates `lint-build-test.yml` to run tests with `--coverage` only on Node `24.x` and upload the `coverage/` artifact > - Simplifies testing scripts in `package.json`: removes `pretest` hook, `test:ci`, and `scripts/reset-coverage-thresholds.sh`; keeps `test` as `vitest run` > - Updates `vitest.config.ts` coverage reporters to include `json-summary` and removes the large per-package `thresholds` block > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 3f9517a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0ede4ff commit 04f8ca7

File tree

6 files changed

+98
-153
lines changed

6 files changed

+98
-153
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Coverage Report
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
report:
8+
name: Report
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v6
16+
17+
- name: Download coverage artifact
18+
uses: actions/download-artifact@v7
19+
with:
20+
name: coverage
21+
path: coverage/
22+
23+
# On push to main, deploy HTML coverage report to GitHub Pages
24+
- name: Deploy coverage to GitHub Pages
25+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
26+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./coverage
30+
destination_dir: coverage
31+
32+
# On PRs, fetch baseline coverage from GitHub Pages
33+
- name: Fetch baseline coverage from GitHub Pages
34+
if: github.event_name == 'pull_request'
35+
run: |
36+
mkdir -p coverage-base
37+
curl -fsSL https://metamask.github.io/ocap-kernel/coverage/coverage-summary.json \
38+
-o coverage-base/coverage-summary.json || { echo "No baseline coverage found"; exit 1; }
39+
40+
- name: Post coverage report
41+
if: github.event_name == 'pull_request'
42+
uses: davelosert/vitest-coverage-report-action@5b6122e3a819a3be7b27fc961b7faafb3bf00e4d
43+
with:
44+
json-summary-path: coverage/coverage-summary.json
45+
json-final-path: coverage/coverage-final.json
46+
json-summary-compare-path: coverage-base/coverage-summary.json
47+
file-coverage-mode: changes
48+
49+
- name: Post coverage report link
50+
if: github.event_name == 'pull_request'
51+
uses: actions/github-script@v8
52+
with:
53+
script: |
54+
const marker = '<!-- coverage-report-link -->';
55+
const body = `${marker}\n📊 [View full HTML coverage report for \`main\`](https://metamask.github.io/ocap-kernel/coverage/)`;
56+
57+
const { data: comments } = await github.rest.issues.listComments({
58+
issue_number: context.issue.number,
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
});
62+
63+
const existing = comments.find(c => c.body?.includes(marker));
64+
65+
if (existing) {
66+
await github.rest.issues.updateComment({
67+
comment_id: existing.id,
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
body,
71+
});
72+
} else {
73+
await github.rest.issues.createComment({
74+
issue_number: context.issue.number,
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
body,
78+
});
79+
}

.github/workflows/lint-build-test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ jobs:
108108
env:
109109
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
110110
- run: yarn build
111-
- run: yarn test:ci
111+
- run: "yarn test --coverage=${{ matrix.node-version == '24.x' && 'true' || 'false' }}"
112+
- name: Upload coverage artifact
113+
if: ${{ matrix.node-version == '24.x' }}
114+
uses: actions/upload-artifact@v6
115+
with:
116+
name: coverage
117+
path: coverage/
118+
retention-days: 7
112119
- name: Require clean working directory
113120
shell: bash
114121
run: |

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ jobs:
5858
needs: check-workflows
5959
uses: ./.github/workflows/lint-build-test.yml
6060

61+
coverage-report:
62+
name: Coverage report
63+
needs: lint-build-test
64+
if: github.event_name != 'merge_group'
65+
uses: ./.github/workflows/coverage-report.yml
66+
permissions:
67+
contents: write
68+
pull-requests: write
69+
6170
is-release:
6271
name: Determine whether this is a release merge commit
6372
needs: lint-build-test

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '**/*.yml' '!**/CHANGELOG.old.md' '!.yarnrc.yml' '!CLAUDE.md' '!merged-packages/**' --ignore-path .gitignore --log-level error",
2828
"postinstall": "simple-git-hooks && yarn rebuild:native",
2929
"prepack": "./scripts/prepack.sh",
30-
"pretest": "bash scripts/reset-coverage-thresholds.sh",
3130
"rebuild:native": "./scripts/rebuild-native.sh",
32-
"test": "yarn pretest && vitest run",
33-
"test:ci": "vitest run --coverage false",
31+
"test": "vitest run",
3432
"test:dev": "turbo run test:dev",
3533
"test:dev:quiet": "turbo run test:dev:quiet --output-logs=errors-only",
3634
"test:e2e": "yarn workspaces foreach --all run test:e2e",

scripts/reset-coverage-thresholds.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

vitest.config.ts

Lines changed: 1 addition & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default defineConfig({
4949
coverage: {
5050
enabled: true,
5151
provider: 'v8',
52-
reporter: ['text', 'json', 'html'],
52+
reporter: ['text', 'json', 'json-summary', 'html'],
5353
reportsDirectory: './coverage',
5454
include: ['**/src/**/*.{ts,tsx}'],
5555
exclude: [
@@ -60,135 +60,6 @@ export default defineConfig({
6060
'**/*.{test,spec}.{ts,tsx,js,jsx}',
6161
path.join(import.meta.dirname, './packages/brow-2-brow/**'),
6262
],
63-
thresholds: {
64-
autoUpdate: true,
65-
'packages/cli/**': {
66-
statements: 52.32,
67-
functions: 53.57,
68-
branches: 68.88,
69-
lines: 52.63,
70-
},
71-
'packages/create-package/**': {
72-
statements: 100,
73-
functions: 100,
74-
branches: 100,
75-
lines: 100,
76-
},
77-
'packages/extension/**': {
78-
statements: 1.29,
79-
functions: 0,
80-
branches: 0,
81-
lines: 1.31,
82-
},
83-
'packages/kernel-agents/**': {
84-
statements: 88.16,
85-
functions: 80,
86-
branches: 75.38,
87-
lines: 88.13,
88-
},
89-
'packages/kernel-browser-runtime/**': {
90-
statements: 84.31,
91-
functions: 78.3,
92-
branches: 81.81,
93-
lines: 84.55,
94-
},
95-
'packages/kernel-errors/**': {
96-
statements: 99.24,
97-
functions: 97.29,
98-
branches: 96,
99-
lines: 99.21,
100-
},
101-
'packages/kernel-language-model-service/**': {
102-
statements: 99,
103-
functions: 100,
104-
branches: 94.11,
105-
lines: 98.97,
106-
},
107-
'packages/kernel-platforms/**': {
108-
statements: 99.28,
109-
functions: 100,
110-
branches: 91.89,
111-
lines: 99.26,
112-
},
113-
'packages/kernel-rpc-methods/**': {
114-
statements: 100,
115-
functions: 100,
116-
branches: 100,
117-
lines: 100,
118-
},
119-
'packages/kernel-shims/**': {
120-
statements: 0,
121-
functions: 0,
122-
branches: 0,
123-
lines: 0,
124-
},
125-
'packages/kernel-store/**': {
126-
statements: 98.37,
127-
functions: 100,
128-
branches: 91.42,
129-
lines: 98.36,
130-
},
131-
'packages/kernel-ui/**': {
132-
statements: 95.03,
133-
functions: 95.83,
134-
branches: 87.53,
135-
lines: 95.11,
136-
},
137-
'packages/kernel-utils/**': {
138-
statements: 100,
139-
functions: 100,
140-
branches: 100,
141-
lines: 100,
142-
},
143-
'packages/logger/**': {
144-
statements: 98.66,
145-
functions: 96.66,
146-
branches: 97.36,
147-
lines: 100,
148-
},
149-
'packages/nodejs/**': {
150-
statements: 86.84,
151-
functions: 83.33,
152-
branches: 87.09,
153-
lines: 87.61,
154-
},
155-
'packages/nodejs-test-workers/**': {
156-
statements: 23.52,
157-
functions: 25,
158-
branches: 25,
159-
lines: 25,
160-
},
161-
'packages/ocap-kernel/**': {
162-
statements: 94.05,
163-
functions: 96,
164-
branches: 86.51,
165-
lines: 94.06,
166-
},
167-
'packages/omnium-gatherum/**': {
168-
statements: 4.16,
169-
functions: 4.54,
170-
branches: 0,
171-
lines: 4.22,
172-
},
173-
'packages/remote-iterables/**': {
174-
statements: 100,
175-
functions: 100,
176-
branches: 100,
177-
lines: 100,
178-
},
179-
'packages/streams/**': {
180-
statements: 100,
181-
functions: 100,
182-
branches: 100,
183-
lines: 100,
184-
},
185-
'packages/template-package/**': {
186-
statements: 100,
187-
functions: 100,
188-
branches: 100,
189-
lines: 100,
190-
},
191-
},
19263
},
19364
},
19465
});

0 commit comments

Comments
 (0)