Skip to content

Commit 9a6b621

Browse files
hswclaude
andcommitted
add(ci): run the Worker's type-check and assertions
A proposal, and deliberately the last commit: adding a gate to this repo's CI is the maintainer's call, so drop this one and everything before it still stands. The one line elsewhere that names the job — a sentence in CLAUDE.md — is inside this commit for that reason. mcp/ is a separate package with its own lockfile, so the build job never touched it: the root `npm ci` doesn't install it, and both eslint.config.js and .prettierignore exclude mcp/ deliberately. Its type-check had never run in CI at all. A second job keeps a Worker failure reading distinctly from a site-build failure. The build job is unchanged. build:data is an explicit step: src/index.ts imports the generated, gitignored src/data.json, so `tsc --noEmit` fails with TS2307 on a clean checkout. pretest would regenerate it, but relying on that makes step order quietly load-bearing. The runner is pinned to 22.15 rather than the build job's 22: ts-resolve-hook .mjs needs node:module's registerHooks, added there. `22` resolves to something newer today, so this only matters the day it doesn't — and the failure it prevents is a link-time missing export with nothing to point at. Not added to .githooks/pre-commit: that fires on every commit, almost none of which touch mcp/, and it would need this package's separate dependency tree. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFy2qPKK546AEFGixoxYoE
1 parent 71c1253 commit 9a6b621

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,44 @@ jobs:
5151
name: dist
5252
path: dist
5353
retention-days: 7
54+
55+
# The MCP Worker in mcp/ is a separate package with its own lockfile, so the
56+
# job above never touches it: the root `npm ci` doesn't install it, and both
57+
# eslint.config.js and .prettierignore exclude mcp/ deliberately. Its
58+
# type-check had never run in CI either. A separate job so a Worker failure
59+
# reads distinctly from a site-build failure.
60+
mcp:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v7
64+
65+
- name: Set up Node.js
66+
uses: actions/setup-node@v7
67+
with:
68+
# ts-resolve-hook.mjs needs registerHooks, added in 22.15. The `22`
69+
# the job above uses would satisfy that today, but pinning the floor
70+
# here keeps a runner rolling back from failing at link time with
71+
# nothing to point at.
72+
node-version: 22.15
73+
cache: npm
74+
cache-dependency-path: mcp/package-lock.json
75+
76+
- name: Install MCP dependencies
77+
run: npm ci
78+
working-directory: mcp
79+
80+
# src/data.json is generated rather than committed, and src/index.ts
81+
# imports it — so tsc cannot resolve the module until the manifest
82+
# exists. `npm test` regenerates it as well (pretest), but the
83+
# type-check has no such hook and runs first.
84+
- name: Build data manifest
85+
run: npm run build:data
86+
working-directory: mcp
87+
88+
- name: Type-check (tsc)
89+
run: npm run typecheck
90+
working-directory: mcp
91+
92+
- name: Test (node:assert)
93+
run: npm test
94+
working-directory: mcp

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ npm run assets # regenerate icons + OG image
116116

117117
`predev` and `prebuild` run `scripts/generate-assets.mjs` automatically.
118118

119-
The Worker in `mcp/` has its own scripts, run from there: `npm test`, `npm run typecheck`, `npm run dev` (wrangler on 31338). On a fresh clone run `npm run build:data` first — `src/data.json` is generated, so `typecheck` fails with `TS2307` without it; `pretest` covers `npm test`.
119+
The Worker in `mcp/` has its own scripts, run from there: `npm test`, `npm run typecheck`, `npm run dev` (wrangler on 31338). On a fresh clone run `npm run build:data` first — `src/data.json` is generated, so `typecheck` fails with `TS2307` without it; `pretest` covers `npm test`. CI's `mcp` job runs the three in that order.
120120

121121
**Pre-commit gate.** A tracked git hook at `.githooks/pre-commit` runs `npm run lint` and `npm run format:check` on every `git commit`; `core.hooksPath` is pointed at `.githooks/` by the `prepare` script on `npm install` (no husky). The same two checks run in CI (`ci.yml`). Run them before committing so the hook passes; `prettier --write .` fixes formatting. Bypass only in a genuine emergency with `git commit --no-verify`. The Worker's assertions are deliberately **not** in the hook: `mcp/` has its own dependency tree that most contributors never install, and running them would rewrite the generated `mcp/src/data.json` on every unrelated commit. CI is the gate for that.
122122

0 commit comments

Comments
 (0)