| 1 | # The gate and the release run on one named Go, not whichever release this |
| 2 | # machine has. Raise it with each Go security release. |
| 3 | export GOTOOLCHAIN = go1.26.11 |
| 4 | export CGO_ENABLED = 0 |
| 5 | |
| 6 | # The deployment platform target for a release. Override for a one-off: |
| 7 | # make release RELEASE_GOARCH=amd64 |
| 8 | RELEASE_GOOS ?= linux |
| 9 | RELEASE_GOARCH ?= arm64 |
| 10 | RELEASE_VERSION = $(shell git rev-parse --short HEAD) |
| 11 | |
| 12 | # One target at a time, even under make -j. |
| 13 | .NOTPARALLEL: |
| 14 | |
| 15 | .PHONY: script-test fonts build release test browser vet fmt-check staticcheck govulncheck gitleaks budget ci native-check |
| 16 | |
| 17 | RASTRILLO := go run amadan.net/rastrillo/rastrillo/cmd/rastrillo |
| 18 | |
| 19 | build: |
| 20 | CGO_ENABLED=0 go build ./... |
| 21 | |
| 22 | # Builds every binary under ./cmd, stamped with the clean commit. A release |
| 23 | # is set in Timeless Sans or not built at all: it fetches the font if it is |
| 24 | # missing and refuses to go on unless the file is the pinned one. (Dev and |
| 25 | # test builds fall back to DM Sans.) |
| 26 | release: |
| 27 | @test -z "$$(git ls-files --others --exclude-standard)" |
| 28 | @git diff --quiet && git diff --cached --quiet || \ |
| 29 | { echo "refusing to build a release from a dirty tree"; exit 1; } |
| 30 | ./hack/fonts.sh |
| 31 | @./hack/fonts.sh check || { echo "refusing to build a release without Timeless Sans"; exit 1; } |
| 32 | @mkdir -p releases |
| 33 | @for dir in cmd/*/; do \ |
| 34 | app=$$(basename $$dir); \ |
| 35 | out=releases/$$app-$(RELEASE_GOOS)-$(RELEASE_GOARCH)-$(RELEASE_VERSION); \ |
| 36 | CGO_ENABLED=0 GOOS=$(RELEASE_GOOS) GOARCH=$(RELEASE_GOARCH) go build -trimpath -buildvcs=false \ |
| 37 | -ldflags "-s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=$(RELEASE_VERSION)" \ |
| 38 | -o $$out ./$$dir || exit 1; \ |
| 39 | git rev-parse HEAD > $$out.COMMIT; \ |
| 40 | echo "built $$out"; \ |
| 41 | done |
| 42 | |
| 43 | budget: |
| 44 | $(RASTRILLO) budget size |
| 45 | |
| 46 | test: |
| 47 | $(RASTRILLO) budget test -count=1 ./... |
| 48 | |
| 49 | # The real-browser suite (internal/browsertest): Chromium drives Base and the |
| 50 | # apps it installs. Set RASTRILLO_CHROME to a Chromium, and |
| 51 | # BASE_BROWSER_ARTIFACTS to a directory to keep the screenshots it takes. |
| 52 | browser: |
| 53 | go test -tags browser -count=1 -timeout 20m ./... |
| 54 | |
| 55 | vet: |
| 56 | go vet ./... |
| 57 | |
| 58 | fmt-check: |
| 59 | @out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi |
| 60 | |
| 61 | STATICCHECK := honnef.co/go/tools/cmd/staticcheck@v0.7.0 |
| 62 | staticcheck: |
| 63 | go run $(STATICCHECK) ./... |
| 64 | |
| 65 | GOVULNCHECK := golang.org/x/vuln/cmd/govulncheck@v1.8.0 |
| 66 | govulncheck: |
| 67 | go run $(GOVULNCHECK) ./... |
| 68 | |
| 69 | GITLEAKS := github.com/zricethezav/gitleaks/v8@v8.30.1 |
| 70 | gitleaks: |
| 71 | @if [ "$$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ] && [ -z "$$(git rev-parse --show-prefix)" ]; then \ |
| 72 | go run $(GITLEAKS) git --no-banner --redact --log-opts=HEAD .; \ |
| 73 | else \ |
| 74 | echo "gitleaks: not the root of a git repository, nothing committed to scan"; \ |
| 75 | fi |
| 76 | |
| 77 | # Tests the operator script against a fake carlos, and the font checks the |
| 78 | # release relies on. |
| 79 | script-test: |
| 80 | scripts/prepare-apps_test.sh |
| 81 | hack/fonts_test.sh |
| 82 | |
| 83 | # ci is the one gate: what a runner executes and what you run before pushing. |
| 84 | ci: build vet fmt-check staticcheck govulncheck gitleaks budget script-test test |
| 85 | |
| 86 | # Fetches Timeless Sans, which the licence keeps out of the repository. |
| 87 | fonts: |
| 88 | ./hack/fonts.sh |
| 89 | |
| 90 | # The native app's gate (native/): the string catalog, BaseKit's tests, the |
| 91 | # Mac app and an iPhone Simulator build. Needs a Mac with Xcode. |
| 92 | native-check: |
| 93 | native/scripts/check-native.sh |
| 94 | |