forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
160 lines (135 loc) · 4.29 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
SHELL := /bin/bash
COVERAGE_FILE := coverage.out
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
DURATION ?= 3s
COUNT ?= 5
BENCH_PATH ?= bench-dir
TEST_PATH ?= ${PROJECT_DIR}/...
BENCH_FILE := ${PROJECT_DIR}/${BENCH_PATH}/bench.txt
REFERENCE_FILE := ${PROJECT_DIR}/${BENCH_PATH}/reference.txt
BENCH_FILES := ${REFERENCE_FILE} ${BENCH_FILE}
BENCH_REFERENCE_REPO := ${BENCH_PATH}/go-tarantool
BENCH_OPTIONS := -bench=. -run=^Benchmark -benchmem -benchtime=${DURATION} -count=${COUNT}
GO_TARANTOOL_URL := https://github.com/tarantool/go-tarantool
GO_TARANTOOL_DIR := ${PROJECT_DIR}/${BENCH_PATH}/go-tarantool
TAGS :=
.PHONY: clean
clean:
( rm -rf queue/testdata/.rocks crud/testdata/.rocks )
rm -f $(COVERAGE_FILE)
.PHONY: deps
deps: clean
@(command -v tt > /dev/null || (echo "error: tt not found" && exit 1))
( cd ./queue/testdata; tt rocks install queue 1.3.0 )
( cd ./crud/testdata; tt rocks install crud )
.PHONY: datetime-timezones
datetime-timezones:
(cd ./datetime; ./gen-timezones.sh)
.PHONY: format
format:
goimports -l -w .
.PHONY: golangci-lint
golangci-lint:
golangci-lint run --config=.golangci.yaml
.PHONY: test
test:
@echo "Running all packages tests"
go clean -testcache
go test -tags "$(TAGS)" ./... -v -p 1
.PHONY: testdata
testdata:
(cd ./testdata; ./generate.sh)
.PHONY: testrace
testrace:
@echo "Running all packages tests with data race detector"
go clean -testcache
go test -race -tags "$(TAGS)" ./... -v -p 1
.PHONY: test-pool
test-pool:
@echo "Running tests in pool package"
go clean -testcache
go test -tags "$(TAGS)" ./pool/ -v -p 1
.PHONY: test-datetime
test-datetime:
@echo "Running tests in datetime package"
go clean -testcache
go test -tags "$(TAGS)" ./datetime/ -v -p 1
.PHONY: test-decimal
test-decimal:
@echo "Running tests in decimal package"
go clean -testcache
go test -tags "$(TAGS)" ./decimal/ -v -p 1
.PHONY: test-queue
test-queue:
@echo "Running tests in queue package"
cd ./queue/ && tarantool -e "require('queue')"
go clean -testcache
go test -tags "$(TAGS)" ./queue/ -v -p 1
.PHONY: test-uuid
test-uuid:
@echo "Running tests in UUID package"
go clean -testcache
go test -tags "$(TAGS)" ./uuid/ -v -p 1
.PHONY: test-settings
test-settings:
@echo "Running tests in settings package"
go clean -testcache
go test -tags "$(TAGS)" ./settings/ -v -p 1
.PHONY: test-crud
test-crud:
@echo "Running tests in crud package"
cd ./crud/testdata && tarantool -e "require('crud')"
go clean -testcache
go test -tags "$(TAGS)" ./crud/ -v -p 1
.PHONY: test-main
test-main:
@echo "Running tests in main package"
go clean -testcache
go test -tags "$(TAGS)" . -v -p 1
.PHONY: coverage
coverage:
go clean -testcache
go get golang.org/x/tools/cmd/cover
go test -tags "$(TAGS)" ./... -v -p 1 -covermode=atomic -coverprofile=$(COVERAGE_FILE)
go tool cover -func=$(COVERAGE_FILE)
.PHONY: coveralls
coveralls: coverage
go get github.com/mattn/goveralls
go install github.com/mattn/goveralls
goveralls -coverprofile=$(COVERAGE_FILE) -service=github
.PHONY: bench-deps
${BENCH_PATH} bench-deps:
@echo "Installing benchstat tool"
rm -rf ${BENCH_PATH}
mkdir ${BENCH_PATH}
go clean -testcache
cd ${BENCH_PATH} && \
go get golang.org/x/perf/cmd/benchstat
go install golang.org/x/perf/cmd/benchstat
.PHONY: bench
${BENCH_FILE} bench: ${BENCH_PATH}
@echo "Running benchmark tests from the current branch"
go test -tags "$(TAGS)" ${TEST_PATH} ${BENCH_OPTIONS} 2>&1 \
| tee ${BENCH_FILE}
benchstat ${BENCH_FILE}
${GO_TARANTOOL_DIR}:
@echo "Cloning the repository into ${GO_TARANTOOL_DIR}"
[ ! -e ${GO_TARANTOOL_DIR} ] && git clone --depth=1 ${GO_TARANTOOL_URL} ${GO_TARANTOOL_DIR}
${REFERENCE_FILE}: ${GO_TARANTOOL_DIR}
@echo "Running benchmark tests from master for using results in bench-diff target"
cd ${GO_TARANTOOL_DIR} && git pull && go test ./... -tags "$(TAGS)" ${BENCH_OPTIONS} 2>&1 \
| tee ${REFERENCE_FILE}
bench-diff: ${BENCH_FILES}
@echo "Comparing performance between master and the current branch"
@echo "'old' is a version in master branch, 'new' is a version in a current branch"
benchstat ${BENCH_FILES} | grep -v pkg:
.PHONY: fuzzing
fuzzing:
@echo "Running fuzzing tests"
go clean -testcache
go test -tags "$(TAGS)" ./... -run=^Fuzz -v -p 1
.PHONY: codespell
codespell:
@echo "Running codespell"
codespell