forked from uber/tchannel-go
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
133 lines (107 loc) · 4.77 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
PATH := $(GOPATH)/bin:$(PATH)
EXAMPLES=./examples/bench/server ./examples/bench/client ./examples/ping ./examples/thrift ./examples/hyperbahn/echo-server
PROD_PKGS := . ./http ./hyperbahn ./json ./peers ./pprof ./raw ./relay ./stats ./thrift $(EXAMPLES)
TEST_ARG ?= -race -v -timeout 5m
COV_PKG ?= ./
BUILD := ./build
THRIFT_GEN_RELEASE := ./thrift-gen-release
THRIFT_GEN_RELEASE_LINUX := $(THRIFT_GEN_RELEASE)/linux-x86_64
THRIFT_GEN_RELEASE_DARWIN := $(THRIFT_GEN_RELEASE)/darwin-x86_64
PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m)
BIN := $(shell pwd)/.bin
# Cross language test args
TEST_HOST=127.0.0.1
TEST_PORT=0
-include crossdock/rules.mk
all: test examples
$(BIN)/thrift:
mkdir -p $(BIN)
scripts/install-thrift.sh -o $(BIN)
packages_test:
go list -json ./... | jq -r '. | select ((.TestGoFiles | length) > 0) | .ImportPath'
setup:
mkdir -p $(BUILD)
mkdir -p $(BUILD)/examples
mkdir -p $(THRIFT_GEN_RELEASE_LINUX)
mkdir -p $(THRIFT_GEN_RELEASE_DARWIN)
(cd $(BUILD) && go mod init "github.com/temporalio/tchannel-go")
install_ci: $(BIN)/thrift install
ifdef CROSSDOCK
$(MAKE) install_docker_ci
endif
help:
@egrep "^# target:" [Mm]akefile | sort -
clean:
echo Cleaning build artifacts...
go clean
rm -rf $(BUILD) $(THRIFT_GEN_RELEASE)
echo
fmt format:
echo Formatting Packages...
git ls-files | grep ".go$$" | xargs gofmt -l -s -w
echo
test_ci:
ifdef CROSSDOCK
$(MAKE) crossdock_ci
else
$(MAKE) test
endif
test: clean setup $(BIN)/thrift
@echo Testing packages:
PATH=$(BIN):$$PATH go test -parallel=4 $(TEST_ARG) ./...
@echo Running frame pool tests
PATH=$(BIN):$$PATH go test -run TestFramesReleased -stressTest $(TEST_ARG)
benchmark: clean setup $(BIN)/thrift
echo Running benchmarks:
PATH=$(BIN)::$$PATH go test ./... -bench=. -cpu=1 -benchmem -run NONE
cover_profile: clean setup $(BIN)/thrift
@echo Testing packages:
mkdir -p $(BUILD)
PATH=$(BIN)::$$PATH go test $(COV_PKG) $(TEST_ARG) -coverprofile=$(BUILD)/coverage.out
cover: cover_profile
go tool cover -html=$(BUILD)/coverage.out
cover_ci:
@echo "Uploading coverage"
$(MAKE) cover_profile
curl -s https://codecov.io/bash > $(BUILD)/codecov.bash
bash $(BUILD)/codecov.bash -f $(BUILD)/coverage.out
FILTER := grep -v -e '_string.go' -e '/gen-go/' -e '/mocks/' -e 'vendor/'
lint:
@echo "Running go vet"
-go vet ./... 2>&1 | fgrep -v -e "possible formatting directiv" -e "exit status" | tee -a lint.log
@echo "Verifying files are gofmt'd"
-gofmt -l . | $(FILTER) | tee -a lint.log
@echo "Checking for unresolved FIXMEs"
-git grep -i -n fixme | $(FILTER) | grep -v -e Makefile | tee -a lint.log
@[ ! -s lint.log ]
thrift_example: thrift_gen
go build -o $(BUILD)/examples/thrift ./examples/thrift/main.go
test_server:
./build/examples/test_server --host ${TEST_HOST} --port ${TEST_PORT}
examples: clean setup thrift_example
echo Building examples...
mkdir -p $(BUILD)/examples/ping $(BUILD)/examples/bench
go build -o $(BUILD)/examples/ping/pong ./examples/ping/main.go
go build -o $(BUILD)/examples/hyperbahn/echo-server ./examples/hyperbahn/echo-server/main.go
go build -o $(BUILD)/examples/bench/server ./examples/bench/server
go build -o $(BUILD)/examples/bench/client ./examples/bench/client
go build -o $(BUILD)/examples/bench/runner ./examples/bench/runner.go
go build -o $(BUILD)/examples/test_server ./examples/test_server
thrift_gen: $(BIN)/thrift
go build -o $(BUILD)/thrift-gen ./thrift/thrift-gen
PATH=$(BIN):$$PATH $(BUILD)/thrift-gen --generateThrift --inputFile thrift/test.thrift --outputDir thrift/gen-go/
PATH=$(BIN):$$PATH $(BUILD)/thrift-gen --generateThrift --inputFile examples/keyvalue/keyvalue.thrift --outputDir examples/keyvalue/gen-go
PATH=$(BIN):$$PATH $(BUILD)/thrift-gen --generateThrift --inputFile examples/thrift/example.thrift --outputDir examples/thrift/gen-go
PATH=$(BIN):$$PATH $(BUILD)/thrift-gen --generateThrift --inputFile hyperbahn/hyperbahn.thrift --outputDir hyperbahn/gen-go
PATH=$(BIN):$$PATH $(BUILD)/thrift-gen --generateThrift --inputFile thrift/meta.thrift --outputDir thrift/gen-go
rm thrift/gen-go/meta/tchan-meta.go # circular dependency, as we just want to generate thrift files here
PATH=$(BIN):$$PATH $(BUILD)/thrift-gen --generateThrift --inputFile thrift/test.thrift --outputDir thrift/gen-go
git ls-files | grep ".go$$" | xargs gofmt -l -s -w
release_thrift_gen: clean setup
GOOS=linux GOARCH=amd64 go build -o $(THRIFT_GEN_RELEASE_LINUX)/thrift-gen ./thrift/thrift-gen
GOOS=darwin GOARCH=amd64 go build -o $(THRIFT_GEN_RELEASE_DARWIN)/thrift-gen ./thrift/thrift-gen
tar -czf thrift-gen-release.tar.gz $(THRIFT_GEN_RELEASE)
mv thrift-gen-release.tar.gz $(THRIFT_GEN_RELEASE)/
.PHONY: all help clean fmt format install install_ci release_thrift_gen packages_test test test_ci lint
.SILENT: all help clean fmt format test lint