carlos / todomvc-bakeoff Public

Clone
git clone https://amadan.net/carlos/todomvc-bakeoff

Plain git — no account needed to clone.

Download

Download this file

1# Go + Rastrillo TodoMVC. See README.md.
2#
3# GOCACHE stays at its default (a shared machine rule): COLD=1 forces a
4# from-scratch compile with -a instead of deleting the cache.
5
6APP := todo-go-rastrillo
7ACCOUNT := bfj
8VERSION ?= $(shell git rev-parse --short HEAD)
9LDFLAGS := -s -w -X 'amadan.net/rastrillo/rastrillo.BuildVersion=$(VERSION)'
10COLDFLAG := $(if $(COLD),-a,)
11RASTRILLO := go run amadan.net/rastrillo/rastrillo/cmd/rastrillo
12MESSAGE ?= Deploy $(VERSION)
13
14# The string constant make bump edits: in handlers.go, beside GET /.
15BUMP_FILE := internal/todo/handlers.go
16BUMP_FROM := const notFoundTitle = "That item is not in your list"
17BUMP_TO := const notFoundTitle = "That item is not in your list."
18
19export CGO_ENABLED = 0
20
21.PHONY: build build-arm64 test perf migration-check clean clean-deps bump unbump deploy
22
23build:
24 go build $(COLDFLAG) -trimpath -ldflags="$(LDFLAGS)" -o dist/app ./cmd/todo
25
26build-arm64:
27 GOOS=linux GOARCH=arm64 go build $(COLDFLAG) -trimpath -ldflags="$(LDFLAGS)" -o dist/app-linux-arm64 ./cmd/todo
28
29# Rastrillo's test runner: go test plus each package's time budget.
30test:
31 go vet ./...
32 test -z "$$(gofmt -l .)" || { gofmt -l .; exit 1; }
33 $(RASTRILLO) budget test ./...
34 $(RASTRILLO) migration check
35
36# Every GET screen at 150ms to first byte, cold boot at 500ms. Serial
37# and uncached, because a measurement taken beside other work isn't one.
38perf:
39 $(RASTRILLO) budget test -no-time -require TestPerfScreens,TestPerfBoot -tags perf -count=1 -p 1 -parallel 1 -run '^TestPerf' ./...
40
41clean:
42 rm -rf dist
43
44# Go keeps compiled packages in the shared GOCACHE, which this target
45# leaves alone; `make build-arm64 COLD=1` recompiles everything with -a.
46clean-deps: clean
47
48bump:
49 sed -i 's/^$(BUMP_FROM)$$/$(BUMP_TO)/' $(BUMP_FILE)
50 grep -qxF '$(BUMP_TO)' $(BUMP_FILE)
51
52unbump:
53 sed -i 's/^$(BUMP_TO)$$/$(BUMP_FROM)/' $(BUMP_FILE)
54 grep -qxF '$(BUMP_FROM)' $(BUMP_FILE)
55
56deploy:
57 carlos deploy --account $(ACCOUNT) --app $(APP) --target linux-arm64 --message "$(MESSAGE)" dist/app-linux-arm64
58