oficina / sheets Public

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

Plain git — no account needed to clone.

Download

Download this file

1comma := ,
2export GOPRIVATE := $(if $(GOPRIVATE),$(GOPRIVATE)$(comma))amadan.net/oficina/estilo.git,amadan.net/oficina/agent-access.git
3
4.PHONY: build release test test-vet test-fmt test-spacing test-build test-migrations test-go test-race test-browser
5
6# One binary, CGO_ENABLED=0, cgo-free SQLite (AGENTS.md / Deploys). Set
7# per-target below rather than exported globally, because test-race is
8# a deliberate, documented exception — see its comment.
9build:
10 CGO_ENABLED=0 go build ./...
11
12# The ONLY way a binary should be built for shipping. rastrillo's
13# BuildVersion defaults to "dev", and an unstamped binary answers
14# GET /api/version with "dev" — which is the field used to tell what is
15# actually deployed, so an unstamped release makes the fleet unreadable
16# while still looking like a successful deploy. Shipping one by hand
17# with a plain `go build` is exactly the mistake this target removes.
18#
19# A dirty tree is refused: the sha would name a commit that is not what
20# is in the binary, which is worse than no stamp at all.
21#
22# The stamp was a short sha because there were no tags to describe. Now
23# that a release IS a tag, git describe --tags --always answers with the
24# tag when the build sits on one and falls back to the same short sha
25# when it does not, so nothing is lost and a published binary reports
26# the name it was published under.
27#
28# The artifact lands in releases/ under the name the publish step
29# expects: `amadan release create` uploads a file under its basename,
30# and that basename is what appears on the release page permanently.
31APP := sheets
32RELEASE_GOOS ?= linux
33RELEASE_GOARCH ?= arm64
34RELEASE_BIN := releases/$(APP)-$(RELEASE_GOOS)-$(RELEASE_GOARCH)
35VERSION ?= $(shell git describe --tags --always 2>/dev/null)
36
37release:
38 @git diff --quiet && git diff --cached --quiet || \
39 { echo "refusing to build a release from a dirty tree"; exit 1; }
40 @test -n "$(VERSION)" || \
41 { echo "make release: no version to stamp; commit, or name it: make release VERSION=v0.1.0"; exit 1; }
42 @mkdir -p releases
43 CGO_ENABLED=0 GOOS=$(RELEASE_GOOS) GOARCH=$(RELEASE_GOARCH) go build -trimpath \
44 -ldflags "-s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=$(VERSION)" \
45 -o $(RELEASE_BIN) ./cmd/$(APP)
46 @echo "built $(RELEASE_BIN) reporting version $(VERSION)"
47 @echo "publish it with:"
48 @echo " amadan release create -repo oficina/$(APP) -notes-file NOTES.md $(VERSION) $(RELEASE_BIN)"
49 @echo "ship it declaring CARLOS mail submission, then promote it (AGENTS.md, Deploys):"
50 @echo " carlos ship -app $(APP) -mail submit -version $(VERSION) -target $(RELEASE_GOOS)-$(RELEASE_GOARCH) $(RELEASE_BIN)"
51 @echo " carlos promote -app $(APP) $(VERSION)"
52
53# The gate, split into named targets so CI can report them individually
54# (.amadan/ci.d calls these one at a time, each its own step). `make
55# test` runs exactly the same six things in the same order, so the
56# local gate and CI stay ONE definition rather than two lists that
57# drift apart. Debugging CI is running `make test`.
58#
59# Order is cheapest-and-fastest first: vet and gofmt are near-instant,
60# build catches compile errors before minutes are spent on tests,
61# test-migrations needs the app to compile but no database and no test
62# suite, plain `go test` (tens of seconds, dominated by the store
63# package) comes next, and -race — by far the slowest step — runs last.
64test: test-vet test-fmt test-spacing test-build test-migrations test-go test-race
65
66# Also vets the browser-tagged tests: they are outside `make test`, and a
67# test behind a tag that nothing compiles rots silently.
68test-vet:
69 CGO_ENABLED=0 go vet ./...
70 CGO_ENABLED=0 go vet -tags browser ./internal/sheets/
71
72# Fails on unformatted files rather than rewriting them. CI must never
73# silently "fix" a diff out from under a branch — a red test-fmt tells
74# the author to run `gofmt -w` themselves.
75test-fmt:
76 @if [ -n "$$(gofmt -l .)" ]; then \
77 echo "gofmt needs to be run on:"; \
78 gofmt -l .; \
79 exit 1; \
80 fi
81
82
83# Fiesta's spacing check (Paul, 2026-11-22: no ad-hoc spacing): every
84# margin, padding and gap in Sheets' own stylesheets is a
85# var(--rst-sp-N), or says why not with /* spacing-allow: why */.
86# tokens.css is rastrillo's, re-copied on each upgrade, and vendor/ is
87# Jspreadsheet's and jSuites': neither is ours to space.
88test-spacing:
89 go tool fiesta spacing -skip 'vendor/*.css' -skip 'tokens.css' internal/sheets/static
90
91test-build:
92 CGO_ENABLED=0 go build ./...
93
94# CI gate for AGENTS.md's additive-only migrations rule: models
95# (internal/sheets/migrations.go's Models) and migrations
96# (internal/sheets/migrations/*.sql, via Schema) must already agree.
97# Touches no database — it diffs structs against committed SQL, the
98# same computation `rastrillo migration generate` does before deciding
99# there is nothing to write — so it belongs this early, right after the
100# app is known to compile and well before test-go pays for real SQLite
101# files. A model changed without `rastrillo migration generate` run
102# after it fails here, not in production at the next boot.
103#
104# `go tool`, not a bare `rastrillo` on PATH: go.mod pins the CLI as a tool
105# at the same version as the module, so the check always runs the
106# migrate the app is built against — never whatever a machine happened
107# to have installed (a v0.25.0 CLI answering for a v0.23.0 app, until
108# the move to amadan.net/rastrillo/rastrillo).
109test-migrations:
110 go tool rastrillo migration check
111
112# Includes internal/guardstest: the mechanical guards for the line cap,
113# forbidden imports, excelize confinement, calc isolation and sealtest
114# containment all run here as ordinary tests, plus internal/sheets/seal
115# and internal/sheets/xlsx's plaintext-leak checks (AGENTS.md / "The one
116# rule"). -count=1 so a cached "ok" from a previous run can never stand
117# in for actually having run.
118test-go:
119 CGO_ENABLED=0 go test -count=1 ./...
120
121# The concurrency-bearing packages: store's one-connection writer pool
122# and its handle gate (AGENTS.md: "Scope tx, never the outer handle,
123# inside transactions, or the one-connection writer pool deadlocks"),
124# and live's fan-out hub, where one publisher and every open browser
125# tab meet. Scoped to those two rather than ./... because -race's
126# slowdown is worth paying where the concurrency actually lives, not
127# repeated across packages that don't touch goroutines.
128#
129# Deliberately NOT CGO_ENABLED=0: the race detector requires cgo (`go:
130# -race requires cgo`), so this one target runs with the ambient
131# CGO_ENABLED (cgo on, given a C toolchain is present). Nothing this
132# target builds is shipped — it only exercises store's own test suite —
133# so it does not violate the cgo-free binary rule, which is about what
134# gets deployed.
135test-race:
136 go test -race -count=1 ./internal/sheets/store/... ./internal/sheets/live/...
137
138# The browser checks (internal/sheets/*_browser_test.go), in a real
139# Chromium: RASTRILLO_CHROME, else chromium or google-chrome on PATH,
140# else a Playwright cache under ~/.cache/ms-playwright (the Linux build
141# only; on a Mac set RASTRILLO_CHROME to Playwright's or Chrome's binary).
142# Deliberately NOT part of `test`: the gate CI runs on every push must
143# not need a browser. Run it before shipping a change to the CSS or to
144# rastrillo's pin. The filter runs eight tests: OnTap matches both
145# TestNoZoomOnTap (the iOS zoom-on-tap check) and TestFormatMenuFitsOnTap;
146# TestDocumentStylesSurviveTheProductionCSP and TestSmartDoorInABrowser
147# are served through rastrillo's production stack, so they see the real
148# CSP. TestSmartDoorInABrowser forces the light scheme itself; the others
149# measure whichever scheme the browser starts in.
150# TestEveryScreenKeepsTheRhythm is Fiesta's rhythm audit over every
151# screen but the grid's own surface, at 1280 and 390px.
152# TestFirstKeystrokeTypesInABrowser types into the grid as the OS
153# delivers keys: a plain key, a dead key and an input method's
154# composition each start a cell edit from the first key;
155# TestFirstKeystrokeAfterLeavingTheGrid checks that Enter saves and Escape
156# cancels such an edit after Bold, a menu item and the formula bar;
157# TestFirstKeystrokeKeepsWhatLandsUnderAnOpenEditor that a value arriving
158# under an open editor is shown when it closes.
159test-browser:
160 CGO_ENABLED=0 go test -tags browser -count=1 -run 'OnTap|DocumentStyles|SmartDoorInABrowser|KeepsTheRhythm|FirstKeystroke' ./internal/sheets/
161