-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
101 lines (73 loc) · 2.6 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
GO ?= go
GOFMT ?= $(GO)fmt
pkgs = ./...
HUGO ?= hugo
help: Makefile
@echo
@echo " Choose a command run in Beetle:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
## install_revive: Install revive for linting.
install_revive:
@echo ">> ============= Install Revive ============= <<"
$(GO) install github.com/mgechev/revive@latest
## style: Check code style.
style:
@echo ">> ============= Checking Code Style ============= <<"
@fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \
if [ -n "$${fmtRes}" ]; then \
echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
echo "Please ensure you are using $$($(GO) version) for formatting code."; \
exit 1; \
fi
## check_license: Check if license header on all files.
check_license:
@echo ">> ============= Checking License Header ============= <<"
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
done); \
if [ -n "$${licRes}" ]; then \
echo "license header checking failed:"; echo "$${licRes}"; \
exit 1; \
fi
## test_short: Run test cases with short flag.
test_short:
@echo ">> ============= Running Short Tests ============= <<"
$(GO) test -mod=readonly -short $(pkgs)
## test: Run test cases.
test:
@echo ">> ============= Running All Tests ============= <<"
$(GO) test -mod=readonly -v -cover $(pkgs)
## lint: Lint the code.
lint:
@echo ">> ============= Lint All Files ============= <<"
revive -config config.toml -exclude vendor/... -formatter friendly ./...
## verify: Verify dependencies
verify:
@echo ">> ============= List Dependencies ============= <<"
$(GO) list -m all
@echo ">> ============= Verify Dependencies ============= <<"
$(GO) mod verify
## format: Format the code.
format:
@echo ">> ============= Formatting Code ============= <<"
$(GO) fmt $(pkgs)
## vet: Examines source code and reports suspicious constructs.
vet:
@echo ">> ============= Vetting Code ============= <<"
$(GO) vet $(pkgs)
## coverage: Create HTML coverage report
coverage:
@echo ">> ============= Coverage ============= <<"
rm -f coverage.html cover.out
$(GO) test -mod=readonly -coverprofile=cover.out $(pkgs)
go tool cover -html=cover.out -o coverage.html
## ci: Run all CI tests.
ci: style check_license test vet lint
@echo "\n==> All quality checks passed"
## run: Run the service
run:
-cp -n config.dist.yml config.prod.yml
$(GO) run beetle.go serve -c config.prod.yml
.PHONY: help