coverage: publish a dashboard-readable coverage-floor.json - #825
coverage: publish a dashboard-readable coverage-floor.json#825fpigeonjr wants to merge 3 commits into
Conversation
- Add coverage-floor.json (repo root), a single-percentage ratchet
({ "lines": 90 }) the cross-repo quality dashboard can read directly.
- scripts/coverage-report.mjs now defaults its threshold to that floor
file instead of a hardcoded --threshold=90 literal, so there's one
source of truth for the number (CLI/--env overrides still work).
- Commit coverage/component-coverage.json (was fully gitignored); its
new lines key mirrors the floor's single-percentage shape. The
markdown report stays CI-artifact-only.
- Add scripts/check-coverage-workflow.mjs + npm run test:coverage-workflow
to assert the floor's shape, that the JSON stays committed, and that
CI guards against a stale snapshot.
- test.yml: add a 'push: branches: [master]' trigger (the suite
previously only ran on pull_request against the default branch) and
a git diff --exit-code guard after the coverage step.
- AGENTS.md: document the new floor-file mechanism.
Closes #822
|
Component / Story Coverage Report✅ 100% coverage (52 / 52 stories have Playwright specs) — threshold: 90% Summary
Coverage metricFor this SCSS-only library, "coverage" means every Storybook story (.stories.js) Uncovered storiesAll stories are covered 🎉 Covered stories
|
There was a problem hiding this comment.
🟡 Changes recommended
The new coverage workflow contract check is missing key validations (integer floor and tracked report) and the committed JSON output should be stabilized to avoid CI drift/flakiness.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR publishes a dashboard-readable component/story coverage result by committing a machine-readable coverage snapshot (coverage/component-coverage.json) and introducing a repo-root coverage-floor.json ratchet as the single source of truth for the default threshold, while also ensuring the main CI workflow runs on pushes to master.
Changes:
- Add
coverage-floor.jsonand updatescripts/coverage-report.mjsto default its threshold from that ratchet (with CLI/env overrides preserved). - Commit
coverage/component-coverage.jsonand adjust.gitignore/CI to keep the committed snapshot from drifting. - Add
scripts/check-coverage-workflow.mjsplus a new CI step to validate the coverage contract and fixtest.ymlto trigger onpushtomaster.
File summaries
| File | Description |
|---|---|
| scripts/coverage-report.mjs | Reads default threshold from coverage-floor.json and writes a committed JSON report including a lines key for dashboards. |
| scripts/check-coverage-workflow.mjs | New contract-check script validating floor/report/CI expectations for component-story coverage publishing. |
| package.json | Adds test:coverage-workflow and removes the hardcoded --threshold=90 from the coverage script. |
| coverage/component-coverage.json | New committed machine-readable snapshot of current story/spec coverage results. |
| coverage-floor.json | New committed “ratchet” floor file with { "lines": 90 } as the default threshold source. |
| AGENTS.md | Updates documentation to describe the new floor-file mechanism and coverage workflow validation. |
| .gitignore | Keeps coverage/ ignored except for committed coverage/component-coverage.json. |
| .github/workflows/test.yml | Runs on push to master, validates the new coverage workflow contract, and guards against stale committed coverage output. |
Review details
- Files reviewed: 6/8 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- check-coverage-workflow.mjs: require coverage-floor.json's lines to be an integer (Number.isInteger), not just a number in range \u2014 a fractional value would pass this check but coverage-report.mjs's own integer check would then fail npm run coverage. - check-coverage-workflow.mjs: git check-ignore only proves the ignore rules allow the file; add a git ls-files --error-unmatch assertion so the check actually proves coverage/component-coverage.json is tracked, not just unignored. - coverage-report.mjs: sort the stories array by path before writing the JSON report. readdirSync's traversal order isn't guaranteed stable across filesystems, which could produce false-positive diffs against the committed snapshot across environments.
…verage-floor-json-for-the-component-st # Conflicts: # AGENTS.md
What
Publishes a dashboard-readable coverage result for the component/story coverage check, and fixes
test.yml's trigger to also run on push tomaster.coverage-floor.json(repo root) — a single-percentage ratchet ({ "lines": 90 }) the cross-repo angular-upgrade-dashboard can read directly, adapted to this repo's story-smoke metric rather than the 4-key{statements, branches, functions, lines}shape used by line-coverage repos (ngx-uswds,sam-ui-elements) — that shape doesn't map cleanly onto story coverage.scripts/coverage-report.mjsnow defaults its threshold to that floor file instead of a hardcoded--threshold=90literal inpackage.json, so there's a single source of truth for the number (--threshold=<n>/COVERAGE_THRESHOLDstill work as explicit overrides).coverage/component-coverage.json(previously fully gitignored as a CI-only artifact). Its newlineskey mirrors the floor.coverage/component-coverage.mdand the rest ofcoverage/stay CI-artifact-only.scripts/check-coverage-workflow.mjs(npm run test:coverage-workflow) asserting: the floor file's shape/range, that the coverage script doesn't hardcode a threshold, that the JSON stays committed while the markdown stays ignored, and that CI guards against a stale snapshot.test.yml: adds agit diff --exit-codeguard after the coverage step so a committed report can't silently drift from a freshly generated one, and addspush: branches: [master]to the trigger — previously the coverage/a11y/lint suite only ran onpull_request, so the default branch'sstatusCheckRollupreported green from CodeQL alone even though the rest of the suite had never run against it.AGENTS.md's coverage section to describe the new floor-file mechanism.Motivation and Context
sam-stylesenforces 90% component/story coverage in CI but committed no machine-readable result, so the dashboard rendered this repo's coverage cell as "not published." This makes the check's result visible to the dashboard while keeping the metric honest to what this repo actually measures (story-smoke coverage, not line coverage).Closes #822
How to Test
All of the above pass locally on Node 24 (per
.nvmrc).Screenshots
N/A — CI/tooling changes only.
Checklist
gh-822-...)<scope>: <subject>conventionnpm test,npm run compile:check,npm run test:security-workflow,npm run test:coverage-workflow,npm run coverage,npm run test:storybook,npm run test:a11y,npm run format:check, andnpm run build:storybookall pass locallyValidate coverage workflow/ freshness-guard steps intest.yml