-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (67 loc) · 2.22 KB
/
Copy pathMakefile
File metadata and controls
89 lines (67 loc) · 2.22 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
# generated by MarkRosemaker/devtool — edit files in mk/ instead.
.DEFAULT_GOAL := all
.DELETE_ON_ERROR:
# Bundles rely on their prerequisites running in order, so not with -j.
.NOTPARALLEL:
MAKEFLAGS += --no-print-directory
CLEAN_FILES := cover.out
# A tool built with an older Go than this module targets refuses to analyse it.
TOOL_GO := $(shell go env GOVERSION)
# Where make tools installs, which is GOBIN when that is set. Put on the PATH
# below so an older copy earlier on yours cannot be the one that runs.
TOOL_BIN := $(shell go env GOBIN)
ifeq ($(TOOL_BIN),)
TOOL_BIN := $(shell go env GOPATH)/bin
endif
export PATH := $(TOOL_BIN):$(PATH)
.PHONY: all ci ready lint vet vuln test test-race cover format fix tidy deps generate verify doc tools clean
# ci, plus the checks that need the network.
all: ci vuln
# ready, plus a stop on anything left unregenerated.
ci: ready verify
# After any code change. Needs no network beyond the module cache.
ready: fix generate vet test-race
lint:
golangci-lint run
vet:
go vet ./...
# Reads the vulnerability database, so it needs the network.
vuln:
govulncheck ./...
test:
go test ./...
test-race:
go test -race ./...
cover:
go test -coverprofile=cover.out ./...
go tool cover -func=cover.out
format:
golangci-lint fmt
fix:
go fix ./...
golangci-lint run --fix
tidy:
go mod tidy
go mod vendor
deps:
go get -u ./...
$(MAKE) tidy
# Everything a tool writes: the go:generate directives, then the files devtool owns.
generate:
go generate ./...
devtool update
# For a runner that did not just regenerate: it reports through git, so your own uncommitted edits look like drift.
verify: generate
git diff --exit-code
# Serves this module's documentation on :8080, as pkg.go.dev will show it.
doc:
pkgsite .
# Installs what the targets above shell out to, into $(go env GOPATH)/bin.
tools:
GOTOOLCHAIN=$(TOOL_GO) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
GOTOOLCHAIN=$(TOOL_GO) go install golang.org/x/vuln/cmd/govulncheck@latest
GOTOOLCHAIN=$(TOOL_GO) go install golang.org/x/pkgsite/cmd/pkgsite@latest
GOTOOLCHAIN=$(TOOL_GO) go install github.com/MarkRosemaker/devtool@latest
# A fragment adds its own with CLEAN_FILES += dist.
clean:
rm -rf $(CLEAN_FILES)