This repository was archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathMakefile
More file actions
261 lines (201 loc) · 6.64 KB
/
Makefile
File metadata and controls
261 lines (201 loc) · 6.64 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GO=GO15VENDOREXPERIMENT="1" CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) GO111MODULE=on go
GOTEST=GO15VENDOREXPERIMENT="1" CGO_ENABLED=1 GO111MODULE=on go test # go race detector requires cgo
VERSION := $(if $(VERSION),$(VERSION),latest)
PACKAGES := go list ./...| grep -vE 'vendor'
PACKAGE_DIRECTORIES := $(PACKAGES) | sed 's|github.com/pingcap/tipocket/||'
LDFLAGS += -s -w
LDFLAGS += -X "github.com/pingcap/tipocket/pkg/test-infra/fixture.BuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tipocket/pkg/test-infra/fixture.BuildHash=$(shell git rev-parse HEAD)"
GOBUILD=$(GO) build -ldflags '$(LDFLAGS)'
DOCKER_REGISTRY_TIPOCKET := $(if $(DOCKER_REGISTRY),$(DOCKER_REGISTRY)/,)tipocket
default: tidy fmt lint build
build: bindir consistency isolation pocket on-dup sqllogic block-writer \
region-available crud \
read-stress follower-read pessimistic resolve-lock cdc-bank \
example ttl \
# +tipocket:scaffold:makefile_build
bindir:
mkdir -p bin
consistency: bank bank2 pbank vbank ledger rawkv-linearizability tpcc pessimistic cdc-bank cross-region
isolation: list-append rw-register
backup:
$(GOBUILD) $(GOMOD) -o bin/backup cmd/backup/*.go
pbank:
$(GOBUILD) $(GOMOD) -o bin/pbank cmd/pbank/main.go
rawkv-linearizability:
cd testcase/rawkv-linearizability; make build; \
cp bin/* ../../bin/
tpcc:
$(GOBUILD) $(GOMOD) -o bin/tpcc cmd/tpcc/main.go
rawkv:
$(GOBUILD) $(GOMOD) -o bin/chaos-rawkv cmd/rawkv/main.go
txnkv:
$(GOBUILD) $(GOMOD) -o bin/chaos-txnkv cmd/txnkv/main.go
pocket:
cd testcase/pocket; make build; \
cp bin/* ../../bin/
compare:
$(GOBUILD) $(GOMOD) -o bin/compare cmd/compare/*.go
on-dup:
cd testcase/ondup; make build; \
cp bin/* ../../bin/
sqllogic:
cd testcase/sqllogictest; make build; \
cp bin/* ../../bin/
region-available:
$(GOBUILD) $(GOMOD) -o bin/region-available cmd/region-available/*.go
pessimistic:
cd testcase/pessimistic; make build; \
cp bin/* ../../bin/
crud:
$(GOBUILD) $(GOMOD) -o bin/crud cmd/crud/*.go
cdc-bank:
$(GOBUILD) $(GOMOD) -o bin/cdc-bank cmd/cdc-bank/*.go
read-stress:
$(GOBUILD) $(GOMOD) -o bin/read-stress cmd/read-stress/*.go
follower-read:
$(GOBUILD) $(GOMOD) -o bin/follower-read cmd/follower-read/*.go
titan:
cd testcase/titan; make build; \
cp bin/* ../../bin/
resolve-lock:
cd testcase/resolve-lock ; make build; \
cp bin/* ../../bin/
example:
cd testcase/example; make build; \
cp bin/* ../../bin/
list-append:
cd testcase/list-append; make build; \
cp bin/* ../../bin/
rw-register:
cd testcase/rw-register; make build; \
cp bin/* ../../bin/
ledger:
cd testcase/ledger; make build; \
cp bin/* ../../bin/
bank:
cd testcase/bank; make build; \
cp bin/* ../../bin/
block-writer:
cd testcase/block-writer; make build; \
cp bin/* ../../bin/
vbank:
cd testcase/vbank; make build; \
cp bin/* ../../bin/
bank2:
cd testcase/bank2; make build; \
cp bin/* ../../bin/
verifier:
cd testcase/verifier; make build; \
cp bin/* ../../bin/
cross-region:
cd testcase/cross-region; make build; \
cp bin/* ../../bin/
ttl:
cd testcase/ttl ; make build; \
cp bin/* ../../bin/
# +tipocket:scaffold:makefile_build_cmd
tipocket:
$(GOBUILD) $(GOMOD) -o bin/tipocket cmd/tipocket/*.go
fmt: groupimports
go fmt ./...
find testcase -mindepth 1 -maxdepth 1 -type d | xargs -I% sh -c 'cd %; make fmt';
tidy:
@echo "go mod tidy"
GO111MODULE=on go mod tidy
@git diff --exit-code -- go.mod
find testcase -mindepth 1 -maxdepth 1 -type d | xargs -I% sh -c 'cd %; make tidy';
lint: install-revive
@echo "linting"
revive -formatter friendly -config revive.toml $$($(PACKAGES) | grep -v "pkg/tidb-operator")
find testcase -mindepth 1 -maxdepth 1 -type d | xargs -I% sh -c 'cd %; make lint';
install-revive:
ifeq (, $(shell which revive))
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
GO111MODULE=on go get github.com/mgechev/revive@v1.0.2 ;\
rm -rf $$TMP_DIR ;\
}
endif
groupimports: install-goimports
goimports -w -l -local github.com/pingcap/tipocket $$($(PACKAGE_DIRECTORIES))
i ?= true
init: tipocket
bin/tipocket init -c=$(c) -i=$i
install-goimports:
ifeq (, $(shell which goimports))
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
GO111MODULE=on go get golang.org/x/tools/cmd/goimports ;\
rm -rf $$TMP_DIR ;\
}
endif
install-jsonnet:
ifeq (, $(shell which jsonnet))
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
GO111MODULE=on go get github.com/google/go-jsonnet/cmd/jsonnet ;\
rm -rf $$TMP_DIR ;\
}
endif
install-jsonnetfmt:
ifeq (, $(shell which jsonnetfmt))
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
GO111MODULE=on go get github.com/google/go-jsonnet/cmd/jsonnetfmt ;\
rm -rf $$TMP_DIR ;\
}
endif
install-yq:
ifeq (, $(shell which yq))
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
GO111MODULE=on go get github.com/mikefarah/yq/v4@v4.4.1 ;\
rm -rf $$TMP_DIR ;\
}
endif
install-jb:
ifeq (, $(shell which jb))
@{ \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
GO111MODULE=on go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb ;\
rm -rf $$TMP_DIR ;\
}
endif
clean_workflow:
rm -rf run/manifest
mkdir -p run/manifest/workflow
mkdir -p run/manifest/cron_workflow
fmt_workflow: install-jsonnetfmt
find run -name "*.jsonnet" | xargs -I{} jsonnetfmt -i {}
build_workflow: fmt_workflow install-jsonnet install-yq
mkdir -p run/manifest/workflow
find run/workflow -name "*.jsonnet" -type f -exec basename {} \; | xargs -I% sh -c 'jsonnet run/build.jsonnet -J run/lib -J run/workflow --ext-str build_mode="workflow" --ext-code-file file=run/workflow/% | yq eval -P - > run/manifest/workflow/%.yaml'
build_cron_workflow: fmt_workflow install-jsonnet install-yq
mkdir -p run/manifest/cron_workflow
find run/workflow -name "*.jsonnet" -type f -exec basename {} \; | xargs -I% sh -c 'jsonnet run/build.jsonnet -J run/lib -J run/workflow --ext-str build_mode="cron_workflow" --ext-code-file file=run/workflow/% | yq eval -P - > run/manifest/cron_workflow/%.yaml'
clean:
@rm -rf bin/*
test:
$(GOTEST) ./...
find testcase -mindepth 1 -maxdepth 1 -type d | xargs -I% sh -c 'cd %; make test';
image:
DOCKER_BUILDKIT=1 docker build -t ${DOCKER_REGISTRY_TIPOCKET}/tipocket:latest .
find testcase -mindepth 1 -maxdepth 1 -type d | xargs -I% sh -c 'if [ -f %/Dockerfile ]; then DOCKER_BUILDKIT=1 docker build -t ${DOCKER_REGISTRY_TIPOCKET}/`basename %`:latest -f %/Dockerfile .; fi';
docker-push:
docker push ${DOCKER_REGISTRY_TIPOCKET}/tipocket:latest
find testcase -mindepth 1 -maxdepth 1 -type d | xargs -I% sh -c 'if [ -f %/Dockerfile ]; then DOCKER_BUILDKIT=1 docker push ${DOCKER_REGISTRY_TIPOCKET}/`basename %`:latest; fi';
.PHONY: all clean pocket compare test fmt