Fail CI when a Stati 2 build falls back

A broken template still exits with 0, and a misspelled include leaves nothing in the page to find. The build log has all of it.

SNP 152 #B21 Filed stati ci

shell
#!/usr/bin/env bash
# scripts/check-build.sh: build, then fail on what Stati 2 only logs
set -o pipefail

npm run build 2>&1 | tee build.log || exit 1

# The config, a layout or an include that failed, and names that found no template
if grep -E "Falling back to default configuration|No layout template found|Error rendering |no template at|names no template" build.log; then
  echo "Stati fell back to something, see above" >&2
  exit 1
fi

if grep -rl --include='*.html' "<!-- Error rendering " dist; then
  echo "A template failed to render in the pages above" >&2
  exit 1
fi
What went wrong What the log says What the page gets
The config didn't load Falling back to default configuration. "My Stati Site" and http://localhost:3000 links
The layout threw Error rendering site/blog/layout.eta for /blog/hello: … a bare fallback document
An include threw Error rendering site/partials/card.eta for /blog/hello: … <!-- Error rendering site/partials/card.eta: … -->
stati.include() named no template stati.include('partials/crad'): no template at … nothing where the include was
stati.layout() named no template stati.layout('bsae'): no template at … the layout's HTML, with no <html> or <head>
A front matter layout typo … names no template; using site/blog/layout.eta. the folder's usual layout

Every one of them exits with 0. The dev server stops on the broken templates and the unknown names with its error overlay, so most of these turn up while you work, but CI only ever sees the build.

In Stati 2 the log is the check that matters, because a misspelled name leaves nothing to find in dist. The dist grep is for pages served from the cache: they aren't rendered, so they log nothing, but the comment from an include that threw is still in their HTML. If CI keeps the build cache between runs, add --force to the build so the log covers every page.

In the Stati docs: Include and layout errors, Template fallback and Partial build success.