forked from cadence-workflow/cadence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (65 loc) · 2.18 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
.PHONY: test bins clean cover cover_ci
PROJECT_ROOT = github.com/uber/cadence
export PATH := $(GOPATH)/bin:$(PATH)
THRIFT_GENDIR=.gen
# default target
default: test
# define the list of thrift files the service depends on
# (if you have some)
THRIFT_SRCS = idl/github.com/uber/cadence/cadence.thrift \
idl/github.com/uber/cadence/shared.thrift \
idl/github.com/uber/cadence/history.thrift \
idl/github.com/uber/cadence/matching.thrift \
PROGS = cadence
TEST_ARG ?= -race -v -timeout 5m
BUILD := ./build
export PATH := $(GOPATH)/bin:$(PATH)
THRIFT_GEN=$(GOPATH)/bin/thrift-gen
define thriftrule
THRIFT_GEN_SRC += $(THRIFT_GENDIR)/go/$1/tchan-$1.go
$(THRIFT_GENDIR)/go/$1/tchan-$1.go:: $2 $(THRIFT_GEN)
@mkdir -p $(THRIFT_GENDIR)/go
$(ECHO_V)$(THRIFT_GEN) --generateThrift --packagePrefix $(PROJECT_ROOT)/$(THRIFT_GENDIR)/go/ --inputFile $2 --outputDir $(THRIFT_GENDIR)/go \
$(foreach template,$(THRIFT_TEMPLATES), --template $(template))
endef
$(foreach tsrc,$(THRIFT_SRCS),$(eval $(call \
thriftrule,$(basename $(notdir \
$(shell echo $(tsrc) | tr A-Z a-z))),$(tsrc))))
# Automatically gather all srcs
ALL_SRC := $(shell find . -name "*.go" | grep -v -e Godeps -e vendor \
-e ".*/\..*" \
-e ".*/_.*" \
-e ".*/mocks.*")
# all directories with *_test.go files in them
TEST_DIRS := $(sort $(dir $(filter %_test.go,$(ALL_SRC))))
glide:
glide install
clean_thrift:
rm -rf .gen
thriftc: clean_thrift glide $(THRIFT_GEN_SRC)
bins: thriftc
go build -i -o cadence main.go
bins_nothrift: glide
go build -i -o cadence main.go
test: bins
@rm -f test
@rm -f test.log
@for dir in $(TEST_DIRS); do \
go test -coverprofile=$@ "$$dir" | tee -a test.log; \
done;
cover_profile: clean bins_nothrift
@echo Testing packages:
@for dir in $(TEST_DIRS); do \
mkdir -p $(BUILD)/"$$dir"; \
go test "$$dir" $(TEST_ARG) -coverprofile=$(BUILD)/"$$dir"/coverage.out || exit 1; \
done;
cover: cover_profile
@for dir in $(TEST_DIRS); do \
go tool cover -html=$(BUILD)/"$$dir"/coverage.out; \
done
cover_ci: cover_profile
@for dir in $(TEST_DIRS); do \
goveralls -coverprofile=$(BUILD)/"$$dir"/coverage.out -service=travis-ci || echo -e "\x1b[31mCoveralls failed\x1b[m"; \
done
clean:
rm -rf cadence