-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (83 loc) · 3.41 KB
/
Makefile
File metadata and controls
104 lines (83 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
GOCACHE ?= $(CURDIR)/.gocache
BIN_DIR ?= $(CURDIR)/bin
APP = formlander
TAILWIND = $(BIN_DIR)/tailwindcss
WATCHEXEC ?= $(shell command -v watchexec 2>/dev/null)
GOTESTSUM ?= $(shell command -v gotestsum 2>/dev/null)
.PHONY: help build run seed dev test test-unit test-e2e test-e2e-setup test-integration tidy fmt clean deps release vendor css css-watch
help:
@echo "Available targets:"
@echo " deps - ensure local build cache directory exists"
@echo " vendor - download JS/CSS dependencies (htmx, highlight.js, tailwind)"
@echo " css - build Tailwind CSS for production"
@echo " css-watch - watch and rebuild Tailwind CSS on changes"
@echo " build - compile the CLI binary to $(BIN_DIR)"
@echo " run - run the application from source"
@echo " dev - hot-reload the server using watchexec (requires .env)"
@echo " test - run unit & e2e tests"
@echo " test-unit - run package tests under internal/"
@echo " test-e2e - run Playwright end-to-end tests in e2e/"
@echo " test-e2e-setup - install Playwright dependencies"
@echo " test-integration - run VM-based installer integration tests (requires Multipass)"
@echo " tidy - add/remove go.mod entries"
@echo " fmt - gofmt Go source files"
@echo " clean - remove build artifacts"
@echo " release - build & push multi-arch Docker images"
deps:
@mkdir -p $(GOCACHE) $(BIN_DIR)
vendor:
@./scripts/vendor.sh
css: vendor
@echo ">> building Tailwind CSS"
$(TAILWIND) -i web/static/app.css -o web/static/app.built.css --minify
css-watch: vendor
@echo ">> watching Tailwind CSS"
$(TAILWIND) -i web/static/app.css -o web/static/app.built.css --watch
COMMIT_SHA ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "dev")
build: deps css
@echo ">> building $(APP)"
GOCACHE=$(GOCACHE) go build -ldflags="-X formlander/internal/server.buildCommit=$(COMMIT_SHA)" -o $(BIN_DIR)/$(APP) ./cmd/$(APP)
run: deps
FORMLANDER_ENV=development GOCACHE=$(GOCACHE) go run ./cmd/$(APP)
seed: deps
@echo ">> seeding database"
FORMLANDER_ENV=development GOCACHE=$(GOCACHE) go run ./cmd/$(APP) --seed
dev: deps
ifeq ($(strip $(WATCHEXEC)),)
@echo "watchexec not found. Install via 'brew install watchexec' or see https://github.com/watchexec/watchexec"
@exit 1
else
FORMLANDER_ENV=development GOCACHE=$(GOCACHE) $(WATCHEXEC) --clear --restart \
--watch cmd --watch internal --watch web \
--exts go,html,tmpl \
-- go run ./cmd/$(APP)
endif
test: test-unit test-e2e
test-unit: deps
ifeq ($(strip $(GOTESTSUM)),)
@echo ">> go test ./internal/..."
FORMLANDER_ENV=test GOCACHE=$(GOCACHE) go test ./internal/...
else
@echo ">> gotestsum ./internal/..."
FORMLANDER_ENV=test GOCACHE=$(GOCACHE) $(GOTESTSUM) --format testname -- -count=1 ./internal/...
endif
test-e2e-setup:
@echo ">> installing Playwright dependencies"
cd e2e && npm install && npx playwright install --with-deps chromium
test-e2e: deps
@echo ">> running Playwright E2E tests"
cd e2e && npm test
test-integration: build
@echo ">> running VM-based installer integration tests"
@echo " (requires Multipass: brew install multipass)"
FORMLANDER_ENV=test BINARY_PATH=$(BIN_DIR)/$(APP) go test -v -timeout 15m ./tests/integration/...
tidy: deps
GOCACHE=$(GOCACHE) go mod tidy
fmt:
@echo ">> formatting Go files"
go fmt ./...
clean:
@echo ">> removing build artifacts"
rm -rf $(BIN_DIR)/$(APP)
release:
@scripts/release.sh