Skip to content

ci: add test, build and locale-parity checks - #15

Merged
dabeecao merged 2 commits into
mainfrom
ci/frontend-checks
Nov 22, 2026
Merged

dabeecao merged 2 commits into
mainfrom
ci/frontend-checks

Conversation

@dabeecao

Copy link
Copy Markdown
Owner

Adds CI so regressions are caught on pull requests instead of at release time. The frontend repo currently has no workflow at all.

Jobs

Job What it does
Test npm ci + npm test. Skips cleanly when package.json has no test script yet, so this workflow is usable before #14 lands.
Build assets Installs Bun (build.js shells out to it for the Tailwind CLI step), runs node build.js, then scripts/check-assets.js.
Locale parity scripts/check-locales.js.

build.js calls execFile('bun', ...) for Tailwind, so the build job installs Bun via oven-sh/setup-bun@v2. Without it the job would fail on the runner.

Helper scripts (runnable locally)

scripts/check-locales.js — every locale must have exactly the same key set as en.json, and top-level keys must stay sorted A-Z.

This matters because build.js only re-sorts a locale file when its keys change (if (addedKeys.length > 0 || removedKeys.length > 0)). A file that drifts out of order without a key change stays unsorted forever.

scripts/check-assets.js — every generated asset referenced by a template must exist after a build. Only build outputs (*.min.js, *.min.css, *.min.json, tailwind.css) are asserted; committed sources are skipped.

This catches a real class of bug: adding <script src="/static/js/foo.min.js"> to a template without the build producing it — which would be a silent 404 in production, invisible until someone opens devtools.

Both print GitHub ::error file=...::message annotations, so failures point at the exact file in the PR diff.

Also fixes an existing issue

static/locales/vi.json was the only locale whose top-level keys were not sorted A-Z (child_toggle_note before child_modal_warning, copy before copied). Sorted here so the new check passes from day one.

The diff is a pure reorder — verified by deep comparison that the parsed content is byte-for-byte identical, 706 keys before and after.

Verification

All three jobs run green locally:

test    → SKIP (no test script on main yet — expected)
build   → Build complete. / Asset check passed: 4 generated asset reference(s) resolved.
locales → All 8 locales share 706 keys, sorted A-Z.

Each check was also probed by deliberately breaking things, to confirm it fails when it should:

Probe Result
Remove one key from ja.json fails, names the missing key
Point a template at ghost.min.js fails, names file + template
Swap two keys in km.json fails, names the file

Not covered

  • No linting/formatting step (there is no linter configured in this repo; happy to add one if you want).
  • No link/accessibility check on templates.
  • The build job downloads pdf.js from cdnjs (build.js), so it needs network; it does not verify a checksum of those downloads. Worth pinning a SHA-256 later, mirroring what the backend Dockerfile already does for yt-dlp.

Adds a GitHub Actions workflow so regressions are caught on pull requests
instead of at release time.

Jobs:
- Test: npm ci + npm test. Skips cleanly when package.json has no "test"
  script yet, so the workflow is usable before the first suite lands.
- Build assets: installs Bun (build.js shells out to it for the Tailwind
  CLI step), runs node build.js, then scripts/check-assets.js.
- Locale parity: scripts/check-locales.js.

Two helper scripts, runnable locally:
- scripts/check-locales.js verifies every locale has exactly the same key
  set as en.json and that top-level keys stay sorted A-Z. build.js only
  re-sorts a file when its keys change, so an unsorted file would otherwise
  persist forever.
- scripts/check-assets.js verifies every generated asset referenced by a
  template was actually produced by the build. Only build outputs
  (*.min.js, *.min.css, *.min.json, tailwind.css) are asserted; committed
  sources are skipped.

Also sorts static/locales/vi.json, the only locale whose top-level keys
were not A-Z. Content is unchanged (verified by deep comparison); the
diff is a pure reorder.
bun.lock was gitignored, so every install resolved dependencies fresh. CI
(and any fresh clone) therefore pulled @fortawesome/fontawesome-free 7.3.1
instead of the 7.2.0 this tree was built against.

7.3.1 no longer ships the webfonts/ directory, so the CSS build emitted no
font files and web/static/webfonts/ was never created. That broke the
backend, which go:embed's that path:

    main.go:53:29: pattern web/static/webfonts: no matching files found

The failure surfaced in the Go build, pointing at Go rather than at the
frontend dependency bump — which is what made it worth fixing properly
instead of papering over.

Changes:
- Commit bun.lock (26 KB) and drop it from .gitignore.
- build-frontend.sh / .bat / .ps1 use `bun install --frozen-lockfile`,
  falling back to an unpinned install with a warning if the lockfile is
  absent.
- The CI build job gains a "Verify go:embed prerequisites" step asserting
  every path main.go embeds still exists after a build, with an error that
  names the likely cause. This catches the same class of breakage in the
  frontend repo, where it can actually be understood.
- CI jobs now install with bun + --frozen-lockfile rather than npm, so the
  lockfile that pins the build is the one that is used.

Verified: a clean `bun install --frozen-lockfile` resolves Font Awesome
7.2.0 with 4 woff2 files, the build recreates static/webfonts/, and the
backend then passes `go vet ./...` and `go build`.
@dabeecao
dabeecao merged commit bfd9acd into main Nov 22, 2026
3 checks passed
@dabeecao
dabeecao deleted the ci/frontend-checks branch November 22, 2026 14:32
dabeecao added a commit that referenced this pull request Nov 22, 2026
* Revert "build: emit font assets without a parent-traversal assetNames (#16)"

This reverts commit 02b1954.

* Revert "ci: add test, build and locale-parity checks (#15)"

This reverts commit bfd9acd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant