-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
78 lines (62 loc) · 2.41 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
# Some things this makefile could make use of:
#
# - test coverage target(s)
# - profiler target(s)
#
OUTPUT_DIR = build
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: installdeps test/integration ## Perform both unit and integration tests
testv: installdeps 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/cc: ## Run all tests + create coverage report for code climate
echo 'mode: $(COVERMODE)' > c.out
for PKG in $(TEST_PACKAGES); do \
go test -covermode=$(COVERMODE) -coverprofile=.coverage.tmp $$PKG; \
if [ -f .coverage.tmp ]; then\
grep -v -E '^mode:' .coverage.tmp >> c.out; \
rm .coverage.tmp;\
fi;\
done
$(RM) .coverage.tmp
test/codecov: ## Run all tests + open coverage report for all packages
for PKG in $(TEST_PACKAGES); do \
go test -covermode=$(COVERMODE) -coverprofile=profile.out $$PKG; \
if [ -f profile.out ]; then\
cat profile.out >> coverage.txt;\
rm profile.out;\
fi;\
done
$(RM) profile.out
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 '#'