Skip to content

Commit b5d4ea0

Browse files
authored
ci: measure coverage, and drop tests other tests already cover (#13)
* ci: measure test coverage of the hooks claude plugin test measures no coverage, and the hooks run in the engine's own environment, where no coverage tool sees them. So npm run coverage instruments a copy of the plugin with istanbul, has each test read the counts back through a __coverage command when it ends, and reports them as text and lcov. CI prints the table in the job summary. * test: drop the tests other tests already cover Coverage per test showed 11 tests whose lines the rest run too: the pane listing per surface, the session press, the full replay, the kept-token and CLAUDE_CONFIG_DIR connects, /leverage with no token, the subagent step, the network retry and logout. Line coverage goes from 62.18% to 61.69%. The token-safety tests stay though others run their lines: they are the only ones that check a token is never kept where others can read it. * ci: comment the coverage table on each PR One comment per PR, edited on each push. Skipped for forks, whose token cannot comment.
1 parent 73ec5f9 commit b5d4ea0

8 files changed

Lines changed: 2917 additions & 241 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
permissions:
88
contents: read
9+
pull-requests: write
910

1011
concurrency:
1112
group: ci-${{ github.ref }}
@@ -23,3 +24,15 @@ jobs:
2324
- run: npm install -g @anthropic-ai/claude-code@2.1.286
2425
- run: claude plugin validate .
2526
- run: claude plugin test .
27+
- run: npm ci
28+
- name: Coverage
29+
run: |
30+
{ echo '### Coverage'; echo '```'; npm run -s coverage; echo '```'; } |
31+
tee "$RUNNER_TEMP/coverage.md"
32+
cat "$RUNNER_TEMP/coverage.md" >> "$GITHUB_STEP_SUMMARY"
33+
# One comment per PR, updated on each push. A fork's token cannot comment.
34+
- name: Comment coverage on the PR
35+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
run: gh pr comment ${{ github.event.pull_request.number }} --body-file "$RUNNER_TEMP/coverage.md" --edit-last --create-if-none

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
.DS_Store
33
*.log
44
.claude/
5+
coverage/

0 commit comments

Comments
 (0)