-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
54 lines (48 loc) · 1.65 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
.PHONY: run-server
run-server: compile
@echo "===> starting server..."
@./build/server
.PHONY: compile
compile:
@echo "=> installing dependencies..."
go mod tidy
@echo "==> Compiling walrus..."
go build -o build/server cmd/server/v1/main.go
.PHONY: test
test:
@echo "==> Running tests..."
go test ./... --race -count=1 -v
.PHONY: test-coverage
test-coverage:
@echo "==> Running tests..."
go test -failfast --race -count=1 -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
.PHONY: lint
lint:
ifeq (, $(shell which $$(go env GOPATH)/bin/golangci-lint))
@echo "==> golangci-lint not installed, trying to install it..."
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.42.1
endif
$$(go env GOPATH)/bin/golangci-lint run -c ./.golangci.yml ./...
.PHONY: generate
generate: compile-proto
@go mod tidy
@go install github.com/matryer/moq@latest
@echo "==>cleaning up generated files"
find . -type f -name '*_mock.go' -exec rm {} +
@echo "==>running go generate..."
go generate ./...
.PHONY: compile-proto
compile-proto:
@echo "==> Checking buf dependencies..."
ifeq (, $(shell command -v buf 2> /dev/null))
@echo "==> Setup: Buf not installed, please follow the instructions on https://docs.buf.build/installation"
endif
@echo "==> compiling proto..."
@echo "===> generating grpc code..."
@go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
@buf generate