forked from apache/skywalking-banyandb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
203 lines (158 loc) · 5.25 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
# 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
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
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
##@ 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: DIR=docker
docker.build:
$(MAKE) $(TARGET) -C $(DIR); \
if [ $$? -ne 0 ]; then \
exit 1; \
fi; \
docker.push: TARGET=docker.push
docker.push: DIR=docker
docker.push:
$(MAKE) $(TARGET) -C $(DIR); \
if [ $$? -ne 0 ]; then \
exit 1; \
fi; \
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: clean ## Package source archive
${RELEASE_SCRIPTS} -s
release-sign: ## Sign artifacts
${RELEASE_SCRIPTS} -k bin
${RELEASE_SCRIPTS} -k src
release-assembly: release-binary release-sign ## Generate release package
.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