oficina / fichas Public

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

Plain git — no account needed to clone.

Download

Download this file

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