Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (48 loc) · 1.54 KB
/
Copy pathMakefile
File metadata and controls
64 lines (48 loc) · 1.54 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
GO ?= go
GOLANGCI_LINT ?= golangci-lint
DIRECT_DEPS_TEMPLATE := {{if and (not .Main) (not .Indirect) (not .Replace)}}{{.Path}}{{end}}
# Resolve go-sphere modules straight from GitHub, bypassing the module proxy
# and its cached "@latest", which lags behind freshly pushed tags.
DIRECT_ORIGIN := GOPRIVATE=github.com/go-sphere/*
.DEFAULT_GOAL := check
.PHONY: deps-update tidy tidy-check fmt build test lint buf-check check verify breaking generate
deps-update:
@GOWORK=off $(DIRECT_ORIGIN) $(GO) mod tidy; \
deps="$$(GOWORK=off $(DIRECT_ORIGIN) $(GO) list -m -f '$(DIRECT_DEPS_TEMPLATE)' all)"; \
if [ -n "$$deps" ]; then GOWORK=off $(DIRECT_ORIGIN) $(GO) get -u $$deps; fi
GOWORK=off $(DIRECT_ORIGIN) $(GO) mod tidy
tidy:
GOWORK=off $(GO) mod tidy
# Non-mutating counterpart of tidy, for CI: fails if go.mod/go.sum are not
# what a consumer would resolve.
tidy-check:
GOWORK=off $(GO) mod tidy -diff
fmt:
$(GO) fmt ./...
$(GOLANGCI_LINT) fmt --no-config --enable gofmt --enable goimports
buf format -w
build:
$(GO) build ./...
test:
$(GO) test ./...
lint:
$(GOLANGCI_LINT) fmt --no-config --enable gofmt --enable goimports --diff
$(GO) vet ./...
$(GOLANGCI_LINT) run --no-config
$(MAKE) buf-check
# The proto module is the published artifact: lint it for style and compile it
# so a bad import or descriptor never reaches buf.build.
buf-check:
buf lint
buf build
check: tidy-check
$(MAKE) lint
$(MAKE) test
verify: check breaking
breaking:
buf breaking . --against '.git#tag=v0.0.1'
generate:
buf generate
buf format -w
buf lint
buf push