oficina / memoria Public

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

Plain git — no account needed to clone.

Download

Download this file

1export GOTOOLCHAIN := go1.26.5
2export GOPRIVATE := $(GOPRIVATE),amadan.net/oficina/estilo.git,amadan.net/oficina/agent-access.git
3
4APP := memoria
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
11RELEASE_GOOS ?= linux
12RELEASE_GOARCH ?= arm64
13RELEASE_BIN := releases/$(APP)-$(RELEASE_GOOS)-$(RELEASE_GOARCH)
14
15.PHONY: build release deps test vet fmt-check migration-check spacing ci browser
16
17# build is the compile check: with more than one package matched, go
18# build discards the output, so this catches a broken package without
19# producing an artifact.
20build:
21 CGO_ENABLED=0 go build ./...
22
23# release is what ships. -s -w drops the symbol table and DWARF, which on
24# this family's apps is 23-31% off the binary and 45-53% off the
25# compressed artifact — and compressed size is what actually gets
26# transferred. carlos is built the same way (see platform's Makefile).
27#
28# What survives: panic traces keep their function names AND line numbers
29# (Go's pclntab is untouched by these flags), debug.ReadBuildInfo works,
30# and go version -m still reports module metadata. What you lose is
31# source-level debugging with delve or gdb — build without the flags for
32# that. rastrillo dev never strips, for the same reason.
33# The scaffold's release target stamped no version and did not refuse a
34# dirty tree. Both matter: rastrillo.BuildVersion defaults to "dev", and
35# an unstamped binary answers "dev" from /api/version forever — which
36# makes the deploy check structurally incapable of failing, since the
37# thing it compares can never disagree.
38#
39# The stamp was a short sha because there were no tags to describe. Now
40# that a release IS a tag, git describe --tags --always answers with the
41# tag when the build sits on one and falls back to the same short sha
42# when it does not — so the reasoning above is unchanged, and a
43# published binary reports the name it was published under.
44VERSION ?= $(shell git describe --tags --always 2>/dev/null)
45
46release:
47 @git diff --quiet && git diff --cached --quiet || \
48 { echo "refusing to build a release from a dirty tree"; exit 1; }
49 @test -n "$(VERSION)" || \
50 { echo "make release: no version to stamp; commit, or name it: make release VERSION=v0.1.0"; exit 1; }
51 @mkdir -p releases
52 CGO_ENABLED=0 GOOS=$(RELEASE_GOOS) GOARCH=$(RELEASE_GOARCH) go build -trimpath \
53 -ldflags "-s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=$(VERSION)" \
54 -o $(RELEASE_BIN) ./cmd/$(APP)
55 @echo "built $(RELEASE_BIN) reporting version $(VERSION)"
56 @echo "ship it declaring CARLOS mail submission, then promote it (carlos deploy has no --mail flag yet; see README):"
57 @echo " carlos ship --app $(APP) --account bds --mail submit --version $(VERSION) $(RELEASE_BIN)"
58 @echo " carlos promote --app $(APP) --account bds $(VERSION) edge"
59 @echo "publish it with:"
60 @echo " amadan release create -repo oficina/$(APP) -notes-file NOTES.md $(VERSION) $(RELEASE_BIN)"
61
62test:
63 go test ./...
64
65# deps makes sure the module cache holds what go.sum says, and repairs it
66# when it does not. The CI runner's cache held an extracted
67# amadan.net/rastrillo/rastrillo whose embedded files (locales/*.toml,
68# migrations/*.sql, ui/calendar.js) were missing, so vet failed with
69# "pattern ...: no matching files found" while the same commit passed
70# here (Calendar met it first, oficina/calendar#26). `go mod verify`
71# names such a directory as "dir has been modified"; deleting it lets
72# `go mod download` extract it again from the checksummed zip.
73deps:
74 @go mod download
75 @out=$$(go mod verify 2>&1) || { \
76 echo "$$out"; \
77 echo "$$out" | sed -n 's/.*: dir has been modified (\(.*\))$$/\1/p' | while read -r dir; do \
78 echo "deps: re-extracting $$dir"; chmod -R u+w "$$dir" && rm -rf "$$dir"; \
79 done; \
80 go mod download && go mod verify; \
81 }
82
83# Also vets the browser-tagged tests: they are outside `make ci`, and a
84# test behind a tag that nothing compiles rots silently.
85vet: deps
86 go vet ./...
87 go vet -tags browser ./internal/memoria/ ./internal/memoriatest/
88
89fmt-check:
90 @out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi
91
92# A step of its own, not folded into another target's recipe: ci.d/
93# steps each exec one make target, so migration-check needs its own
94# name to get its own reported step on a runner with step support.
95#
96# go tool, not a bare "rastrillo": go.mod pins the CLI as a tool at the
97# module's own version, so this needs nothing on PATH but the Go
98# toolchain, works offline after go mod download, and always runs the
99# migrate the app is built against. A bare "rastrillo migration check"
100# failed a fresh clone's very first CI run with "make: rastrillo:
101# Command not found", and nothing in the scaffold said what to install.
102migration-check:
103 go tool rastrillo migration check
104
105# spacing is Fiesta's stylesheet half of the spacing rhythm (Paul,
106# 2026-11-22): every margin, padding and gap in static/ is a
107# var(--rst-sp-N) step, or says why not with /* spacing-allow: why */.
108# tokens.css is rastrillo's, vendored and pinned byte for byte
109# (TestVendoredAssetsMatchTheLibrary), so it is skipped; estilo's files
110# are read like Memoria's own. The rendered half is the rhythm audit,
111# TestEveryScreenKeepsTheRhythm, in make browser.
112spacing:
113 go tool fiesta spacing -skip tokens.css internal/memoria/static
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
122ci: vet fmt-check test migration-check spacing
123
124# The browser checks (internal/memoriatest/*_browser_test.go), in a real
125# Chromium through chromedp. Deliberately NOT part of `ci`: the gate
126# every push runs must not need a browser. Run it before shipping a
127# change to the CSS or to rastrillo's pin; TestNoZoomOnTap is the iOS
128# zoom-on-tap check, and TestPagesRenderUnderTheProductionCSP is the one
129# browser check served through rastrillo's production stack, so it sees
130# the real CSP. TestEveryScreenKeepsTheRhythm and TestTheDoorKeepsTheRhythm
131# are Fiesta's rhythm audit over every screen at 1280px and 390px.
132# TestSmartDoorInABrowser (internal/memoria) draws every
133# sign-in state at 320px and 1280px, forced light. The Chromium comes from
134# RASTRILLO_CHROME, or on a Mac from the Playwright cache: Chromium.app,
135# or Google Chrome for Testing.app, found by the shell because the path
136# has spaces and make's wildcard splits on them (Calendar's fix).
137RASTRILLO_CHROME ?= $(shell for p in "$(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"; do [ -x "$$p" ] && { echo "$$p"; break; }; done)
138browser:
139 RASTRILLO_CHROME="$(RASTRILLO_CHROME)" CGO_ENABLED=0 go test -tags browser -count=1 -run 'OnTap|ProductionCSP|NoSidewaysScroll|TypingSuggestsAndEnterAnswers|WholeResultIsALink|StaleAIAnswer|AnswerSlotSettles|ThumbsUp|TypeaheadAnswerCopies|AWholeRowOpens|ClearEmptiesTheBox|KeepsTheRhythm' ./internal/memoriatest/
140 RASTRILLO_CHROME="$(RASTRILLO_CHROME)" CGO_ENABLED=0 go test -tags browser -count=1 -run 'SmartDoorInABrowser' ./internal/memoria/
141
142.PHONY: credits
143credits:
144 @set -eu; notices_tmp=$$(mktemp -d); trap 'rm -rf "$$notices_tmp"' EXIT; \
145 GOOS=$$(go env GOHOSTOS) GOARCH=$$(go env GOHOSTARCH) CGO_ENABLED=0 \
146 go build -o "$$notices_tmp/notices" amadan.net/oficina/estilo.git/cmd/oficina-notices; \
147 GOOS=linux GOARCH=arm64 CGO_ENABLED=0 "$$notices_tmp/notices" \
148 -package ./cmd/memoria -lucide -onest \
149 -exclude amadan.net/oficina/agent-access.git,amadan.net/oficina/estilo.git,amadan.net/oficina/home/connect,amadan.net/oficina/home/handoff,amadan.net/oficina/home/roster,amadan.net/oficina/home/teammode,amadan.net/oficina/suite,amadan.net/rastrillo/native/server \
150 > "$$notices_tmp/notices.json"; \
151 mv "$$notices_tmp/notices.json" internal/memoria/credits/notices.json
152