Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "yarn"
node-version: '24'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
Expand All @@ -33,6 +33,9 @@ jobs:
- name: Unit tests
run: yarn test:unit

- name: Coverage threshold
run: yarn test:coverage

build:
name: Build
needs: test
Expand All @@ -42,8 +45,8 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "yarn"
node-version: '24'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn test
20 changes: 19 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ yarn test:coverage # Generate coverage report
- Test edge cases and error conditions.
- Aim to maintain or improve code coverage.

## Hooks and feedback loop

The repository ships local git hooks that mirror the checks CI runs, so failures show up before you push rather than after. The hooks install automatically when you run `yarn install` (via the `prepare` script in `package.json`); no separate setup step is required.

There are three tiers, ordered from fast to thorough:

| Tier | When it runs | What it does |
| ---------- | ------------------ | ------------------------------------------------------------------------------------------------------ |
| Pre-commit | Every `git commit` | `lint-staged` — ESLint `--fix` and Prettier `--write` on staged files only. Sub-second on small diffs. |
| Pre-push | Every `git push` | `yarn test` — lint, type check, and unit tests across the whole tree. The same checks CI runs. |
| CI | Every push and PR | The pre-push checks plus a coverage threshold check (`yarn test:coverage`). |

The hooks are not gatekeepers — CI is. If a hook is incorrectly blocking a legitimate push (mid-rebase, work-in-progress on a side branch, etc.), use `git push --no-verify` to bypass. CI will still run the full set when the change reaches a PR.

If a hook is gating a legitimate change for an unclear reason, run the underlying command directly to see the full output: `yarn lint-staged` for pre-commit, `yarn test` for pre-push. The hooks themselves are short shell scripts in `.husky/` — open them if you need to inspect what's running.

Coverage thresholds live in `vite.config.mjs` under `test.coverage.thresholds`. They follow a ratchet pattern: thresholds are seeded at the current baseline so coverage can only go up. If a refactor genuinely needs to drop coverage (e.g., removing tested code), update the thresholds in the same change.

## Code Style

- ESLint and Prettier are used for formatting (automated in CI).
Expand Down Expand Up @@ -158,7 +176,7 @@ Note that office hours are not recorded.
| ---------- | ------------- | ----------- |
| 2026-02-27 | 15.30 - 16.30 | ✅ Complete |
| 2026-03-27 | 10.30 - 11.30 | ✅ Complete |
| 2026-04-24 | 15.30 - 16.30 | Planned |
| 2026-04-24 | 15.30 - 16.30 | ✅ Complete |
| 2026-05-29 | 10.30 - 11.30 | Planned |
| 2026-06-26 | 15.30 - 16.30 | Planned |
| 2026-07-31 | 10.30 - 11.30 | Planned |
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,11 @@ Coverage output is for local use only and is not committed. Open `coverage/index

### Continuous integration

Every push and pull request runs the same three steps as `yarn test` via [`.github/workflows/test-and-deploy.yml`](./.github/workflows/test-and-deploy.yml): `yarn test:lint`, `yarn test:types`, and `yarn test:unit`, under Node 24 on `ubuntu-latest`. A separate `build` job runs `yarn build` (and, on `main`, `yarn build:demo`) and deploys the demo to GitHub Pages. Coverage is not collected in CI today — run `yarn test:coverage` locally when you need a coverage signal.
Every push and pull request runs the same checks as `yarn test` via [`.github/workflows/test-and-deploy.yml`](./.github/workflows/test-and-deploy.yml): `yarn test:lint`, `yarn test:types`, `yarn test:unit`, plus `yarn test:coverage` against the thresholds defined in `vite.config.mjs`. All steps run under Node 24 on `ubuntu-latest`. A separate `build` job runs `yarn build` (and, on `main`, `yarn build:demo`) and deploys the demo to GitHub Pages.

### Coverage

Captured 2026-04-20 via `yarn test:coverage` (v8 instrumentation, 29 tests across 3 spec files):

| Metric | Coverage |
| ---------- | -------- |
| Statements | 10.33% |
| Branches | 5.99% |
| Functions | 13.19% |
| Lines | 9.66% |
Coverage thresholds live in [`vite.config.mjs`](./vite.config.mjs) under `test.coverage.thresholds` and follow a ratchet pattern — they only ever go up. CI fails if a change drops coverage below the recorded threshold. Run `yarn test:coverage` locally to see the current numbers, or `yarn test:coverage:ratchet` to lift the thresholds to match the latest run (commit the resulting `vite.config.mjs` change in the same PR as the coverage improvement).

## Configuration

Expand Down
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@
"test:unit": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"test:coverage:ratchet": "vitest run --coverage --coverage.thresholds.autoUpdate",
"test": "npm-run-all --continue-on-error test:lint test:types test:unit",
"clear-cdn-cache": "./scripts/clearCDNcaches.sh"
"clear-cdn-cache": "./scripts/clearCDNcaches.sh",
"prepare": "husky"
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{md,json,yml,yaml}": [
"prettier --write"
]
},
"main": "dist/protvista-uniprot.js",
"module": "dist/protvista-uniprot.mjs",
Expand Down Expand Up @@ -61,8 +72,11 @@
"eslint-plugin-no-unsanitized": "4.1.5",
"eslint-plugin-prettier": "5.5.5",
"globals": "17.5.0",
"husky": "9.1.7",
"jsdom": "29.0.2",
"lint-staged": "15.5.2",
"npm-run-all": "4.1.5",
"prettier": "3.8.3",
"rollup-plugin-visualizer": "7.0.1",
"svg-inline-loader": "0.8.2",
"typescript": "6.0.3",
Expand Down
1 change: 1 addition & 0 deletions src/protvista-uniprot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,3 +780,4 @@ class ProtvistaUniprot extends LitElement {
}

export default ProtvistaUniprot;
// touched
12 changes: 12 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ export default defineConfig({
// Style template strings.
'src/styles/**',
],
// Ratchet pattern: thresholds are seeded at the current baseline so
// coverage can only go up. Initial values below are placeholders —
// run `yarn test:coverage` once on `next`, read the four numbers off
// the summary table, and update these to ~1–2% below the observed
// baseline. Until then CI will not fail on coverage drop. See the
// "Hooks and feedback loop" section in CONTRIBUTING.md.
thresholds: {
lines: 11.13,
functions: 14.08,
branches: 7.54,
statements: 12.01,
},
},
},
});
Loading
Loading