-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) · 2.43 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
VERSION_PATH=$(shell go list -m -f "{{.Path}}")/version
LDFLAGS=-w -s \
-X ${VERSION_PATH}.gitRepo=$(shell go list -m -f "{{.Path}}") \
-X ${VERSION_PATH}.gitBranch=$(shell git rev-parse --abbrev-ref HEAD) \
-X ${VERSION_PATH}.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
-X ${VERSION_PATH}.gitCommit=$(shell git rev-parse --short HEAD) \
-X ${VERSION_PATH}.gitTag=$(shell git describe --exact-match --tags HEAD 2> /dev/null || echo "") \
-X ${VERSION_PATH}.kubectlVersion=$(shell go list -m -f "{{.Path}} {{.Version}}" all | grep k8s.io/client-go | cut -d " " -f2) \
.PHONY: build_tools
build_tools:
go install \
github.com/envoyproxy/protoc-gen-validate \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
google.golang.org/protobuf/cmd/protoc-gen-go \
github.com/golangci/golangci-lint/cmd/golangci-lint \
golang.org/x/tools/cmd/goimports
.PHONY: gen
gen:
cd hack && ./gen_proto.sh && cd .. && make fmt
.PHONY: lint
lint:
golangci-lint run -D errcheck
.PHONY: release
release: build_linux_amd64 build_darwin_amd64 build_darwin_arm64
.PHONY: fmt
fmt:
gofmt -s -w ./pkg && \
gofmt -s -w -r 'interface{} -> any' ./internal ./plugins ./tools ./version ./third_party ./cmd && \
goimports -w ./
.PHONY: serve
serve:
go run -race main.go serve --debug --app_port 4000
.PHONY: build_race
build_race:
CGO_ENABLED=1 go build -ldflags="${LDFLAGS}" -race -o app main.go
.PHONY: build
build:
CGO_ENABLED=1 go build -ldflags="${LDFLAGS}" -o app main.go
.PHONY: build_web
build_web:
cd ./frontend && yarn build
.PHONY: test
test:
go test ./... -race -count=1 -cover
.PHONY: build_linux_amd64
build_linux_amd64:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o app-linux-amd64 main.go
.PHONY: build_linux_arm64
build_linux_arm64:
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS} -extldflags '-static'" -o app-linux-arm64 main.go
.PHONY: build_darwin_amd64
build_darwin_amd64:
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o app-darwin-amd64 main.go
.PHONY: build_darwin_arm64
build_darwin_arm64:
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o app-darwin-arm64 main.go
.PHONY: build_windows
build_windows:
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o app.exe main.go