Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (62 loc) · 1.79 KB
/
Copy pathMakefile
File metadata and controls
83 lines (62 loc) · 1.79 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
.DEFAULT_GOAL := build
APP := mezzo
CMD := ./cmd/$(APP)
GO ?= go
GOFLAGS ?=
ARGS ?=
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS ?= -s -w -X main.version=$(VERSION)
BUILD_FLAGS ?= -trimpath -ldflags "$(LDFLAGS)"
GORELEASER_VERSION ?= latest
GORELEASER ?= $(GO) run github.com/goreleaser/goreleaser/v2@$(GORELEASER_VERSION)
.PHONY: help all build run test test-race lint vet fmt fmt-check tidy generate check clean snapshot release
help:
@printf '%s\n' \
'Targets:' \
' make build Build ./mezzo' \
' make run Run the app with go run (override ARGS=...)' \
' make test Run unit tests' \
' make test-race Run tests with the race detector' \
' make lint Run formatting check and go vet' \
' make fmt Format Go files' \
' make tidy Tidy go.mod/go.sum' \
' make generate Run go generate' \
' make snapshot Build a local GoReleaser snapshot' \
' make release Publish a GoReleaser release' \
' make clean Remove build output' \
' make check Run lint, tests, and build' \
'' \
'Examples:' \
' make run ARGS="-verbose"' \
' make build VERSION=canary'
all: check
build:
$(GO) build $(GOFLAGS) $(BUILD_FLAGS) -o $(APP) $(CMD)
run:
$(GO) run $(GOFLAGS) $(CMD) $(ARGS)
test:
$(GO) test $(GOFLAGS) ./...
test-race:
$(GO) test $(GOFLAGS) -race ./...
lint: fmt-check vet
vet:
$(GO) vet $(GOFLAGS) ./...
fmt:
$(GO) fmt $(GOFLAGS) ./...
fmt-check:
@test -z "$$($(GO)fmt -l .)" || { \
echo 'Go files need formatting:'; \
$(GO)fmt -l .; \
exit 1; \
}
tidy:
$(GO) mod tidy
generate:
$(GO) generate $(GOFLAGS) ./...
check: lint test build
snapshot:
$(GORELEASER) release --snapshot --clean
release:
$(GORELEASER) release --clean
clean:
rm -rf $(APP) dist coverage.out