-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
153 lines (116 loc) · 4.59 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
REPO_ROOT := $(shell git rev-parse --show-toplevel)
.DEFAULT_GOAL:=help
SHELL:=/usr/bin/env bash
COLOR:=\\033[36m
NOCOLOR:=\\033[0m
GITREPO=$(shell git remote -v | grep fetch | awk '{print $$2}' | sed 's/\.git//g' | sed 's/https:\/\///g')
PROJECTS= nft-meta block-etl cloud-proxy gateway ranker transform webui dashboard entrance gen-car #dealer
GO_PROJECTS= nft-meta block-etl cloud-proxy gateway ranker transform entrance gen-car #dealer
##@ init project
init:
cp -f .githooks/* .git/hooks
go.mod:
go mod init ${GITREPO}
go mod tidy -compat=1.19
deps: ./extern/filecoin-ffi/filcrypto.pc
all_proxy=${all_proxy} bash -x ${REPO_ROOT}/hack/deps.sh
##@ Verify
.PHONY: add-verify-hook verify verify-build verify-golangci-lint verify-go-mod verify-shellcheck verify-spelling all
add-verify-hook: ## Adds verify scripts to git pre-commit hooks.
# Note: The pre-commit hooks can be bypassed by using the flag --no-verify when
# performing a git commit.
git config --local core.hooksPath "${REPO_ROOT}/.githooks"
# TODO(lint): Uncomment verify-shellcheck once we finish shellchecking the repo.
verify: ./extern/filecoin-ffi/filcrypto.pc go.mod verify-golangci-lint verify-go-mod #verify-shellcheck ## Runs verification scripts to ensure correct execution
all_proxy=${all_proxy} bash -x ${REPO_ROOT}/hack/verify.sh
verify-shellcheck: ## Runs shellcheck
${REPO_ROOT}/hack/verify-shellcheck.sh
gen-ent:
go install entgo.io/ent/cmd/[email protected]
go get entgo.io/ent/cmd/[email protected]
go run -mod=mod entgo.io/ent/cmd/ent generate --feature entql,sql/lock,sql/execquery,sql/upsert,privacy,schema/snapshot,sql/modifier ./nft-meta/pkg/db/ent/schema
ifdef AIMPROJECT
PROJECTS= $(AIMPROJECT)
endif
ifndef DEVELOPMENT
DEVELOPMENT= dev
endif
ifndef DOCKER_REGISTRY
DOCKER_REGISTRY= uhub.service.ucloud.cn
endif
ifndef TAG
TAG= latest
endif
.PHONY: build build-docker release-docker deploy-to-k8s-cluster
./extern/filecoin-ffi/filcrypto.pc:
mkdir extern -p
cd extern; git clone https://github.com/filecoin-project/filecoin-ffi.git || true
cd extern/filecoin-ffi; git pull; git checkout v1.23.0
FFI_USE_CUDA=0 FFI_USE_OPENCL=1 make -C extern/filecoin-ffi .install-filcrypto
./dealer/output/linux/amd64/lotus:
mkdir -p dealer/output/linux/amd64/
curl -sL https://github.com/filecoin-project/lotus/releases/download/v1.23.1-rc2/lotus_v1.23.1-rc2_linux_amd64.tar.gz -o dealer/output/linux/amd64/lotus_v1.23.1-rc2_linux_amd64.tar.gz
tar xvvf dealer/output/linux/amd64/lotus_v1.23.1-rc2_linux_amd64.tar.gz -C dealer/output/linux/amd64/
mv dealer/output/linux/amd64/lotus_v1.23.1-rc2_linux_amd64/lotus dealer/output/linux/amd64
./dealer/output/linux/amd64/ipfs:
mkdir -p dealer/output/linux/amd64/
curl -sL https://dist.ipfs.tech/kubo/v0.20.0/kubo_v0.20.0_linux-amd64.tar.gz -o dealer/output/linux/amd64/kubo_v0.20.0_linux-amd64.tar.gz
tar -xvzf dealer/output/linux/amd64/kubo_v0.20.0_linux-amd64.tar.gz -C dealer/output/linux/amd64/
cp dealer/output/linux/amd64/kubo/ipfs dealer/output/linux/amd64/
dealer: ./dealer/output/linux/amd64/lotus ./dealer/output/linux/amd64/ipfs
build: ./extern/filecoin-ffi/filcrypto.pc ## Build project
@for x in $(PROJECTS); do \
${REPO_ROOT}/$${x}/script/build.sh $(TAG);\
done
build-docker:
@for x in $(PROJECTS); do \
${REPO_ROOT}/$${x}/script/build-docker-image.sh $(TAG) $(DOCKER_REGISTRY);\
done
release-docker:
@for x in $(PROJECTS); do \
${REPO_ROOT}/$${x}/script/release-docker-image.sh $(TAG) $(DOCKER_REGISTRY);\
done
deploy-to-k8s-cluster:
@for x in $(PROJECTS); do \
${REPO_ROOT}/$${x}/script/deploy-to-k8s-cluster.sh $(TAG) $(DOCKER_REGISTRY);\
done
prepare-golang-env:
all_proxy=${all_proxy} bash -x ${REPO_ROOT}/hack/set-golang-env.sh
prepare-node-env:
all_proxy=${all_proxy} ${REPO_ROOT}/hack/set-node-env.sh
##@ Tests
.PHONY: go-unit-test go-ut
# TODO:build unit test system
go-unit-test: verify-build
# go-unit-test: verify-build before-test test-go after-test
# before-test:
# @for x in $(GO_PROJECTS); do \
# ${REPO_ROOT}/$${x}/script/before-test.sh;\
# done
# test-go:
# @for x in $(GO_PROJECTS); do \
# ${REPO_ROOT}/$${x}/script/test-go.sh;\
# done
# after-test:
# @for x in $(GO_PROJECTS); do \
# ${REPO_ROOT}/$${x}/script/after-test.sh;\
# done
test-verbose:
VERBOSE=1 make test
##@ Helpers
.PHONY: help
help: ## Display this help
@awk \
-v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
' \
BEGIN { \
FS = ":.*##" ; \
printf "\nUsage:\n make %s<target>%s\n", col, nocol \
} \
/^[a-zA-Z_-]+:.*?##/ { \
printf " %s%-15s%s %s\n", col, $$1, nocol, $$2 \
} \
/^##@/ { \
printf "\n%s%s%s\n", col, substr($$0, 5), nocol \
} \
' $(MAKEFILE_LIST)