-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
104 lines (76 loc) · 2.64 KB
/
Makefile
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Makefile Copyright Alex Edwards, MIT licensed
#
# https://www.alexedwards.net/blog/a-time-saving-makefile-for-your-go-projects
# https://gist.github.com/alexedwards/3b40775846535d0014ab1ff477e4a568
# HELPERS
# ========================================================================== #
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
.PHONY: confirm
confirm:
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
.PHONY: no-dirty
no-dirty:
git diff --exit-code > /dev/null
git diff --staged --exit-code > /dev/null
# ========================================================================== #
# QUALITY CONTROL
# ========================================================================== #
## tidy: format code and tidy modfile
.PHONY: tidy
tidy:
go fmt ./...
go mod tidy -v
## audit: run quality control checks
AUDITS=lint misspell verify format vet ineffassign staticcheck race metalint
# vulncheck is commented out until we switch to 1.20.5
.PHONY: audit
audit: $(foreach audit,$(AUDITS),audit/$(audit))
audit/verify:
go mod verify
audit/format:
test -z $$(gofmt -l .)
audit/vet:
go vet ./...
audit/ineffassign:
go run github.com/gordonklaus/ineffassign@latest ./...
audit/staticcheck:
go run honnef.co/go/tools/cmd/staticcheck@latest -checks=all,-ST1000,-U1000 ./...
audit/vulncheck:
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
audit/race:
go test -race -buildvcs -vet=off ./...
audit/lint:
go run github.com/mgechev/revive@latest -set_exit_status ./...
audit/misspell:
go run github.com/client9/misspell/cmd/misspell@latest -error .
audit/metalint:
go run github.com/golangci/golangci-lint/cmd/[email protected] \
run -E misspell --exclude-use-default=0 -E revive
# ========================================================================== #
# DEVELOPMENT
# ========================================================================== #
## test: run all tests
.PHONY: test
test:
go test -v -race -buildvcs ./...
## test/cover: run all tests and display coverage
.PHONY: test/cover
test/cover:
go test -v -race -buildvcs -coverprofile=/tmp/coverage.out ./...
go tool cover -html=/tmp/coverage.out
## build: build the application
.PHONY: build
build:
# Include additional build steps, like TypeScript, SCSS or Tailwind compilation here...
go build -v ./...
# ========================================================================== #
# OPERATIONS
# ========================================================================== #
## push: push changes to the remote Git repository
.PHONY: push
push: tidy audit no-dirty
git push