| 1 | SHA := $(shell git rev-parse --short HEAD 2>/dev/null || echo dev) |
| 2 | LDFLAGS := -s -w -X github.com/carlosframework/platform/internal/version.Build=$(SHA) |
| 3 | GOOS ?= |
| 4 | GOARCH ?= |
| 5 | |
| 6 | .PHONY: test build fmt census-card census-propose |
| 7 | |
| 8 | # The build gate: vet, format, tests. `.amadan/ci.d/10-gate` runs this same |
| 9 | # target, so what CI checks and what you check are one definition. |
| 10 | # |
| 11 | # -count=1 is CLAUDE.md's rule: never satisfy the gate from a cached pass. |
| 12 | # The 30m timeout is above Go's 10m default because the root package's e2e |
| 13 | # tests compile the carlos binary many times over. |
| 14 | # |
| 15 | # .amadan/test-gate.sh runs launchctx, vet, gofmt and the tests at once, |
| 16 | # and splits the slowest packages' tests across processes. TEST_SPLIT |
| 17 | # overrides which packages and how many ways (TEST_SPLIT= runs none split). |
| 18 | test: |
| 19 | .amadan/test-gate.sh |
| 20 | |
| 21 | build: |
| 22 | CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -o carlos . |
| 23 | |
| 24 | fmt: |
| 25 | gofmt -w . |
| 26 | |
| 27 | # The root-read census as an approval (#369, AGENTS.md "The census"): |
| 28 | # census-card prints what changed and writes nothing; census-propose writes |
| 29 | # the overlay, its chain manifest line and the approval card. CLAIMS has |
| 30 | # one line per changed unit, "<file>:<unit><TAB><what changed>". Kept here |
| 31 | # rather than in a script: every .sh in the tree is itself a census unit. |
| 32 | CENSUS_RUN = out=$$(mktemp "$${TMPDIR:-/tmp}/census.XXXXXX") || exit 1; \ |
| 33 | trap 'rm -f "$$out"' EXIT; \ |
| 34 | GOFLAGS="$${GOFLAGS:--buildvcs=false}" go test ./internal/provision/ -run '^TestPlan14RootReadCensusPropose$$' -count=1 -v >"$$out" 2>&1; rc=$$?; \ |
| 35 | if [ $$rc -eq 0 ]; then sed -n '/^--- census card ---$$/,/^--- end census card ---$$/p' "$$out" | sed '1d;$$d'; \ |
| 36 | else grep -v '^20[0-9][0-9]/' "$$out" | tail -20 >&2; fi; exit $$rc |
| 37 | # CLAIMS is kept as one value, spaces and all, and made absolute for go test. |
| 38 | CENSUS_CLAIMS = c='$(CLAIMS)'; if [ -n "$$c" ]; then case "$$c" in /*) ;; *) c="$$PWD/$$c" ;; esac; \ |
| 39 | CARLOS_CENSUS_CLAIMS="$$c"; export CARLOS_CENSUS_CLAIMS; fi |
| 40 | |
| 41 | census-card: |
| 42 | @CARLOS_CENSUS_CARD=1; export CARLOS_CENSUS_CARD; $(CENSUS_CLAIMS); $(CENSUS_RUN) |
| 43 | |
| 44 | census-propose: |
| 45 | @if [ -z '$(NAME)' ] || [ -z '$(CLAIMS)' ]; then echo "usage: make census-propose NAME=<branch> CLAIMS=<file>" >&2; exit 2; fi; \ |
| 46 | CARLOS_CENSUS_PROPOSE='$(NAME)'; export CARLOS_CENSUS_PROPOSE; $(CENSUS_CLAIMS); $(CENSUS_RUN) |
| 47 | |