oficina / calendar Public

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

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 := calendar
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# 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
26VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null)
27
28.PHONY: build release version-check deps test vet fmt-check spacing migration-check ci browser
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.
33build:
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.
46release: 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):"
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
73version-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
86test:
87 go test ./...
88
89# deps makes sure the module cache holds what go.sum says, and repairs it
90# when it does not. A CI runner's cache once held an extracted
91# amadan.net/rastrillo/rastrillo whose embedded files (locales/*.toml,
92# migrations/*.sql, ui/calendar.js) were missing, so vet failed with
93# "pattern ...: no matching files found" on every run, while the same
94# commit passed here. `go mod verify` names such a directory as "dir has
95# been modified"; deleting it lets `go mod download` extract it again
96# from the checksummed zip.
97deps:
98 @go mod download
99 @out=$$(go mod verify 2>&1) || { \
100 echo "$$out"; \
101 echo "$$out" | sed -n 's/.*: dir has been modified (\(.*\))$$/\1/p' | while read -r dir; do \
102 echo "deps: re-extracting $$dir"; chmod -R u+w "$$dir" && rm -rf "$$dir"; \
103 done; \
104 go mod download && go mod verify; \
105 }
106
107# Also vets the browser-tagged tests: they are outside `make ci`, and a
108# test behind a tag that nothing compiles rots silently.
109vet: deps
110 go vet ./...
111 go vet -tags browser ./internal/calendartest/ ./internal/calendar/
112
113fmt-check:
114 @out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi
115
116# Fiesta's spacing check (Paul, 2026-11-22: no ad-hoc spacing): every
117# margin, padding and gap in Calendar's own stylesheets is a
118# var(--rst-sp-N), or says why not with /* spacing-allow: why */.
119# tokens.css is rastrillo's, re-copied on each upgrade, and not ours to
120# space. estilo's files (theme, busy, chrome, menu, sky, base, written by
121# scripts/writeestilo) are read too: they are on the scale, and a bump
122# that brings one that is not should fail here, not pass unseen.
123spacing:
124 go tool fiesta spacing -skip tokens.css internal/calendar/static
125
126# A step of its own, not folded into another target's recipe: ci.d/
127# steps each exec one make target, so migration-check needs its own
128# name to get its own reported step on a runner with step support.
129#
130# go tool, not a bare "rastrillo": go.mod pins the CLI as a tool at the
131# module's own version, so this needs nothing on PATH but the Go
132# toolchain, works offline after go mod download, and always runs the
133# migrate the app is built against. A bare "rastrillo migration check"
134# failed a fresh clone's very first CI run with "make: rastrillo:
135# Command not found", and nothing in the scaffold said what to install.
136migration-check:
137 go tool rastrillo migration check
138
139# ci is the one gate: what a runner executes and what you run before
140# pushing are the same definition. amadan's runner falls back to this
141# target when .amadan/ci is absent; ci.d/ carries the same targets,
142# reported one by one, for a runner with step support. migration-check
143# fails the build the moment models.go and migrations/ disagree,
144# instead of at boot on whatever machine notices next. If the app
145# declares manifest resources, also add: rastrillo generate --check
146ci: vet fmt-check spacing test migration-check
147
148# The browser gate: the quick-add box driven in a real Chromium, with
149# script and then with JavaScript disabled.
150#
151# Deliberately NOT part of `ci`. It needs node and `npm install`, and
152# the one gate the team runs on every push must not depend on a
153# toolchain the app itself does not use. Run it before shipping a
154# change to the box.
155#
156# TestNoZoomOnTap (the iOS zoom-on-tap check),
157# TestFormFootOnANarrowScreen and TestPlacedChipsSurviveTheProductionCSP
158# drive Chromium through chromedp instead, and find it through
159# RASTRILLO_CHROME; on a Mac the Playwright cache's Chromium is used when
160# that is unset. The CSP check is the one served through rastrillo's
161# production stack, so it is the one that sees the real policy.
162#
163# TestEveryScreenKeepsTheRhythm is Fiesta's rhythm audit over every
164# screen at 1280 and 390px, through the production stack, reading
165# around the calendar grids themselves.
166#
167# TestSmartDoorInABrowser (internal/calendar) is the sign-in door in every
168# state at 320px and 1280px: no sideways scroll, 24px targets, the Oficina
169# glyph drawn. It forces the light scheme itself. On macOS, run with
170# TMPDIR=/tmp if a unix socket path is too long.
171browser:
172 npm install --no-save playwright
173 RASTRILLO_CHROME="$(RASTRILLO_CHROME)" go test -tags browser -run 'InARealBrowser|OnTap|OnANarrowScreen|SurviveTheProductionCSP|KeepsTheRhythm' ./internal/calendartest/
174 RASTRILLO_CHROME="$(RASTRILLO_CHROME)" go test -tags browser -run 'SmartDoorInABrowser' ./internal/calendar/
175
176# The Playwright cache's Chromium: older caches hold Chromium.app, newer
177# ones "Google Chrome for Testing.app". The path has spaces, so it is found
178# by the shell (make's wildcard and firstword split on them) and quoted
179# where it is used.
180RASTRILLO_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)
181
182.PHONY: credits
183credits:
184 @set -eu; notices_tmp=$$(mktemp -d); trap 'rm -rf "$$notices_tmp"' EXIT; \
185 GOOS=$$(go env GOHOSTOS) GOARCH=$$(go env GOHOSTARCH) CGO_ENABLED=0 \
186 go build -o "$$notices_tmp/notices" amadan.net/oficina/estilo.git/cmd/oficina-notices; \
187 GOOS=linux GOARCH=arm64 CGO_ENABLED=0 "$$notices_tmp/notices" \
188 -package ./cmd/calendar -lucide -onest \
189 -exclude amadan.net/oficina/home/dashboard,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/rastrillo/native/server \
190 > "$$notices_tmp/notices.json"; \
191 mv "$$notices_tmp/notices.json" internal/calendar/credits/notices.json
192