-
Notifications
You must be signed in to change notification settings - Fork 87
/
Makefile
209 lines (160 loc) · 5.57 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
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
# 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
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
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
$(GINKGO) --race \
-ldflags \
"-X github.com/apache/skywalking-banyandb/pkg/test/flags.eventuallyTimeout=30s -X github.com/apache/skywalking-banyandb/pkg/test/flags.LogLevel=error" \
$(TEST_CI_OPTS) \
./...
##@ Code quality targets
lint: TARGET=lint
lint: PROJECTS:=api $(PROJECTS) pkg scripts/ci/check test
lint: default ## Run the linters on all projects
##@ 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
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) lint
$(MAKE) license-dep
$(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
license-check: default ## Check license header
$(LICENSE_EYE) header check
license-fix: $(LICENSE_EYE)
license-fix: TARGET=license-fix
license-fix: PROJECTS:=ui
license-fix: default ## Fix license header issues
$(LICENSE_EYE) header fix
license-dep: $(LICENSE_EYE)
license-dep: TARGET=license-dep
license-dep: PROJECTS:=ui
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
##@ Docker targets
docker.build: TARGET=docker
docker.build: PROJECTS:= banyand bydbctl
docker.build: default ## Build docker images
docker.push: TARGET=docker.push
docker.push: PROJECTS:= banyand bydbctl
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 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
.PHONY: test test-race test-coverage test-ci
.PHONY: license-check license-fix license-dep
.PHONY: release release-binary release-source release-sign release-assembly
.PHONY: vendor-update