oficina / alta Public

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

Plain git — no account needed to clone.

Download

Download this file

1export GOTOOLCHAIN := go1.26.5
2export GOPRIVATE := $(GOPRIVATE),amadan.net/oficina/estilo.git
3
4APP := alta
5
6# What `carlos ship -target` defaults to, and so what a release must be
7# built for. Override for a one-off: make release RELEASE_GOARCH=amd64
8RELEASE_GOOS ?= linux
9RELEASE_GOARCH ?= arm64
10RELEASE_BIN := releases/$(APP)-$(RELEASE_GOOS)-$(RELEASE_GOARCH)
11
12# What GET /api/version answers. An unstamped binary answers "dev"
13# forever, and the deploy check can then never fail.
14VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null)
15
16.PHONY: build release adopt version-check deps test vet fmt-check compat ci check compat-check
17
18build:
19 CGO_ENABLED=0 go build ./...
20
21release: version-check
22 @mkdir -p releases
23 CGO_ENABLED=0 GOOS=$(RELEASE_GOOS) GOARCH=$(RELEASE_GOARCH) go build -trimpath \
24 -ldflags "-s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=$(VERSION)" \
25 -o $(RELEASE_BIN) ./cmd/$(APP)
26 @echo "built $(RELEASE_BIN) reporting version $(VERSION)"
27
28# adopt builds the local adoption runner for this machine (it is run here,
29# never shipped), stamped like a release: alta-adopt version prints it.
30ADOPT_BIN := releases/alta-adopt
31adopt: version-check
32 @mkdir -p releases
33 CGO_ENABLED=0 go build -trimpath \
34 -ldflags "-s -w -X main.version=$(VERSION)" \
35 -o $(ADOPT_BIN) ./cmd/alta-adopt
36 @echo "built $(ADOPT_BIN) reporting version $(VERSION)"
37
38version-check:
39 @test -n "$(VERSION)" || { echo "make release: no version to stamp; commit, or name it: make release VERSION=v0.1.0"; exit 1; }
40 @case "$(VERSION)" in *-dirty) echo "make release: the tree is dirty, so $(VERSION) does not name what you would ship"; exit 1;; esac
41
42# deps repairs a module cache whose extracted copy lost files (go mod
43# verify names it), the CI runner's known failure (memoria's Makefile).
44deps:
45 @go mod download
46 @out=$$(go mod verify 2>&1) || { \
47 echo "$$out"; \
48 echo "$$out" | sed -n 's/.*: dir has been modified (\(.*\))$$/\1/p' | while read -r dir; do \
49 echo "deps: re-extracting $$dir"; chmod -R u+w "$$dir" && rm -rf "$$dir"; \
50 done; \
51 go mod download && go mod verify; \
52 }
53
54test:
55 CGO_ENABLED=0 go test ./...
56
57vet: deps
58 go vet ./...
59
60fmt-check:
61 @out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi
62
63# compat runs Alta's engine against Home's real operator code at the
64# pinned commit (homecompat/go.mod). Its own module, so Alta's build
65# never depends on Home's internals.
66compat:
67 cd homecompat && go vet ./... && CGO_ENABLED=0 go test ./...
68
69# check runs one package's tests: make check PKG=./homeop/... RUN=TestX
70# PKG is required. Use this, never bare `go test`: it pins the toolchain.
71check:
72 @test -n "$(PKG)" || { echo "make check: PKG is required, e.g. make check PKG=./provision/... RUN=TestX"; exit 1; }
73 CGO_ENABLED=0 go test $(PKG) -run '$(RUN)' -count=1
74
75# compat-check is check for homecompat, which is its own module.
76compat-check:
77 cd homecompat && CGO_ENABLED=0 go test ./... -run '$(RUN)' -count=1
78
79# ci is the one gate: what the runner executes and what you run before
80# pushing. No migration-check: Alta has no GORM models, only SQL
81# migrations under provision/migrations.
82ci: vet fmt-check test compat
83