-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (65 loc) · 3.23 KB
/
Copy pathMakefile
File metadata and controls
86 lines (65 loc) · 3.23 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
.PHONY: all build test test-verbose test-cover lint fmt vet clean help
# ─── Variables ────────────────────────────────────────────────────────────────
MODULE := $(shell go list -m)
BINARY := bin/isoserver
CMD := ./cmd/isoserver
COVERAGE := coverage.out
GO := go
GOFLAGS :=
# ─── Default ──────────────────────────────────────────────────────────────────
all: fmt vet test build
# ─── Build ────────────────────────────────────────────────────────────────────
build:
@echo "» building $(BINARY)"
@mkdir -p bin
$(GO) build $(GOFLAGS) -o $(BINARY) $(CMD)
# ─── Test ─────────────────────────────────────────────────────────────────────
test:
@echo "» running tests"
$(GO) test $(GOFLAGS) ./...
test-verbose:
@echo "» running tests (verbose)"
$(GO) test $(GOFLAGS) -v ./...
test-cover:
@echo "» running tests with coverage"
$(GO) test $(GOFLAGS) -coverprofile=$(COVERAGE) -covermode=atomic ./...
$(GO) tool cover -func=$(COVERAGE)
cover-html: test-cover
@echo "» opening coverage report in browser"
$(GO) tool cover -html=$(COVERAGE)
# ─── Code Quality ─────────────────────────────────────────────────────────────
fmt:
@echo "» formatting"
$(GO) fmt ./...
vet:
@echo "» vetting"
$(GO) vet ./...
lint:
@echo "» linting"
@which golangci-lint > /dev/null 2>&1 || { \
echo "golangci-lint not found — install from https://golangci-lint.run/usage/install/"; \
exit 1; \
}
golangci-lint run ./...
# ─── Maintenance ──────────────────────────────────────────────────────────────
tidy:
@echo "» tidying modules"
$(GO) mod tidy
clean:
@echo "» cleaning"
@rm -rf bin $(COVERAGE)
# ─── Help ─────────────────────────────────────────────────────────────────────
help:
@echo "Usage: make <target>"
@echo ""
@echo " all fmt + vet + test + build (default)"
@echo " build compile cmd/isoserver to bin/isoserver"
@echo " test run all tests"
@echo " test-verbose run all tests with -v"
@echo " test-cover run tests and print coverage summary"
@echo " cover-html run tests and open HTML coverage report"
@echo " fmt gofmt all packages"
@echo " vet go vet all packages"
@echo " lint run golangci-lint (must be installed)"
@echo " tidy go mod tidy"
@echo " clean remove bin/ and coverage.out"