forked from apache/skywalking-banyandb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
341 lines (278 loc) · 13.2 KB
/
Copy pathMakefile
File metadata and controls
341 lines (278 loc) · 13.2 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
mk_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mk_dir := $(dir $(mk_path))
tool_bin := $(mk_dir)bin
ifneq (,$(wildcard $(mk_dir).env))
include $(mk_dir).env
export
endif
include scripts/build/version.mk
PROJECTS := ui banyand bydbctl mcp fodc/agent fodc/proxy
TEST_CI_OPTS ?=
##@ Build targets
clean: TARGET=clean
clean: PROJECTS:=api $(PROJECTS) pkg
clean: default ## Clean artifacts in all projects
rm -rf build
rm -f .env
rm -f *.out
clean-build: TARGET=clean-build
clean-build: default ## Clean build artifacts in all projects
generate: TARGET=generate
generate: PROJECTS:=api $(PROJECTS) pkg
generate: default ## Generate API codes
generate-test-cases: ## Regenerate measure query test cases (input/*.ql, input/*.yaml)
go run ./test/cases/measure/cmd/generate generate test/cases/measure/data
capture-test-cases: ## Capture measure query want fixtures (data/want/*.yaml) by running queries against a standalone server
CAPTURE_WANT_FIXTURES=1 go test -count=1 -timeout 5m -run TestCapture ./test/cases/measure/cmd/capture/
generate-trace-test-cases: ## Regenerate trace query test cases (input/*.ql, input/*.yml)
go run ./test/cases/trace/cmd/generate generate test/cases/trace/data
capture-trace-test-cases: ## Capture trace query want fixtures (data/want/*.yml) against a standalone server
CAPTURE_TRACE_WANT_FIXTURES=1 go test -count=1 -timeout 5m -run TestCaptureTrace ./test/cases/trace/cmd/capture/
build: TARGET=all
build: default ## Build all projects
##@ Release targets
release: TARGET=release
release: default ## Build the release artifacts for all projects, usually the statically linked binaries
##@ Test targets
test: TARGET=test
test: PROJECTS:=$(PROJECTS) pkg test
test: default ## Run the unit tests in all projects
test-race: TARGET=test-race
test-race: PROJECTS:=$(PROJECTS) pkg test
test-race: default ## Run the unit tests in all projects with race detector on
test-coverage: TARGET=test-coverage
test-coverage: PROJECTS:=$(PROJECTS) pkg test
test-coverage: default ## Run the unit tests in all projects with coverage analysis on
include scripts/build/ginkgo.mk
test-ci: $(GINKGO) ## Run the unit tests in CI. Usage: make test-ci PKG=./banyand/trace
$(GINKGO) --race \
-ldflags \
"-X github.com/apache/skywalking-banyandb/pkg/test/flags.eventuallyTimeout=30s -X github.com/apache/skywalking-banyandb/pkg/test/flags.consistentlyTimeout=10s -X github.com/apache/skywalking-banyandb/pkg/test/flags.LogLevel=error" \
$(TEST_CI_OPTS) \
$(PKG)
PKG ?= ./...
GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}')
test-docker: ## Run tests in Docker with constrained resources (2 CPU cores, 4GB RAM). Usage: make test-docker PKG=./banyand/trace
@echo "Running tests in Docker container (2 CPUs, 4GB RAM) for package: $(PKG)"
@echo "Using Go version: $(GO_VERSION) (from go.mod)"
docker run --rm \
--cpus=2 \
--memory=4g \
-v $(mk_dir):/workspace \
-w /workspace \
golang:$(GO_VERSION) \
go run github.com/onsi/ginkgo/v2/ginkgo --race \
-ldflags "-X github.com/apache/skywalking-banyandb/pkg/test/flags.eventuallyTimeout=30s -X github.com/apache/skywalking-banyandb/pkg/test/flags.consistentlyTimeout=10s -X github.com/apache/skywalking-banyandb/pkg/test/flags.LogLevel=error" \
$(PKG)
load-test-barrier: ## Run the schema-barrier CP-6 SLO load harness (3 data nodes + 1 liaison, 100 callers, 5m measurement). Override with LOAD_FLAGS="-loadtest.measure=30s ..." for smoke runs.
@echo "Running schema-barrier load harness (CP-6 SLO profile)"
@echo "Override profile via LOAD_FLAGS, e.g. LOAD_FLAGS='-loadtest.measure=30s -loadtest.callers=20'"
go test -tags=loadtest -timeout 30m -count=1 -v ./test/load/schema_barrier/... $(LOAD_FLAGS)
##@ Trace pipeline plugin targets
# Linux and macOS only — Go plugins require CGO and are not supported on Windows.
# These targets MUST NOT be included in test-race: a plugin built without -race
# cannot be loaded by a -race host (the Go runtime rejects the mismatch with a
# "plugin was built with a different version of package runtime" error at
# plugin.Open time). The in-package guards in banyand/trace (diskSurvivorSpans,
# TestInMergeFilter_DisabledFlag_LegacyIdentity, TestInMergeFilter_FailOpenNegativeControl)
# remain the sole race-checked coverage of the merge filter path.
PLUGIN_OUTPUT_DIR ?= build/bin/plugins
BANYAND_SERVER_CGO_BIN ?= banyand/build/bin/dev/banyand-server
.PHONY: build-trace-pipeline-plugin
build-trace-pipeline-plugin: ## Build the latencystatussampler.so plugin (Linux/macOS only; requires a C toolchain)
@if ! command -v gcc > /dev/null 2>&1 && ! command -v clang > /dev/null 2>&1; then \
echo "ERROR: build-trace-pipeline-plugin requires a C toolchain (gcc or clang) but neither was found in PATH."; \
exit 1; \
fi
@mkdir -p $(PLUGIN_OUTPUT_DIR)
CGO_ENABLED=1 go build -buildmode=plugin -trimpath \
-o $(PLUGIN_OUTPUT_DIR)/latencystatussampler.so \
./test/plugins/_latencystatussampler
@echo "Built $(PLUGIN_OUTPUT_DIR)/latencystatussampler.so"
.PHONY: build-trace-pipeline-server
build-trace-pipeline-server: ## Build banyand-server with explicit CGO_ENABLED=1 for plugin hosting (Linux/macOS only)
@if ! command -v gcc > /dev/null 2>&1 && ! command -v clang > /dev/null 2>&1; then \
echo "ERROR: build-trace-pipeline-server requires a C toolchain (gcc or clang) but neither was found in PATH."; \
exit 1; \
fi
@# ui/dist must contain at least one embeddable (non-hidden) file for
@# ui/embed.go's //go:embed dist to succeed. Create a placeholder when the
@# UI has not been built (dev / CI without the UI step).
@mkdir -p ui/dist
@if [ ! -f ui/dist/index.html ]; then touch ui/dist/index.html; fi
@mkdir -p $(dir $(BANYAND_SERVER_CGO_BIN))
CGO_ENABLED=1 go build -trimpath \
-o $(BANYAND_SERVER_CGO_BIN) \
github.com/apache/skywalking-banyandb/banyand/cmd/server
@echo "Built $(BANYAND_SERVER_CGO_BIN)"
.PHONY: test-trace-pipeline
# NOTE: no -race flag — see comment above. Plugins and -race require both the
# .so and the host to be race-built; the simple CGO_ENABLED=1 targets here do
# not pass -race, so the suite is intentionally excluded from the race lane.
test-trace-pipeline: build-trace-pipeline-plugin build-trace-pipeline-server $(GINKGO) ## Build the .so + CGO server, then run the pipeline integration suites (Linux/macOS only; excluded from test-race)
BANYAND_BIN=$(mk_dir)$(BANYAND_SERVER_CGO_BIN) \
BANYAND_TRACE_PLUGIN=$(mk_dir)$(PLUGIN_OUTPUT_DIR)/latencystatussampler.so \
$(GINKGO) \
--tags trace_pipeline \
-ldflags "-X github.com/apache/skywalking-banyandb/pkg/test/flags.eventuallyTimeout=30s -X github.com/apache/skywalking-banyandb/pkg/test/flags.consistentlyTimeout=10s -X github.com/apache/skywalking-banyandb/pkg/test/flags.LogLevel=error" \
-timeout 10m \
./test/integration/standalone/pipeline/... \
./test/integration/distributed/pipeline/...
##@ Code quality targets
lint: TARGET=lint
lint: PROJECTS:=api $(PROJECTS) pkg scripts/ci/check test
lint: check-import-boundaries
lint: default ## Run the linters on all projects
# lint-rawgo enforces the project's "no raw goroutines" rule. New `go`
# statements in code outside the recovery wrappers must either go
# through run.Go / run.GoOrDie / run.GoWithSignal or carry an explicit
# `//panicdiag:allow-rawgo <reason>` directive. Pre-existing sites are
# tracked in pkg/panicdiag/lintrawgo/baseline.txt; that list only ever
# shrinks. Runs once at the module root rather than per-subproject.
.PHONY: lint-rawgo
lint-rawgo: ## Enforce panic-recovery wrappers for goroutine launches
go run ./scripts/lint/rawgo \
-baseline=pkg/panicdiag/lintrawgo/baseline.txt ./...
.PHONY: update-rawgo-baseline
update-rawgo-baseline: ## Regenerate the raw-go baseline from the current tree
go run ./scripts/lint/rawgo-baseline \
-baseline=pkg/panicdiag/lintrawgo/baseline.txt ./...
# check-import-boundaries enforces the layering invariants documented in
# pkg/initerror/initerror.go: the leaf permanent-error contract must not gain
# project-internal dependencies, and the property schema-registry classifier
# must not import the storage internals it classifies via the leaf interface.
.PHONY: check-import-boundaries
check-import-boundaries: ## Enforce import-boundary invariants for the version-incompat fix
@bad=0; \
if grep -rln 'banyand/internal/storage' banyand/metadata/schema/property/ 2>/dev/null; then \
echo "FAIL: banyand/metadata/schema/property/ must not import banyand/internal/storage"; \
bad=1; \
fi; \
if grep -rln 'banyand/internal/storage' pkg/schema/ 2>/dev/null; then \
echo "FAIL: pkg/schema/ must not import banyand/internal/storage"; \
bad=1; \
fi; \
if grep -rln 'github.com/apache/skywalking-banyandb/' pkg/initerror/*.go 2>/dev/null | grep -v _test.go; then \
echo "FAIL: pkg/initerror/ must remain a leaf with zero project-internal imports (test files excepted)"; \
bad=1; \
fi; \
if [ $$bad -ne 0 ]; then exit 1; fi; \
echo "import boundaries OK"
##@ Vendor update
vendor-update: TARGET=vendor-update
vendor-update: PROJECTS:=$(PROJECTS) pkg test
vendor-update: default ## Run the linters on all projects
##@ Code style targets
tidy:
go mod tidy
format: TARGET=format
format: PROJECTS:=api $(PROJECTS) pkg scripts/ci/check test
format: tidy
format: default ## Run the linters on all projects
check-req: ## Check the requirements
@$(MAKE) -C scripts/ci/check test
@$(MAKE) -C ui check-version
@$(MAKE) -C mcp check-version
include scripts/build/vuln.mk
vuln-check: $(GOVULNCHECK)
$(GOVULNCHECK) -show color,verbose ./...
check: ## Check that the status is consistent with CI
$(MAKE) license-check
$(MAKE) format
$(MAKE) tidy
git add --renormalize .
mkdir -p /tmp/artifacts
git diff >/tmp/artifacts/check.diff 2>&1
@if [ ! -z "`git status -s`" ]; then \
echo "Following files are not consistent with CI:"; \
git status -s; \
cat /tmp/artifacts/check.diff; \
exit 1; \
fi
pre-push: ## Check source files before pushing to the remote repo
$(MAKE) check-req
$(MAKE) generate
$(MAKE) generate-test-cases
$(MAKE) lint
$(MAKE) check
$(MAKE) vuln-check
##@ License targets
include scripts/build/license.mk
license-check: $(LICENSE_EYE)
license-check: TARGET=license-check
license-check: PROJECTS:=ui mcp canopy
license-check: default ## Check license header
$(LICENSE_EYE) header check
license-fix: $(LICENSE_EYE)
license-fix: TARGET=license-fix
license-fix: PROJECTS:=ui mcp canopy
license-fix: default ## Fix license header issues
$(LICENSE_EYE) header fix
license-dep: $(LICENSE_EYE)
license-dep: TARGET=license-dep
license-dep: PROJECTS:=ui mcp
license-dep: default ## Fix license header issues
@rm -rf $(mk_dir)/dist/licenses
$(LICENSE_EYE) dep resolve -o $(mk_dir)/dist/licenses -s $(mk_dir)/dist/LICENSE.tpl
mv $(mk_dir)/ui/ui-licenses $(mk_dir)/dist/licenses
cat $(mk_dir)/ui/LICENSE >> $(mk_dir)/dist/LICENSE
mv $(mk_dir)/mcp/mcp-licenses $(mk_dir)/dist/licenses
cat $(mk_dir)/mcp/LICENSE >> $(mk_dir)/dist/LICENSE
##@ Docker targets
docker.build: TARGET=docker
docker.build: PROJECTS:= banyand bydbctl mcp fodc/agent fodc/proxy
docker.build: default ## Build docker images
docker.push: TARGET=docker.push
docker.push: PROJECTS:= banyand bydbctl mcp fodc/agent fodc/proxy
docker.push: default ## Push docker images
default:
@for PRJ in $(PROJECTS); do \
echo "--- $$PRJ: $(TARGET) ---"; \
$(MAKE) $(TARGET) -C $$PRJ; \
if [ $$? -ne 0 ]; then \
exit 1; \
fi; \
done
nuke:
git clean -Xdf
include scripts/build/help.mk
##@ release
RELEASE_SCRIPTS := $(mk_dir)/scripts/release.sh
release-binary: release-source ## Package binary archive
${RELEASE_SCRIPTS} -b
release-source: ## Package source archive
${RELEASE_SCRIPTS} -s
release-sign: ## Sign artifacts
${RELEASE_SCRIPTS} -k banyand
${RELEASE_SCRIPTS} -k bydbctl
${RELEASE_SCRIPTS} -k fodc-agent
${RELEASE_SCRIPTS} -k fodc-proxy
${RELEASE_SCRIPTS} -k src
release-assembly: release-binary release-sign ## Generate release package
PUSH_RELEASE_SCRIPTS := $(mk_dir)/scripts/push-release.sh
release-push-candidate: ## Push release candidate
${PUSH_RELEASE_SCRIPTS}
.PHONY: all $(PROJECTS) clean build default nuke
.PHONY: lint check tidy format pre-push generate-test-cases capture-test-cases generate-trace-test-cases capture-trace-test-cases check-import-boundaries
.PHONY: test test-race test-coverage test-ci test-docker
.PHONY: build-trace-pipeline-plugin build-trace-pipeline-server test-trace-pipeline
.PHONY: license-check license-fix license-dep
.PHONY: release release-binary release-source release-sign release-assembly
.PHONY: vendor-update