-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (47 loc) · 1.23 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
BINARY_NAME := forgotten-fields
# Using Windows Subsystem for Linux (WSL) requires environment variable GOOS=windows when running application
WSL_FLAGS :=
UNAME_S := ${shell uname -s}
ifeq ($(UNAME_S), Linux)
WSL_FLAGS += GOOS=windows
endif
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
all: run
## tidy: formats the code
.PHONY: tidy
tidy:
@echo '$@: ${BINARY_NAME}'
go fmt ./...
go mod tidy -v
@echo '$@: successful'
## no-dirty: checks that there are no uncommited changes in the tracked files
.PHONY: no-dirty
no-dirty:
git diff --exit-code
## audit: runs quality control checks
.PHONY: audit
audit:
@echo '$@: Running quality control checks..'
go mod verify
go vet ./...
go run honnef.co/go/tools/cmd/staticcheck@latest -checks=all,-ST1000,-U1000 ./...
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
@echo '$@: successful'
## build: build the application
.PHONY: build
build:
@echo '$@: Building ${BINARY_NAME}...'
$(WSL_FLAGS) go build -o ./build/tmp/bin/${BINARY_NAME}
@echo '$@: successful'
## run: run the application
.PHONY: run
run: build
./build/tmp/bin/${BINARY_NAME}
## clean: remove build related files
.PHONY: clean
clean:
go clean
rm -rf ./build