Setup precommit hooks and check for coverage levels in CI.#163
Open
Setup precommit hooks and check for coverage levels in CI.#163
Conversation
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.
Purpose
Addresses #162
Tighten the local feedback loop for routine maintenance. Today, lint, type, and test failures only surface after pushing — sometimes only after a PR review reveals a red check. There are no local hooks. Coverage is tracked (since the vitest baseline in #130) but no threshold is enforced, so coverage can drift downward silently between refactors.
This PR adds the mainstream three-tier check pattern (pre-commit / pre-push / CI), shifting routine failures left to local hooks, and wires a coverage-threshold check into CI so coverage can only ratchet upward.
Approach
Three tiers of checks:
lint-stagedagainst staged files only — ESLint--fix+ Prettier--writeon.ts/.tsx, Prettier--writeon.md/.json/.yml/.yaml. Sub-second on typical diffs.yarn test— the same lint + types + unit checks CI runs. Mirrors CI exactly so failures show up locally before the push lands.Coverage thresholdstep (yarn test:coverage) using vitest's built-incoverage.thresholds. Initial threshold values are zero placeholders — runningyarn test:coverage:ratchetlifts them to the current observed baseline using vitest's--coverage.thresholds.autoUpdateflag. Once seeded, coverage can only go up; CI fails on a drop.Tooling: Husky 9 + lint-staged (de-facto JavaScript standards). Hooks install automatically via the
preparescript — no per-contributor setup. Documented inCONTRIBUTING.md(new "Hooks and feedback loop" section) andREADME.md(CI section refreshed; the stale hardcoded coverage table replaced with a pointer tovite.config.mjsas the live source of truth).Bundled minor cleanups: added
prettieras a direct devDependency (it was previously a missing peer ofeslint-plugin-prettier); added atest:coverage:ratchetscript for ratcheting thresholds; updated the README's "Coverage is not collected in CI today" line, which this PR makes obsolete.Testing
Manual verification (no new unit tests; this is pure tooling):
yarn install—prepare: huskyruns,.husky/_/infrastructure created.git commitinvokedyarn lint-staged, the file was auto-fixed, the commit landed cleanly.yarn testran end-to-end. Confirmed that introducing a deliberate test failure blocks the push with non-zero exit.yarn test:coverage— confirmed vitest produces the coverage report and applies the (currently zero) thresholds without failing.yarn test:coverage:ratchet— confirmed vitest rewrites thethresholds:block invite.config.mjswith the observed values.testjob afterUnit tests. Verified the YAML parses cleanly.Visual changes
N/A — pure tooling. No UI, render, or build-output changes.
Checklist
protvista-uniprotv3/v5 compatibility section) are flagged as a separate v5 docs PR.yarn test:coverage:ratcheteither before merge or in a follow-up commit lifts them to the current baseline.