oficina / estilo Public

Clone
git clone https://amadan.net/oficina/estilo

Plain git — no account needed to clone.

Download

Download this file

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