-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add test coverage reporting with GitHub Pages deployment #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b5a03ee
dcb482d
cc4c412
0c7bf74
be9259e
9873b82
57c9daf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||
| name: CI | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| push: | ||||||||||
|
||||||||||
| push: | |
| push: | |
| branches: | |
| - main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Permissions pages: write and id-token: write are set at workflow level but only needed by deploy-coverage job. Consider moving these to job-level permissions for better security (principle of least privilege).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/ci.yaml, line 13:
<comment>Permissions `pages: write` and `id-token: write` are set at workflow level but only needed by `deploy-coverage` job. Consider moving these to job-level permissions for better security (principle of least privilege).</comment>
<file context>
@@ -9,6 +10,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
+permissions:
+ contents: read
+ pages: write
</file context>
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pages: write and id-token: write permissions are defined at the workflow level (lines 15-16), which grants these permissions to all jobs including the ci job. However, these permissions are only needed for the deploy-coverage job.
According to GitHub Actions security best practices, permissions should be scoped as narrowly as possible. Consider moving these permissions to the job level:
permissions:
contents: read
jobs:
ci:
runs-on: ubuntu-latest
# ... steps ...
deploy-coverage:
if: github.ref == 'refs/heads/main'
needs: ci
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# ... steps ...This ensures the ci job only has contents: read permission, reducing the potential impact if that job is compromised.
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The conditional test execution creates two different test paths: pnpm test for non-main branches (line 42) and pnpm run coverage for main branch (line 46).
The coverage script uses vitest run --coverage which runs tests in non-watch mode. However, the test script runs vitest which may behave differently. This could potentially lead to inconsistent test execution between PRs and main branch deployments.
To ensure consistency, consider:
- Using
vitest run(without coverage) for PRs, andvitest run --coveragefor main branch, OR - Documenting that the
testscript behavior is intentionally different
Looking at package.json line 30, pnpm test runs vitest which will run in non-watch mode in CI due to vitest.config.ts setting watch: false. This is actually consistent, so no change is needed. However, for clarity, consider using vitest run explicitly in the test script to make the intent clear.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,9 +27,8 @@ | |||||||
| "lint:knip": "knip", | ||||||||
| "preinstall": "npx only-allow pnpm", | ||||||||
| "prepack": "npm pkg delete scripts.preinstall && pnpm run build", | ||||||||
|
||||||||
| "prepack": "npm pkg delete scripts.preinstall && pnpm run build", | |
| "prepack": "npm pkg delete scripts.preinstall && pnpm run build", | |
| // Note: Vitest only runs test files matching *.spec.ts or *.test.ts in all workspace packages. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: This
push:trigger without branch filtering will cause duplicate CI runs for PRs to main. Consider adding a branch filter (e.g.,branches: [main]) or usingpull_requestonly for feature branches.Alternatively, if you want CI to run on all pushes, you could skip the push-triggered run when a PR exists using a condition.
Prompt for AI agents