forked from raystack/raccoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
86 lines (62 loc) · 2.15 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
.PHONY: all
ALL_PACKAGES=$(shell go list ./... | grep -v "vendor")
APP_EXECUTABLE="out/raccoon"
COVER_FILE="/tmp/coverage.out"
all: install-protoc setup compile
# Setups
setup: generate-proto copy-config
make update-deps
install-protoc:
@echo "> installing dependencies"
go get -u github.com/golang/protobuf/[email protected]
go get -u github.com/golang/protobuf/[email protected]
go get -u google.golang.org/grpc/cmd/[email protected]
update-deps:
go mod tidy -v
go mod vendor
copy-config:
cp .env.sample .env
PROTO_PACKAGE=/proto
generate-proto:
rm -rf .temp
mkdir -p .temp
curl -o .temp/proton.tar.gz -L http://api.github.com/repos/odpf/proton/tarball/main; tar xvf .temp/proton.tar.gz -C .temp/ --strip-components 1
protoc --proto_path=.temp/ .temp/odpf/raccoon/v1beta1/raccoon.proto --go_out=./ --go_opt=paths=import --go_opt=Modpf/raccoon/v1beta1/raccoon.proto=$(PROTO_PACKAGE)
protoc --proto_path=.temp/ .temp/odpf/raccoon/v1beta1/raccoon.proto --go-grpc_opt=paths=import --go-grpc_opt=Modpf/raccoon/v1beta1/raccoon.proto=$(PROTO_PACKAGE) --go-grpc_out=./
# Build Lifecycle
compile:
mkdir -p out/
go build -o $(APP_EXECUTABLE)
build: copy-config update-deps compile
install:
go install $(ALL_PACKAGES)
start: build
./$(APP_EXECUTABLE)
clean: ## Clean the builds
rm -rf out/
# Utility
fmt:
go fmt $(ALL_PACKAGES)
vet:
go vet $(ALL_PACKAGES)
lint:
@for p in $(ALL_PACKAGES); do \
echo "==> Linting $$p"; \
golint $$p | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } \
done
# Tests
test: lint
ENVIRONMENT=test go test $(shell go list ./... | grep -v "vendor" | grep -v "integration") -v
@go list ./... | grep -v "vendor" | grep -v "integration" | xargs go test -count 1 -cover -short -race -timeout 1m -coverprofile ${COVER_FILE}
@go tool cover -func ${COVER_FILE} | tail -1 | xargs echo test coverage:
test-bench: # run benchmark tests
@go test $(shell go list ./... | grep -v "vendor") -v -bench ./... -run=^Benchmark
test_ci: install-protoc setup test
# Docker Run
docker-run:
docker-compose build
docker-compose up -d
docker-stop:
docker-compose stop
docker-start:
docker-compose start