-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (68 loc) · 2.15 KB
/
Copy pathMakefile
File metadata and controls
85 lines (68 loc) · 2.15 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
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
PKG := github.com/alephao/snapdiff
BIN := snapdiff
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
TEMPL ?= $(HOME)/go/bin/templ
PLATFORMS := \
darwin/amd64 \
darwin/arm64 \
linux/amd64 \
linux/arm64 \
windows/amd64
.PHONY: all build generate test vet fmt lint release clean acceptance \
screenshots screenshots-update screenshots-install
all: lint test build
generate:
@if [ ! -x "$(TEMPL)" ]; then \
echo "templ not found at $(TEMPL); run: GOBIN=\$$HOME/go/bin go install github.com/a-h/templ/cmd/templ@latest" >&2; \
exit 1; \
fi
$(TEMPL) generate -path ./internal/web/views
build: generate
go build -ldflags '$(LDFLAGS)' -o $(BIN) ./cmd/snapdiff
install: build
@echo 'Deleting old binary'
@sudo rm -f /usr/local/bin/snapdiff
@echo 'Copying binary to /usr/local/bin/snapdiff'
@sudo cp ./snapdiff /usr/local/bin/snapdiff
@echo 'Now you can run snapdiff'
test:
go test ./...
acceptance:
go test -tags acceptance -count=1 ./test/acceptance/...
vet:
go vet ./...
fmt:
gofmt -w .
lint:
@diff_files=$$(gofmt -l . | grep -v '_templ\.go$$' || true); \
if [ -n "$$diff_files" ]; then \
echo "gofmt needed:"; echo "$$diff_files"; exit 1; \
fi
go vet ./...
clean:
rm -rf $(BIN) dist/
# Visual-regression screenshot suite (Playwright). Opt-in: requires Node
# + chromium installed in tests-screenshots/. See docs/adr/0017-*.md.
screenshots-install:
@cd tests-screenshots && pnpm install && pnpm exec playwright install chromium
screenshots:
@cd tests-screenshots && pnpm exec playwright test
screenshots-update:
@cd tests-screenshots && pnpm exec playwright test --update-snapshots
# Cross-compile the matrix from a single host (CGO disabled).
release: generate
mkdir -p dist
@for p in $(PLATFORMS); do \
os=$${p%/*}; arch=$${p#*/}; \
ext=""; [ "$$os" = "windows" ] && ext=".exe"; \
out="dist/$(BIN)-$$os-$$arch$$ext"; \
echo "==> $$out"; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch \
go build -ldflags '$(LDFLAGS)' -o "$$out" ./cmd/snapdiff || exit 1; \
done
@echo "==> dist/"
@ls -lh dist/