forked from dragonflyoss/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
349 lines (300 loc) · 10.8 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
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
342
343
344
345
346
347
348
349
# Copyright The Dragonfly Authors.
#
# Licensed 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.
PROJECT_NAME := "d7y.io/dragonfly/v2"
DFGET_NAME := "dfget"
SEMVER := "2.0.1"
VERSION_RELEASE := "1"
PKG := "$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/ | grep -v '\(/test/\)')
GIT_COMMIT := $(shell git rev-parse --verify HEAD --short=7)
GIT_COMMIT_LONG := $(shell git rev-parse --verify HEAD)
DFGET_ARCHIVE_PREFIX := "$(DFGET_NAME)_$(SEMVER)-$(VERSION_RELEASE)_$(GIT_COMMIT)"
all: help
# Prepare required folders for build
build-dirs:
@mkdir -p ./bin
.PHONY: build-dirs
# Build dragonlfy
docker-build: docker-build-cdn docker-build-dfdaemon docker-build-scheduler docker-build-manager
@echo "Build image done."
.PHONY: docker-build
# Push dragonfly images
docker-push: docker-push-cdn docker-push-dfdaemon docker-push-scheduler docker-push-manager
@echo "Push image done."
.PHONY: docker-push
# Build cdn image
docker-build-cdn:
@echo "Begin to use docker build cdn image."
./hack/docker-build.sh cdn
.PHONY: docker-build-cdn
# Build dfdaemon image
docker-build-dfdaemon:
@echo "Begin to use docker build dfdaemon image."
./hack/docker-build.sh dfdaemon
.PHONY: docker-build-dfdaemon
# Build scheduler image
docker-build-scheduler:
@echo "Begin to use docker build scheduler image."
./hack/docker-build.sh scheduler
.PHONY: docker-build-scheduler
# Build manager image
docker-build-manager:
@echo "Begin to use docker build manager image."
./hack/docker-build.sh manager
.PHONY: docker-build-manager
# Build testing tools image
docker-build-testing-tools: build-dirs
@echo "Begin to testing tools image."
./test/tools/no-content-length/build.sh
.PHONY: docker-build-testing-tools
# Push cdn image
docker-push-cdn: docker-build-cdn
@echo "Begin to push cdn docker image."
./hack/docker-push.sh cdn
.PHONY: docker-push-cdn
# Push dfdaemon image
docker-push-dfdaemon: docker-build-dfdaemon
@echo "Begin to push dfdaemon docker image."
./hack/docker-push.sh dfdaemon
.PHONY: docker-push-dfdaemon
# Push scheduler image
docker-push-scheduler: docker-build-scheduler
@echo "Begin to push scheduler docker image."
./hack/docker-push.sh scheduler
.PHONY: docker-push-scheduler
# Push manager image
docker-push-manager: docker-build-manager
@echo "Begin to push manager docker image."
./hack/docker-push.sh manager
.PHONY: docker-push-manager
# Build dragonfly
build: build-cdn build-scheduler build-dfget build-manager
.PHONY: build
# Build cdn
build-cdn: build-dirs
@echo "Begin to build cdn."
./hack/build.sh cdn
.PHONY: build-cdn
# Build dfget
build-dfget: build-dirs
@echo "Begin to build dfget."
./hack/build.sh dfget
.PHONY: build-dfget
# Build linux dfget
build-linux-dfget: build-dirs
@echo "Begin to build linux dfget."
GOOS=linux GOARCH=amd64 ./hack/build.sh dfget
.PHONY: build-linux-dfget
# Build scheduler
build-scheduler: build-dirs
@echo "Begin to build scheduler."
./hack/build.sh scheduler
.PHONY: build-scheduler
# Build manager
build-manager: build-dirs
@echo "Begin to build manager."
./hack/build.sh manager
.PHONY: build-manager
# Build manager console
build-manager-console: build-dirs
@echo "Begin to build manager."
./hack/build.sh manager-console
.PHONY: build-manager-console
# Install cdn
install-cdn:
@echo "Begin to install cdn."
./hack/install.sh install cdn
.PHONY: install-cdn
# Install dfget
install-dfget:
@echo "Begin to install dfget."
./hack/install.sh install dfget
.PHONY: install-dfget
# Install scheduler
install-scheduler:
@echo "Begin to install scheduler."
./hack/install.sh install scheduler
.PHONY: install-scheduler
# Install manager
install-manager:
@echo "Begin to install manager."
./hack/install.sh install manager
.PHONY: install-manager
# Build rpm dfget
build-rpm-dfget: build-linux-dfget
@echo "Begin to build rpm dfget"
@docker run --rm \
-v "$(PWD)/build:/root/build" \
-v "$(PWD)/docs:/root/docs" \
-v "$(PWD)/LICENSE:/root/License" \
-v "$(PWD)/CHANGELOG.md:/root/CHANGELOG.md" \
-v "$(PWD)/bin:/root/bin" \
-e "SEMVER=$(SEMVER)" \
-e "VERSION_RELEASE=$(VERSION_RELEASE)" \
goreleaser/nfpm pkg \
--config /root/build/package/nfpm/dfget.yaml \
--target /root/bin/$(DFGET_ARCHIVE_PREFIX)_linux_amd64.rpm
@echo "Build package output: ./bin/$(DFGET_ARCHIVE_PREFIX)_linux_amd64.rpm"
.PHONY: build-rpm-dfget
# Build deb dfget
build-deb-dfget: build-linux-dfget
@echo "Begin to build deb dfget"
@docker run --rm \
-v "$(PWD)/build:/root/build" \
-v "$(PWD)/docs:/root/docs" \
-v "$(PWD)/LICENSE:/root/License" \
-v "$(PWD)/CHANGELOG.md:/root/CHANGELOG.md" \
-v "$(PWD)/bin:/root/bin" \
-e "SEMVER=$(SEMVER)" \
-e "VERSION_RELEASE=$(VERSION_RELEASE)" \
goreleaser/nfpm pkg \
--config /root/build/package/nfpm/dfget.yaml \
--target /root/bin/$(DFGET_ARCHIVE_PREFIX)_linux_amd64.deb
@echo "Build package output: ./bin/$(DFGET_ARCHIVE_PREFIX)_linux_amd64.deb"
.PHONY: build-deb-dfget
# Generate dfget man page
build-dfget-man-page:
@pandoc -s -t man ./docs/en/cli-reference/dfget.1.md -o ./docs/en/cli-reference/dfget.1
.PHONY: build-dfget-man-page
# Generate e2e sha256sum
build-e2e-sha256sum:
@GOOS=linux GOARCH=amd64 go build -o /tmp/sha256sum-offset test/tools/sha256sum-offset/main.go
.PHONY: build-e2e-sha256sum
# Run unittests
test:
@go test -v -gcflags "all=-l" -race -short ${PKG_LIST}
.PHONY: test
# Run tests with coverage
test-coverage:
@go test -v -gcflags "all=-l" -race -short ${PKG_LIST} -coverprofile cover.out -covermode=atomic
@cat cover.out >> coverage.txt
.PHONY: test-coverage
# Run github actions E2E tests with coverage
actions-e2e-test-coverage:
@ginkgo -v -r --race --fail-fast --cover --trace --progress test/e2e
@cat coverprofile.out >> coverage.txt
.PHONY: actions-e2e-test-coverage
# Install E2E tests environment
install-e2e-test:
@./hack/install-e2e-test.sh
.PHONY: install-e2e-test
# Run E2E tests
e2e-test: install-e2e-test build-e2e-sha256sum
@ginkgo -v -r --race --fail-fast --cover --trace --progress test/e2e
.PHONY: e2e-test
# Run E2E tests with coverage
e2e-test-coverage: install-e2e-test build-e2e-sha256sum
@ginkgo -v -r --race --fail-fast --cover --trace --progress test/e2e
@cat coverprofile.out >> coverage.txt
.PHONY: e2e-test-coverage
# Clean E2E tests
clean-e2e-test:
@kind delete cluster
@echo "cleaning log file"
@rm -rf test/e2e/*.log
.PHONY: clean-e2e-test
# Kind load dragonlfy
kind-load: kind-load-cdn kind-load-scheduler kind-load-dfdaemon kind-load-manager kind-load-testing-tools
@echo "Kind load image done."
.PHONY: kind-load
# Run kind load docker-image cdn
kind-load-cdn:
@./hack/kind-load.sh cdn
.PHONY: kind-load-cdn
# Run kind load docker scheduler
kind-load-scheduler:
@./hack/kind-load.sh scheduler
.PHONY: kind-load-scheduler
# Run kind load docker dfget
kind-load-dfdaemon:
@./hack/kind-load.sh dfdaemon
.PHONY: kind-load-dfget
# Run kind load docker manager
kind-load-manager:
@./hack/kind-load.sh manager
.PHONY: kind-load-manager
# Run kind load docker testing tools
kind-load-testing-tools:
@./hack/kind-load.sh no-content-length
.PHONY: kind-load-testing-tools
# Run code lint
lint: markdownlint
@echo "Begin to golangci-lint."
@golangci-lint run
.PHONY: lint
# Run markdown lint
markdownlint:
@echo "Begin to markdownlint."
@./hack/markdownlint.sh
.PHONY: markdownlint
# Run go generate
generate:
@go generate ${PKG_LIST}
.PHONY: generate
# Generate swagger files
swag:
@swag init --parseDependency --parseInternal -g cmd/manager/main.go -o api/manager
# Generate changelog
changelog:
@git-chglog -o CHANGELOG.md
.PHONY: changelog
# Clear compiled files
clean:
@go clean
@rm -rf bin .go .cache
.PHONY: clean
help:
@echo "make build-dirs prepare required folders for build"
@echo "make docker-build build dragonfly image"
@echo "make docker-push push dragonfly image"
@echo "make docker-build-cdn build CDN image"
@echo "make docker-build-dfdaemon build dfdaemon image"
@echo "make docker-build-scheduler build scheduler image"
@echo "make docker-push-cdn push CDN image"
@echo "make docker-push-dfdaemon push dfdaemon image"
@echo "make docker-push-scheduler push scheduler image"
@echo "make build build dragonfly"
@echo "make build-cdn build CDN"
@echo "make build-dfget build dfget"
@echo "make build-dfget-linux build linux dfget"
@echo "make build-scheduler build scheduler"
@echo "make build-manager build manager"
@echo "make build-manager-console build manager console"
@echo "make build-e2e-sha256sum build sha256sum test tool"
@echo "make install-cdn install CDN"
@echo "make install-dfget install dfget"
@echo "make install-scheduler install scheduler"
@echo "make install-manager install manager"
@echo "make build-rpm-dfget build rpm dfget"
@echo "make build-deb-dfget build deb dfget"
@echo "make build-dfget-man-page generate dfget man page"
@echo "make test run unit tests"
@echo "make test-coverage run tests with coverage"
@echo "make actions-e2e-test-coverage run github actons E2E tests with coverage"
@echo "make install-e2e-test install E2E tests environment"
@echo "make e2e-test run e2e tests"
@echo "make e2e-test-coverage run e2e tests with coverage"
@echo "make clean-e2e-test clean e2e tests"
@echo "make kind-load kind load docker image"
@echo "make kind-load-cdn kind load cdn docker image"
@echo "make kind-load-scheduler kind load scheduler docker image"
@echo "make kind-load-dfdaemon kind load dfdaemon docker image"
@echo "make kind-load-manager kind load manager docker image"
@echo "make kind-load-testing-tools kind load testing tools docker image"
@echo "make lint run code lint"
@echo "make markdownlint run markdown lint"
@echo "make swag generate swagger api docs"
@echo "make changelog generate CHANGELOG.md"
@echo "make generate run go generate"
@echo "make clean clean"