forked from uber-go/fx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (116 loc) · 3.98 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
SHELL := /bin/bash
PROJECT_ROOT := go.uber.org/fx
SUPPORT_FILES := .build
include $(SUPPORT_FILES)/colors.mk
include $(SUPPORT_FILES)/deps.mk
include $(SUPPORT_FILES)/flags.mk
include $(SUPPORT_FILES)/verbosity.mk
.PHONY: all
all: lint test
.DEFAULT_GOAL := all
COV_REPORT := overalls.coverprofile
# all .go files that don't exist in hidden directories
ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor \
-e ".*/\..*" \
-e "examples/keyvalue/.*" \
-e ".*/_.*")
TEST_TIMEOUT := "-timeout=3s"
.PHONY: test
test: examples $(COV_REPORT)
TEST_IGNORES = vendor .git
COVER_IGNORES = $(TEST_IGNORES) examples testutils
comma := ,
null :=
space := $(null) #
OVERALLS_IGNORE = $(subst $(space),$(comma),$(strip $(COVER_IGNORES)))
ifeq ($(V),0)
_FILTER_OVERALLS = cat
else
_FILTER_OVERALLS = grep -v "^Processing:"
endif
# This is the default for overalls
COVER_OUT := profile.coverprofile
$(COV_REPORT): $(PKG_FILES) $(ALL_SRC)
@$(call label,Running tests)
@echo
$(ECHO_V)$(OVERALLS) -project=$(PROJECT_ROOT) \
-ignore "$(OVERALLS_IGNORE)" \
-covermode=atomic \
$(DEBUG_FLAG) -- \
$(TEST_FLAGS) $(RACE) $(TEST_TIMEOUT) $(TEST_VERBOSITY_FLAG) | \
grep -v "No Go Test files" | \
$(_FILTER_OVERALLS)
$(ECHO_V)if [ -a $(COV_REPORT) ]; then \
$(GOCOV) convert $@ | $(GOCOV) report ; \
fi
COV_HTML := coverage.html
$(COV_HTML): $(COV_REPORT)
$(ECHO_V)$(GOCOV) convert $< | gocov-html > $@
.PHONY: coveralls
coveralls: $(COV_REPORT)
$(ECHO_V)goveralls -service=travis-ci -coverprofile=overalls.coverprofile
BENCH ?= .
BENCH_FILE ?= .bench/new.txt
.PHONY: bench
bench:
@$(call label,Running benchmarks)
$(ECHO_V)rm -f $(BENCH_FILE)
$(ECHO_V)$(foreach pkg,$(LIST_PKGS),go test -bench=. -run="^$$" $(BENCH_FLAGS) $(pkg) | \
tee -a $(BENCH_FILE);)
BASELINE_BENCH_FILE = .bench/old.txt
# Git diffs can be quote noisy, and contain all sorts of special characters, this just checks
# if there is anything in the output at all, which is what we want
GIT_DIFF = $(firstword $(shell git diff master))
.PHONY: benchbase
benchbase:
$(ECHO_V)if [ -z "$(IGNORE_BASELINE_CHECK)" ] && [ -n "$(GIT_DIFF)" ]; then \
echo "$(ERROR_STYLE)Can't record baseline with code changes off master." ; \
echo "Check out master and try again$(COLOR_RESET)"; \
exit 1; \
fi
@echo "$(LABEL_STYLE)Running baseline benchmark$(COLOR_RESET)"
@echo
$(ECHO_V)$(MAKE) bench BENCH_FILE=$(BASELINE_BENCH_FILE)
.PHONY: benchcmp
benchcmp:
$(ECHO_V)which benchcmp >/dev/null || go get -u golang.org/x/tools/cmd/benchcmp
$(ECHO_V)test -s $(BASELINE_BENCH_FILE) || \
$(call die,Baseline benchmark file missing. Check out master and run \'make benchbase\')
$(ECHO_V)test -s $(BENCH_FILE) || \
$(call label,No current benchmark file. Will generate) ;\
benchcmp $(BASELINE_BENCH_FILE) $(BENCH_FILE)
.PHONY: benchreset
benchreset:
$(ECHO_V)rm -f $(BASELINE_BENCH_FILE)
$(ECHO_V)rm -f $(BENCH_FILE)
include $(SUPPORT_FILES)/lint.mk
include $(SUPPORT_FILES)/licence.mk
.PHONY: gendoc
gendoc:
$(ECHO_V)find . -name README.md \
-not -path "./vendor/*" \
-not -path "./node_modules/*" | \
xargs -I% md-to-godoc -input=%
.PHONY: clean
clean:
$(ECHO_V)rm -f $(COV_REPORT) $(COV_HTML) $(LINT_LOG)
$(ECHO_V)find $(subst /...,,$(PKGS)) -name $(COVER_OUT) -delete
$(ECHO_V)rm -rf examples/keyvalue/kv/ .bin
.PHONY: examples
examples: .bin/thriftrw .bin/thriftrw-plugin-yarpc
@$(call label,Generating example RPC bindings)
@echo
$(ECHO_V)PATH=$(shell pwd)/.bin:$$PATH $(MAKE) -C examples/keyvalue kv/types.go ECHO_V=$(ECHO_V)
.bin/thriftrw: vendor ./vendor/go.uber.org/thriftrw/*.go
@$(call label,Building ThriftRW)
@echo
$(ECHO_V)mkdir -p .bin
$(ECHO_V)./.build/build_vendored.sh .bin go.uber.org/thriftrw
.bin/thriftrw-plugin-yarpc: vendor ./vendor/go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc/*.go
@$(call label,Building ThriftRW YARPC plugin)
@echo
$(ECHO_V)mkdir -p .bin
$(ECHO_V)./.build/build_vendored.sh .bin go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc
.PHONY: vendor
vendor:
$(ECHO_V)test -d vendor || $(MAKE) libdeps