| 1 | export GOTOOLCHAIN := go1.26.5 |
| 2 | export GOPRIVATE := $(GOPRIVATE),amadan.net/oficina/estilo.git |
| 3 | |
| 4 | APP := slides |
| 5 | |
| 6 | # What `carlos ship -target` defaults to, and therefore what a release |
| 7 | # must be built for. Building for your own machine and shipping that is a |
| 8 | # silent architecture mismatch: the binary uploads fine and fails to exec |
| 9 | # on the instance. Override for a one-off: |
| 10 | # make release RELEASE_GOARCH=amd64 |
| 11 | RELEASE_GOOS ?= linux |
| 12 | RELEASE_GOARCH ?= arm64 |
| 13 | RELEASE_BIN := releases/$(APP)-$(RELEASE_GOOS)-$(RELEASE_GOARCH) |
| 14 | |
| 15 | # What the running binary reports from GET /api/version. The platform's |
| 16 | # deploy verification polls that endpoint on every instance socket and |
| 17 | # compares what it finds against the release it believes it adopted; an |
| 18 | # unstamped binary answers "dev" from every build you have ever made, so |
| 19 | # those two facts can never disagree and a process that was never |
| 20 | # recycled onto the new release verifies green. Stamping this is what |
| 21 | # gives that check the ability to fail. |
| 22 | # |
| 23 | # git describe, because the tag is what you ship against. Outside a |
| 24 | # repository, or before the first commit, name it yourself: |
| 25 | # make release VERSION=v0.1.0 |
| 26 | VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null) |
| 27 | |
| 28 | .PHONY: build release version-check test vet fmt-check migration-check spacing browser ci |
| 29 | |
| 30 | # build is the compile check: with more than one package matched, go |
| 31 | # build discards the output, so this catches a broken package without |
| 32 | # producing an artifact. |
| 33 | build: |
| 34 | CGO_ENABLED=0 go build ./... |
| 35 | |
| 36 | # release is what ships. -s -w drops the symbol table and DWARF, which on |
| 37 | # this family's apps is 23-31% off the binary and 45-53% off the |
| 38 | # compressed artifact — and compressed size is what actually gets |
| 39 | # transferred. carlos is built the same way (see platform's Makefile). |
| 40 | # |
| 41 | # What survives: panic traces keep their function names AND line numbers |
| 42 | # (Go's pclntab is untouched by these flags), debug.ReadBuildInfo works, |
| 43 | # and go version -m still reports module metadata. What you lose is |
| 44 | # source-level debugging with delve or gdb — build without the flags for |
| 45 | # that. rastrillo dev never strips, for the same reason. |
| 46 | release: version-check |
| 47 | @mkdir -p releases |
| 48 | CGO_ENABLED=0 GOOS=$(RELEASE_GOOS) GOARCH=$(RELEASE_GOARCH) \ |
| 49 | go build -ldflags="-s -w -X 'amadan.net/rastrillo/rastrillo.BuildVersion=$(VERSION)'" \ |
| 50 | -o $(RELEASE_BIN) ./cmd/$(APP) |
| 51 | @echo |
| 52 | @echo "built $(RELEASE_BIN) reporting version $(VERSION)" |
| 53 | @echo "ship it with:" |
| 54 | @echo " carlos ship -app $(APP) -mail submit -target $(RELEASE_GOOS)-$(RELEASE_GOARCH) $(RELEASE_BIN)" |
| 55 | @echo "then promote it (carlos deploy has no -mail flag yet; see README/AGENTS):" |
| 56 | @echo " carlos promote -app $(APP) <version>" |
| 57 | |
| 58 | # version-check refuses rather than letting release ship a binary whose |
| 59 | # version is untrue. Both refusals are about the same thing: /api/version |
| 60 | # is only evidence if the answer identifies one artifact. |
| 61 | # |
| 62 | # An empty stamp is worse than the "dev" default, because "dev" is |
| 63 | # saying something true about itself and "" looks like a value that |
| 64 | # arrived from somewhere. |
| 65 | # |
| 66 | # A dirty tree is refused rather than suffixed. A -dirty stamp names a |
| 67 | # commit plus changes nobody can name, so two different binaries can |
| 68 | # carry the identical string — which does not fix the check, it makes |
| 69 | # it look reliable while it is not, and that is the more expensive |
| 70 | # failure. Refusing costs one `git stash`; a wrong stamp ships. If you |
| 71 | # mean to ship uncommitted work, say so out loud: |
| 72 | # make release VERSION=v0.1.0-wip |
| 73 | version-check: |
| 74 | @if [ -z "$(VERSION)" ]; then \ |
| 75 | echo "make release: no version to stamp."; \ |
| 76 | echo " git describe found nothing here: no repository, or no commit yet."; \ |
| 77 | echo " Commit, or name it: make release VERSION=v0.1.0"; \ |
| 78 | exit 1; \ |
| 79 | fi |
| 80 | @case "$(VERSION)" in *-dirty) \ |
| 81 | echo "make release: the tree is dirty, so $(VERSION) does not name what you are about to ship."; \ |
| 82 | echo " Commit or stash first, or name it: make release VERSION=v0.1.0-wip"; \ |
| 83 | exit 1;; \ |
| 84 | esac |
| 85 | |
| 86 | test: |
| 87 | go test ./... |
| 88 | |
| 89 | # Also vets the browser-tagged tests: they are outside `make ci`, and a |
| 90 | # drive that no longer compiles would otherwise be found by whoever next |
| 91 | # runs make browser. |
| 92 | vet: |
| 93 | go vet ./... |
| 94 | go vet -tags browser ./internal/slidestest/ |
| 95 | |
| 96 | fmt-check: |
| 97 | @out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi |
| 98 | |
| 99 | # A step of its own, not folded into another target's recipe: ci.d/ |
| 100 | # steps each exec one make target, so migration-check needs its own |
| 101 | # name to get its own reported step on a runner with step support. |
| 102 | # |
| 103 | # go run, not a bare "rastrillo": go.mod already requires rastrillo, so |
| 104 | # this needs nothing on PATH but the Go toolchain, and works offline |
| 105 | # after go mod download. A bare "rastrillo migration check" failed a |
| 106 | # fresh clone's very first CI run with "make: rastrillo: Command not |
| 107 | # found", and nothing in the scaffold said what to install. |
| 108 | # |
| 109 | # What makes the go run resolve is the tool directive at the foot of |
| 110 | # go.mod — it is what keeps the CLI's own dependencies in go.sum. See |
| 111 | # the comment there before removing it. |
| 112 | migration-check: |
| 113 | go run amadan.net/rastrillo/rastrillo/cmd/rastrillo migration check |
| 114 | |
| 115 | # ci is the one gate: what a runner executes and what you run before |
| 116 | # pushing are the same definition. amadan's runner falls back to this |
| 117 | # target when .amadan/ci is absent; ci.d/ carries the same targets, |
| 118 | # reported one by one, for a runner with step support. migration-check |
| 119 | # fails the build the moment models.go and migrations/ disagree, |
| 120 | # instead of at boot on whatever machine notices next. If the app |
| 121 | # declares manifest resources, also add: rastrillo generate --check |
| 122 | ci: vet fmt-check test migration-check spacing |
| 123 | |
| 124 | # spacing is Fiesta's spacing gate (rastrillo v0.45.0, Fiesta 1.6; Paul, |
| 125 | # 2026-11-22: no ad-hoc spacing): every margin, padding and gap in this |
| 126 | # app's own stylesheets is a step of the scale, var(--rst-sp-N), or says |
| 127 | # why not with /* spacing-allow: why */. The skipped files are vendored, |
| 128 | # somebody else's to space: tokens.css and shell.css are rastrillo's |
| 129 | # (rastrillo doctor), theme.css and busy.css estilo's (go run |
| 130 | # ./scripts/writeestilo), brand/brand.css estilo's brand/distribute.py. |
| 131 | # The templates' <style> blocks, which this tool does not read, are |
| 132 | # TestEveryStylesheetIsOnTheSpacingScale's (make test). The rhythm audit, |
| 133 | # its runtime half, is make browser. |
| 134 | spacing: |
| 135 | go tool fiesta spacing \ |
| 136 | -skip tokens.css -skip shell.css -skip theme.css -skip busy.css -skip brand/brand.css \ |
| 137 | internal/slides/static |
| 138 | |
| 139 | # browser runs Fiesta's rhythm audit over every screen in a real |
| 140 | # Chromium (internal/slidestest/browser_rhythm_test.go): the gaps |
| 141 | # between a page's blocks are steps of the scale, no text rests on a |
| 142 | # control, and a heading sits closer to its content than to what comes |
| 143 | # before. The rest of the browser drive is `go test -tags browser |
| 144 | # ./internal/slidestest/` (AGENTS.md, Fonts: Tests), run when you touch a |
| 145 | # slide surface. The Chromium is RASTRILLO_CHROME; on a Mac the |
| 146 | # Playwright cache's is used when it is unset. |
| 147 | RASTRILLO_CHROME ?= $(shell ls -d "$(HOME)"/Library/Caches/ms-playwright/chromium-*/chrome-mac*/Chromium.app/Contents/MacOS/Chromium "$(HOME)"/Library/Caches/ms-playwright/chromium-*/chrome-mac*/"Google Chrome for Testing.app"/Contents/MacOS/"Google Chrome for Testing" 2>/dev/null | tail -1) |
| 148 | browser: |
| 149 | CGO_ENABLED=0 RASTRILLO_CHROME="$(RASTRILLO_CHROME)" go test -count=1 -tags browser -run 'KeepsTheRhythm' ./internal/slidestest/ |
| 150 | |
| 151 | .PHONY: credits credits-check |
| 152 | credits: |
| 153 | python3 scripts/credits.py |
| 154 | |
| 155 | credits-check: |
| 156 | python3 scripts/credits.py --check |
| 157 | |
| 158 | ci: credits-check |
| 159 | |