-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
63 lines (49 loc) · 2 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
TMP_DIR := .tmp
RELEASE_VER := $(shell git rev-parse --short HEAD)
NAME = default
COVERMODE = atomic
TEST_PACKAGES := $(shell go list ./... | grep -v vendor | grep -v fakes)
.PHONY: help
.DEFAULT_GOAL := help
# Under the hood, `go test -tags ...` also runs the "default" (unit) test case
# in addition to the specified tags
test: test/integration ## Perform both unit and integration tests
testv: testv/integration ## Perform both unit and integration tests (with verbose flags)
test/unit: ## Perform unit tests
go test -cover $(TEST_PACKAGES)
testv/unit: ## Perform unit tests (with verbose flag)
go test -v -cover $(TEST_PACKAGES)
test/integration: ## Perform integration tests
go test -cover -tags integration $(TEST_PACKAGES)
testv/integration: ## Perform integration tests
go test -v -cover -tags integration $(TEST_PACKAGES)
test/race: ## Perform unit tests and enable the race detector
go test -race -cover $(TEST_PACKAGES)
test/cover: ## Run all tests + open coverage report for all packages
echo 'mode: $(COVERMODE)' > .coverage
for PKG in $(TEST_PACKAGES); do \
go test -coverprofile=.coverage.tmp -tags "integration" $$PKG; \
grep -v -E '^mode:' .coverage.tmp >> .coverage; \
done
go tool cover -html=.coverage
$(RM) .coverage .coverage.tmp
test/codecov: ## Run all tests + create coverage report (used by codecov)
ECODE=0; \
for PKG in $(TEST_PACKAGES); do \
go test -tags integration -covermode=$(COVERMODE) -coverprofile=profile.out $$PKG; \
ECODE=$$((ECODE+$$?));\
if [ -f profile.out ]; then\
cat profile.out >> coverage.txt;\
rm profile.out;\
fi;\
done;\
$(RM) profile.out ;\
exit $$ECODE;\
installdeps: ## Install needed dependencies for various middlewares
go get -t -v ./...
generate: ## Run generate for non-vendor packages only
go list ./... | xargs go generate
help: ## Display this help message
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
grep -v '#'