ci(coverage): measure frontend coverage with v8 and backend branch coverage (#5407)

* ci(coverage): measure frontend coverage with v8 and backend branch coverage

The frontend had no coverage measurement, and the backend's line-only
report counts a one-sided `if` as covered when its body never runs.

- Add @vitest/coverage-v8 and `npm run test:coverage`. Its include lists
  every source file, so a file no test imports reports 0% instead of
  disappearing. Generated types, locales, tokens, test utilities,
  stories, fixtures and play helpers are excluded.
- Frontend Checks runs tests with coverage and uploads the cobertura
  report to GitHub code coverage as code-coverage/vitest, mirroring
  pytest.yml: a separate job holds code-quality: write and fork PRs skip
  the upload.
- Turn on branch coverage in backend/.coveragerc.

Baseline on master: 407 test files pass; frontend lines 63.3%, branches
55.3%. The app project alone (no stories) gives 61.4% lines, so stories
add about two points.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4iK9WRvZqdTHiRc9gY

* ci(coverage): include JavaScript sources in the frontend coverage report

The two audio worklets (gmeAudioWorklet.js, pico8AudioWorklet.js) are
production code that the `{ts,vue}` glob left out of the report, so they
now show at 0% instead of being omitted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH5s4iK9WRvZqdTHiRc9gY

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Dornan
2026-10-30 10:49:20 -05:00
committed by GitHub
parent 63faff8883
commit fec6e494f7
6 changed files with 163 additions and 1 deletions

View File

@@ -42,9 +42,45 @@ jobs:
working-directory: frontend
- name: Run tests (vitest, includes Storybook play() and a11y tests)
run: npm test
run: npm run test:coverage
working-directory: frontend
# Fork PRs can't upload.
- name: Upload coverage report artifact
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: frontend-coverage-report
path: frontend/coverage/cobertura-coverage.xml
if-no-files-found: error
retention-days: 1
# A separate job keeps code-quality: write away from the job that runs the PR's code.
upload-coverage:
needs: test
if: ${{ !cancelled() && needs.test.result == 'success' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
# actionlint doesn't know the code-quality scope yet.
# trunk-ignore(actionlint)
code-quality: write
steps:
- name: Download coverage report
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: frontend-coverage-report
# Best-effort while GitHub code coverage is in preview; errors still show as annotations.
- name: Upload coverage to GitHub
uses: actions/upload-code-coverage@2b21a77928be8d5168c2b9581a67f2adbebacc52 # v1.4.4
with:
file: cobertura-coverage.xml
language: TypeScript
label: code-coverage/vitest
fail-on-error: false
build:
runs-on: ubuntu-24.04
timeout-minutes: 15