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
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
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
43test-vet:
44 CGO_ENABLED=0 go vet ./...
45
46# Fails on unformatted files rather than rewriting them. CI must never
47# silently "fix" a diff out from under a branch — a red test-fmt tells
48# the author to run `gofmt -w` themselves.
49test-fmt:
50 @if [ -n "$$(gofmt -l .)" ]; then \
51 echo "gofmt needs to be run on:"; \
52 gofmt -l .; \
53 exit 1; \
54 fi
55
56# A compile check, not a release: nothing is stamped or shipped, so VCS
57# stamping is off. (On 2026-09-29 a runner's checkout could not answer
58# `git status`, and stamping turned that into a build failure.)
59test-build:
60 CGO_ENABLED=0 go build -buildvcs=false ./...
61
62# Includes internal/lint's prefix-rule tripwire (AGENTS.md's
63# estilo-*/rst- split) and theme's gates (AGENTS.md, "Theme"; the
64# token-set check is the two-pin case). -count=1 so a cached "ok" can never stand in for
65# actually having run.
66test-go:
67 CGO_ENABLED=0 go test -count=1 ./...
68