-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (42 loc) · 1.34 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
.PHONY: test clean
default: build
BINARY_FILE_NAME=metrics
COVERAGE_FILE_NAME=cover.out
COVERAGE_TMP_FILE_NAME=cover.tmp
proto:
go install github.com/golang/protobuf/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/[email protected]
PATH=${PATH}:~/go/bin protoc --go_out=plugins=grpc:. --go_opt=paths=source_relative \
api/grpc/*.proto \
api/grpc/subject/*.proto \
api/grpc/limits/*.proto \
api/grpc/source/*/*.proto \
api/grpc/interests/*.proto
vet: proto
go vet
test: vet
go test -race -cover -coverprofile=${COVERAGE_FILE_NAME} ./...
cat ${COVERAGE_FILE_NAME} | grep -v _mock.go | grep -v logging.go | grep -v .pb.go > ${COVERAGE_FILE_NAME}.tmp
mv -f ${COVERAGE_FILE_NAME}.tmp ${COVERAGE_FILE_NAME}
go tool cover -func=${COVERAGE_FILE_NAME} | grep -Po '^total\:\h+\(statements\)\h+\K.+(?=\.\d+%)' > ${COVERAGE_TMP_FILE_NAME}
./scripts/cover.sh
rm -f ${COVERAGE_TMP_FILE_NAME}
build: proto
CGO_ENABLED=0 GOOS=linux GOARCH= GOARM= go build -ldflags="-s -w" -o ${BINARY_FILE_NAME} main.go
chmod ugo+x ${BINARY_FILE_NAME}
docker:
docker build -t awakari/metrics .
run: docker
docker run \
-d \
--name awakari-metrics \
-p 50051:50051 \
--expose 50051 \
awakari/metrics
staging: docker
./scripts/staging.sh
release: docker
./scripts/release.sh
clean:
go clean
rm -f ${BINARY_FILE_NAME} ${COVERAGE_FILE_NAME}