Back to the notes

Notes

Put the audit in the Dockerfile: no green, no image

Once the three checks live inside the step that produces the artifact, there is no room left for making it green first: each one has to name the broken page within seconds.

The pipeline for this site has exactly two roles: CI pushes an image to the registry, ArgoCD converges that image into a running Pod. Everything in between sits in one place - the RUN npm run audit line inside the build stage of the Dockerfile. That position is not an accident: the only step nobody skips is the step that produces the artifact. The CI trigger has paths-ignore (a docs-only push never runs at all), and a bare npm run build only tells you there are 42 files, not that one of them has a 61-character title.

Each of the three checks has its own remit. Contrastreads src/styles/tokens.css and the four theme arms, scoring 22 foreground/background pairings under each - 88 checks - against the values that survive the cascade rather than the token names. The site checkreads dist/, not src/, because correctness is defined by the file a browser receives: unique titles inside a 60-character budget, descriptions inside 155, canonical and hreflang resolving to files that actually exist, a parseable sitemap and JSON-LD, landmarks with exactly one h1, a skip link, and no dead links and no leftover serialization artifacts in the copy. The no-JS checkstrips every script tag from each page and demands byte-identical visible text, then sweeps the shipped CSS for rules that hide content without a JavaScript-only or state-only qualifier. typecheck deliberately stays outside the gate: it is a developer command, whereas the gate has to be a verdict about the emitted site.

Three real failures, each of which made a check stricter. First, a stale assertion is worse than none. After the information architecture was folded into a single notes stream, the site check was still asserting the old routes and the hard-coded no-JS list still carried six deleted pages, so all-passed really meant 24 hand-picked names. The fix was not to trim the assertions but to make the no-JS check walk dist/: coverage went from 24 curated routes to all 42 actual ones, and a page can no longer be missing from coverage. Second, a regex that stops at the first item. In a YAML block list every item must carry its own newline; keeping the newline outside the repeated group parses only the first tag per file, which silently mis-aligns every topic page against its posts. Third, a CSP hash mismatch does not raise an error. The script simply never runs, so the page looks like a plain static document. Hashes must therefore come from the build, and be reconciled against the inline scripts actually present in dist/: two executable scripts need to be declared, while the 22 application/ld+json blocks are non-executable and outside CSP remit.

The cost is concrete: about three seconds on every build, and all three checks have to be green for every copy change. The gain is that there is no such thing as a green-but-broken deploy - if any check fails there is no image, no new tag in the registry, and nothing for ArgoCD to converge, so deployed can only ever mean checked. Three rules carry over to any gate I write now: assert against the real artifact, make every failure name its page, and never lower a threshold to buy a green run.