ci: report frontend test coverage on pull requests#10273
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Coverage Report for ./frontend
File CoverageNo changed files found. |
Contributor
There was a problem hiding this comment.
No issues found across 6 files
Architecture diagram
sequenceDiagram
participant Dev as Developer (PR)
participant GHA as GitHub Actions (test_fe.yaml)
participant Turbo as Turbo (monorepo runner)
participant Vitest as Vitest w/ Coverage
participant FS as Coverage Files (coverage/*.json)
participant ReportAction as vitest-coverage-report-action
participant GH_API as GitHub API (PR Comment)
Note over Dev,GH_API: PR Coverage Report Flow
Dev->>GHA: Push PR / update branch
GHA->>GHA: Trigger test_frontend job
Note over GHA: permissions: pull-requests: write
GHA->>Turbo: NEW: pnpm turbo test:coverage
Turbo->>Turbo: dependsOn: ["build"] (cached or fresh)
Turbo->>Vitest: vitest run --coverage
Note over Vitest: Coverage only runs with --coverage flag (opt-in)
Vitest->>FS: Write coverage/coverage-summary.json, coverage-final.json, etc.
Note over Vitest: reportOnFailure: true → written even on test failure
alt Tests pass or fail (always())
GHA->>ReportAction: NEW: Run davelosert/vitest-coverage-report-action
Note over ReportAction: continue-on-error: true
ReportAction->>FS: Read coverage JSON files
FS-->>ReportAction: summary & final coverage data
alt Fork PR (GITHUB_TOKEN read-only)
ReportAction->>GH_API: POST PR comment
GH_API-->>ReportAction: 403 Forbidden
Note over ReportAction: continue-on-error → check not marked red
else Non-fork PR (GITHUB_TOKEN write)
ReportAction->>GH_API: POST PR comment
GH_API-->>ReportAction: 201 Created
Note over GH_API: Coverage report appears on PR
end
end
Note over GHA: Optional: Summarize typecheck failure (unchanged)
Contributor
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.15-dev55 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Frontend test coverage was never measured or reported anywhere. The backend already publishes coverage via Codecov (
test_be.yaml); per maintainer decision the frontend gets PR comments only — no Codecov wiring for the frontend. This lands as part of the marimo-team engineering-excellence initiative to make code-health signals visible on every PR.What was added
frontend/vitest.config.ts— acoverageblock (v8 provider,include: ["src/**"],reportOnFailure: true, reporterstext, html, json-summary, json). It is opt-in:enabledis left unset so coverage only runs when--coverageis passed. This matches the pattern used across the org's codemirror repos.frontend/package.json— newtest:coveragescript (vitest run --coverage) and dev dep@vitest/coverage-v8pinned to3.2.4to exactly match the lockedvitest(avoids a peer-dependency mismatch). Lockfile updated (additive only).turbo.json— atest:coveragetask mirroringtest(dependsOn: ["build"],outputs: ["coverage/**"])..github/workflows/test_fe.yaml— the test step now runspnpm turbo test:coverage, and a SHA-pinneddavelosert/vitest-coverage-report-action@…v2step posts the coverage comment. Thetest_frontendjob gainspull-requests: write.frontend/.gitignore— ignorecoverage/.Design choice: coverage in CI only
pnpm test/pnpm turbo testare unchanged — they still run plainvitest, so local runs and the default CI test path keep their current speed and behavior. Coverage instrumentation (which is not free on a repo this size) is gated behind the explicit--coverageflag via the separatetest:coveragescript, which CI invokes.reportOnFailure: truemeans the comment still appears when tests fail.Fork-PR handling
marimo gets many PRs from forks, where
GITHUB_TOKENis downgraded to read-only and posting a comment 403s. The report step usesif: always()+continue-on-error: trueso external contributors' checks never go red because of the comment (same pattern just adopted in marimo-lsp#634).Local verification
pnpm install— clean; only@vitest/coverage-v8(+ its transitive deps) added to the lockfile;pnpm dedupe --checkpasses.frontend/on a subset (vitest run --coverage src/utils/__tests__/arrays.test.ts) — the full frontend suite is too slow to run to completion locally, so a subset was used to validate wiring and output path.coverage/coverage-summary.jsonandcoverage/coverage-final.jsonland infrontend/coverage/— exactly where the workflow points (working-directory: ./frontend+coverage/coverage-summary.json, which the action resolves viapath.resolve).oxlintandoxfmtclean on the changed config; git tree clean (coverage/is now ignored).Scope: only
test_fe.yaml, the vitest/turbo config,package.json(+lockfile), and.gitignore. Backend workflows and Codecov config are untouched.