-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
34 lines (27 loc) · 1.05 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
ROOT_DIR = $(shell pwd)
PROTO_DIR = $(ROOT_DIR)/protos
COVERAGE_DIR = $(ROOT_DIR)/coverage
COV_UNIT_DIR = $(COVERAGE_DIR)/unit
COV_INTEGRATION_DIR = $(COVERAGE_DIR)/integration
.PHONY: protos
protos:
protoc --proto_path=$(PROTO_DIR) --go_out=$(PROTO_DIR) --go_opt=paths=source_relative \
--go-grpc_out=$(PROTO_DIR) --go-grpc_opt=paths=source_relative $(PROTO_DIR)/*.proto
.PHONY: test
test: integration unit
.PHONY: integration
integration:
mkdir -p $(COV_INTEGRATION_DIR) || true
go test -tags=integration -timeout 30m -cover ./... -args -test.gocoverdir=$(COV_INTEGRATION_DIR)
.PHONY: unit
unit:
mkdir -p $(COV_UNIT_DIR) || true
go test -tags=unit -cover ./... -args -test.gocoverdir=$(COV_UNIT_DIR)
.PHONY: coverage
coverage: test
go tool covdata textfmt -i="$(COV_INTEGRATION_DIR),$(COV_UNIT_DIR)" -o=$(COVERAGE_DIR)/tmp.cov
go tool cover -func=$(COVERAGE_DIR)/tmp.cov
grep -v 'testutils.go' $(COVERAGE_DIR)/tmp.cov > $(COVERAGE_DIR)/total.cov
PHONY: view-coverage
view-coverage: $(COVERAGE_DIR)/total.cov
go tool cover -html=$(COVERAGE_DIR)/total.cov