.PHONY: build test test-modcache test-vet test-fmt test-build test-go test-spacing test-browser # CGO_ENABLED=0 for the same reason sheets-core sets it: nothing here # should grow a cgo dependency by accident. estilo has no cgo-driven # store of its own; this is a floor, not a workaround. build: CGO_ENABLED=0 go build ./... # The gate, split into named targets so CI can report them individually # (.amadan/ci.d calls these one at a time, each its own step). `make # test` runs exactly the same five things in the same order, so the # local gate and CI stay ONE definition rather than two lists that # drift apart. Debugging CI is running `make test`. # # Order is cheapest-and-fastest first: vet and gofmt are near-instant, # build catches compile errors before time is spent on tests, and # go test — which includes the prefix-rule tripwire (internal/lint) # and the theme's gates (token set, contrast, accent goldens) — runs last. # test-modcache goes first: nothing after it means anything if the # dependencies on disk are not the ones go.sum names. test: test-modcache test-vet test-fmt test-build test-go test-spacing # Checks the module cache holds exactly what go.sum names, and re-fetches # any module Go reports as modified: it removes the exact directory or zip # go mod verify names (so a module path with capitals, which lives at an # escaped directory name, is removed too) and downloads again. Anything # verify reports that is not a modified file is left alone, and the final # verify still fails on it. Written down because of # 2026-09-29: a CI runner's copy of rastrillo v0.23.0 had lost # sessions/migrations/, so `go vet` failed on main and every branch alike # for a reason no commit here could fix. The cache is a cache; a damaged # entry is removed and downloaded again, never trusted. test-modcache: @out=$$(go mod verify 2>&1) && { echo "$$out"; exit 0; }; \ echo "$$out"; \ for p in $$(echo "$$out" | awk -F'[()]' '/(dir|zip) has been modified \(/ { print $$2 }'); do \ echo "removing damaged $$p"; \ if [ -d "$$p" ]; then chmod -R u+w "$$p" 2>/dev/null; rm -rf "$$p"; \ else rm -f "$$p" "$${p%.zip}.ziphash"; fi; \ done; \ go mod download && go mod verify # Vetted twice: the second time with the browser tag, so the browser # checks (not run here) cannot stop compiling unnoticed. test-vet: CGO_ENABLED=0 go vet ./... CGO_ENABLED=0 go vet -tags browser ./... # Fails on unformatted files rather than rewriting them. CI must never # silently "fix" a diff out from under a branch — a red test-fmt tells # the author to run `gofmt -w` themselves. test-fmt: @if [ -n "$$(gofmt -l .)" ]; then \ echo "gofmt needs to be run on:"; \ gofmt -l .; \ exit 1; \ fi # A compile check, not a release: nothing is stamped or shipped, so VCS # stamping is off. (On 2026-09-29 a runner's checkout could not answer # `git status`, and stamping turned that into a build failure.) test-build: CGO_ENABLED=0 go build -buildvcs=false ./... # Includes internal/lint's prefix-rule tripwire (AGENTS.md's # estilo-*/rst- split) and theme's gates (AGENTS.md, "Theme"; the # token-set check is the two-pin case). -count=1 so a cached "ok" can never stand in for # actually having run. test-go: CGO_ENABLED=0 go test -count=1 ./... # Every margin, padding and gap in estilo's stylesheets is a step of the # spacing scale, var(--rst-sp-1) to var(--rst-sp-6), or says why it is # not in a /* spacing-allow: why */ comment beside it: Fiesta's spacing # check (DESIGN.md, "Checking the rhythm"). go run with a version, not a # require or a tool directive: estilo is imported by every app, and a # Fiesta requirement here would join their module graphs and move the # Fiesta their rastrillo was built against. FIESTA_VERSION := v1.7.0 test-spacing: go run amadan.net/rastrillo/fiesta/cmd/fiesta@$(FIESTA_VERSION) spacing . # The browser checks: not part of `make test` (and so not CI), because # they need Node 22+ and Playwright with its browsers (ESTILO_PLAYWRIGHT # for the package's directory if it is not resolvable from theme/; # ESTILO_BROWSERS, default chromium,webkit). Today that is theme's # no-flash check for the chrome text, by pixels # (theme/fonts_browser_test.go), the stacked bar's title field fitted to # its whole title (chrome/title_browser_test.go), the Google import # chooser (googleimport/browser_test.go) and the side's fold focus and # rail tooltips (side/side_browser_test.go). It runs the whole suite with # the tag. # An engine that will not launch fails it; it never skips to a pass. test-browser: CGO_ENABLED=0 go test -tags browser -count=1 ./...