-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
152 lines (103 loc) · 2.73 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
BINARY_NAME:=waku
TAG ?= latest
ifeq ($(OS),Windows_NT)
RM_CMD:=rd /s /q
NULL:=/dev/nul
EXT:=.exe
else
RM_CMD:=rm -rf
NULL:=/dev/null
EXT=
endif
# =================================== DEFAULT =================================== #
default: all
## default: Runs build and test
.PHONY: default
all: build test
# =================================== HELPERS =================================== #
## help: print this help message
.PHONY: help
help:
@echo 'Waku - You can run the CLI with "go run main.go"'
@echo ''
@echo 'Usage: make [target]'
@echo ''
@echo 'Commands:'
@sed -n 's/^## //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
@echo ''
@echo 'Extra:'
@sed -n 's/^### //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
## install: Install dependencies
.PHONY: install
install:
go get ./...
# =================================== DEVELOPMENT =================================== #
## docs: Runs Documentation
.PHONY: docs
docs:
mkdocs serve -f www/mkdocs.yml -a 0.0.0.0:8000
## build: Builds Go binary
.PHONY: build
build:
go build -ldflags="-s -w" -o $(BINARY_NAME)$(EXT) main.go
## build/docs: Builds documentation
build/docs:
mkdocs build -f www/mkdocs.yml
### build/docker: Builds Docker image
build/docker:
docker build . -t $(BINARY_NAME):$(TAG)
## test: Runs tests
.PHONY: test
test:
go mod tidy
go mod verify
go vet ./...
go run github.com/securego/gosec/v2/cmd/gosec@latest -quiet ./...
go run github.com/go-critic/go-critic/cmd/gocritic@latest check -enableAll ./...
go run github.com/google/osv-scanner/cmd/osv-scanner@latest -r .
go test -v -race ./...
## bench: Run benchmarks
bench:
go test -v -bench=. -benchmem ./...
## bump: Quickly bump Waku version (X.X.X, X.X.X-rc.X, etc.)
bump:
@VERSION=$(version) ; \
if [ -z "$$VERSION" ]; then \
echo "Usage: make bump version=x.x.x"; \
exit 1; \
fi; \
./scripts/version_bump.sh "$$VERSION"
# =================================== QUALITY ================================== #
## lint: Lint code
.PHONY: lint
lint: lint/go lint/npm
### lint/go: Lint Go code
.PHONY: lint/go
lint/go:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run
### lint/npm: Lint NPM code
.PHONY: lint/npm
lint/npm:
prettier --cache --check .
## format: Format code
.PHONY: format
format: format/go format/npm
### format/go: Format Go code
.PHONY: format/go
format/go:
go fmt ./...
go mod tidy -v
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run --fix
### format/npm: Format NPM code
.PHONY: format/npm
format/npm:
prettier --cache --write .
## tidy: Clean up code artifacts
.PHONY: tidy
tidy:
go clean ./...
${RM_CMD} $(BINARY_NAME)$(EXT)
## clean: Remove node_modules
.PHONY: clean
clean: tidy
${RM_CMD} node_modules