-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
277 lines (219 loc) · 8.26 KB
/
Makefile
File metadata and controls
277 lines (219 loc) · 8.26 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
env ?= localnet
# -----------------------------------------------------------------------------
# Combined targets
# -----------------------------------------------------------------------------
.PHONY: build
build: go-build rust-build
.PHONY: lint
lint: go-lint rust-lint
.PHONY: fmt
fmt: rust-fmt go-fmt
.PHONY: test
test: go-test rust-test
.PHONY: ci
ci: build lint test
.PHONY: clean
clean:
cargo clean
# -----------------------------------------------------------------------------
# Go targets
# -----------------------------------------------------------------------------
.PHONY: go-build
go-build:
CGO_ENABLED=0 go build -v -tags "qa e2e" ./...
cd controlplane/s3-uploader && go build -v ./...
.PHONY: go-lint
go-lint:
dev/go-lint.sh
.PHONY: go-lint-native
go-lint-native:
golangci-lint run -c ./.golangci.yaml
cd controlplane/s3-uploader && golangci-lint run
.PHONY: go-fmt
go-fmt:
go fmt ./...
cd controlplane/s3-uploader && go fmt ./...
.PHONY: go-test
go-test:
dev/go-test.sh
.PHONY: go-test-native
go-test-native:
go test -exec "sudo -E" -race -v ./...
cd controlplane/s3-uploader && go test -race -v ./...
$(if $(findstring nocontainertest,$(MAKECMDGOALS)),,$(MAKE) go-container-test)
$(MAKE) -C client/doublezerod test-faults
.PHONY: go-test-docker
go-test-docker:
go test -race -v ./...
cd controlplane/s3-uploader && go test -race -v ./...
$(if $(findstring nocontainertest,$(MAKECMDGOALS)),,$(MAKE) go-container-test)
$(MAKE) -C client/doublezerod test-faults
.PHONY: nocontainertest
nocontainertest:
@:
.PHONY: go-fuzz
go-fuzz:
cd tools/twamp && $(MAKE) fuzz
cd client/doublezerod && $(MAKE) fuzz
.PHONY: go-container-test
go-container-test:
go run tools/container-test/main.go -v
.PHONY: go-ci
go-ci: go-build go-lint go-test go-fuzz
# -----------------------------------------------------------------------------
# Rust targets
# -----------------------------------------------------------------------------
.PHONY: rust-build
rust-build: rust-build-programs
cargo build -v --workspace
.PHONY: rust-build-programs
rust-build-programs:
cd smartcontract && $(MAKE) build-programs env=$(env)
.PHONY: rust-lint
rust-lint: rust-fmt-check
@cargo install cargo-hack
cargo hack clippy --workspace --all-targets --exclude doublezero-telemetry --exclude doublezero-serviceability --exclude doublezero-program-common --exclude doublezero-record --exclude doublezero-geolocation -- -Dclippy::all -Dwarnings
cd smartcontract && $(MAKE) lint-programs
.PHONY: rust-fmt
rust-fmt:
rustup component add rustfmt --toolchain nightly
cargo +nightly fmt --all -- --config imports_granularity=Crate
.PHONY: rust-fmt-check
rust-fmt-check:
@rustup component add rustfmt --toolchain nightly
@cargo +nightly fmt --all -- --check --config imports_granularity=Crate || (echo "Formatting check failed. Please run 'make fmt' to fix formatting issues." && exit 1)
.PHONY: rust-test
rust-test:
cargo test --workspace --exclude doublezero-telemetry --exclude doublezero-serviceability --exclude doublezero-program-common --exclude doublezero-record --exclude doublezero-geolocation --all-features
cd smartcontract && $(MAKE) test-programs
$(MAKE) rust-program-accounts-compat
.PHONY: rust-test-programs
rust-test-programs:
cd smartcontract && $(MAKE) test-programs
.PHONY: rust-validator-test
rust-validator-test:
bash smartcontract/test/run_record_test.sh
.PHONY: rust-ci
rust-ci: rust-build rust-lint rust-test rust-validator-test
.PHONY: rust-program-accounts-compat
rust-program-accounts-compat:
cargo run -p doublezero -- accounts -ed --no-output
cargo run -p doublezero -- accounts -et --no-output
cargo run -p doublezero -- accounts -em --no-output
# -----------------------------------------------------------------------------
# SDK targets
# -----------------------------------------------------------------------------
.PHONY: sdk-test
sdk-test:
go test ./sdk/borsh-incremental/go/...
go test ./sdk/revdist/go/...
$(MAKE) python-test-borsh-incremental
$(MAKE) python-test-revdist
$(MAKE) python-test-serviceability
$(MAKE) python-test-telemetry
$(MAKE) typescript-test-borsh-incremental
$(MAKE) typescript-test-revdist
$(MAKE) typescript-test-serviceability
$(MAKE) typescript-test-telemetry
.PHONY: python-test-borsh-incremental
python-test-borsh-incremental:
cd sdk/borsh-incremental/python && uv run pytest
.PHONY: python-test-revdist
python-test-revdist:
cd sdk/revdist/python && uv run pytest
.PHONY: python-test-serviceability
python-test-serviceability:
cd sdk/serviceability/python && uv run pytest
.PHONY: python-test-telemetry
python-test-telemetry:
cd sdk/telemetry/python && uv run pytest
.PHONY: typescript-test-borsh-incremental
typescript-test-borsh-incremental:
cd sdk/borsh-incremental/typescript && bun install && bun tsc --noEmit && bun test
.PHONY: typescript-test-revdist
typescript-test-revdist:
cd sdk/revdist/typescript && bun install && bun tsc --noEmit && bun test
.PHONY: typescript-test-serviceability
typescript-test-serviceability:
cd sdk/serviceability/typescript && bun install && bun tsc --noEmit && bun test
.PHONY: typescript-test-telemetry
typescript-test-telemetry:
cd sdk/telemetry/typescript && bun install && bun tsc --noEmit && bun test
.PHONY: sdk-compat-test
sdk-compat-test:
REVDIST_COMPAT_TEST=1 go test -run TestCompat -v ./sdk/revdist/go/...
$(MAKE) python-compat-test-revdist
$(MAKE) typescript-compat-test-revdist
$(MAKE) python-compat-test-serviceability
$(MAKE) typescript-compat-test-serviceability
.PHONY: python-compat-test-revdist
python-compat-test-revdist:
cd sdk/revdist/python && REVDIST_COMPAT_TEST=1 uv run pytest -k compat -v
.PHONY: typescript-compat-test-revdist
typescript-compat-test-revdist:
cd sdk/revdist/typescript && bun install && REVDIST_COMPAT_TEST=1 bun test --grep compat
.PHONY: python-compat-test-serviceability
python-compat-test-serviceability:
cd sdk/serviceability/python && SERVICEABILITY_COMPAT_TEST=1 uv run pytest -k compat -v
.PHONY: typescript-compat-test-serviceability
typescript-compat-test-serviceability:
cd sdk/serviceability/typescript && bun install && SERVICEABILITY_COMPAT_TEST=1 bun test --grep compat
.PHONY: generate-fixtures
generate-fixtures:
cd sdk/revdist/testdata/fixtures/generate-fixtures && cargo run
cd sdk/serviceability/testdata/fixtures/generate-fixtures && cargo run
cd sdk/telemetry/testdata/fixtures/generate-fixtures && cargo run
# -----------------------------------------------------------------------------
# E2E targets
#
# Usage:
# make e2e-test # run all tests
# make e2e-test RUN=TestE2E_Multicast # run a specific test
# make e2e-test-debug RUN=TestE2E_Multicast # with debug logging
# make e2e-test-nobuild # skip docker image build
# make e2e-test-keep # keep containers after test
# make e2e-test-keep-nobuild # both
# make e2e-test-cleanup # remove leftover containers
# -----------------------------------------------------------------------------
.PHONY: e2e-build
e2e-build:
cd e2e && $(MAKE) build
.PHONY: e2e-build-debug
e2e-build-debug:
cd e2e && $(MAKE) build-debug
.PHONY: e2e-test
e2e-test:
cd e2e && $(MAKE) test $(if $(RUN),RUN=$(RUN))
.PHONY: e2e-test-debug
e2e-test-debug:
cd e2e && $(MAKE) test-debug $(if $(RUN),RUN=$(RUN))
.PHONY: e2e-test-nobuild
e2e-test-nobuild:
cd e2e && $(MAKE) test-nobuild $(if $(RUN),RUN=$(RUN))
.PHONY: e2e-test-keep
e2e-test-keep:
cd e2e && $(MAKE) test-keep $(if $(RUN),RUN=$(RUN))
.PHONY: e2e-test-keep-nobuild
e2e-test-keep-nobuild:
cd e2e && $(MAKE) test-keep-nobuild $(if $(RUN),RUN=$(RUN))
.PHONY: e2e-test-cleanup
e2e-test-cleanup:
cd e2e && $(MAKE) test-cleanup
# -----------------------------------------------------------------------------
# Build programs for specific environments
# -----------------------------------------------------------------------------
.PHONY: build-programs
build-programs:
$(MAKE) -C smartcontract build-programs env=$(env)
.PHONY: build-programs-localnet
build-programs-localnet:
$(MAKE) build-programs env=localnet
.PHONY: build-programs-devnet
build-programs-devnet:
$(MAKE) build-programs env=devnet
.PHONY: build-programs-testnet
build-programs-testnet:
$(MAKE) build-programs env=testnet
.PHONY: build-programs-mainnet-beta
build-programs-mainnet-beta:
$(MAKE) build-programs env=mainnet-beta