This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
168 lines (126 loc) · 7.17 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
.PHONY: deps build run lint run-mainnet-online run-mainnet-offline run-testnet-online \
run-testnet-offline check-comments add-license check-license shorten-lines \
spellcheck salus build-local format check-format update-tracer test coverage coverage-local \
update-bootstrap-balances mocks
ADDLICENSE_IGNORE=-ignore "**/*.xml" -ignore "**/*.sh" -ignore "**/*.yml" -ignore "**/*.yaml"
ADDLICENSE_INSTALL=go install github.com/google/addlicense@latest
ADDLICENSE_CMD=addlicense
ADDLICENCE_SCRIPT=${ADDLICENSE_CMD} -c "Klaytn" -l "apache" -v ${ADDLICENSE_IGNORE}
SPELLCHECK_CMD=go run github.com/client9/misspell/cmd/misspell
GOLINES_INSTALL=go install github.com/segmentio/golines@latest
GOLINES_CMD=golines
GOLINT_INSTALL=go get golang.org/x/lint/golint
GOLINT_CMD=golint
GOVERALLS_INSTALL=go install github.com/mattn/goveralls@latest
GOVERALLS_CMD=goveralls
GOIMPORTS_CMD=go run golang.org/x/tools/cmd/goimports
GO_PACKAGES=./services/... ./cmd/... ./configuration/... ./klaytn/...
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
TEST_SCRIPT=go test ${GO_PACKAGES}
INTEGRATION_TEST_SCRIPT=go test ./integration/...
LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam
PWD=$(shell pwd)
NOFILE=100000
deps:
go get ./...
test:
${TEST_SCRIPT}
integration-test:
${INTEGRATION_TEST_SCRIPT}
build:
docker build -t rosetta-klaytn:latest https://github.com/klaytn/rosetta-klaytn.git
build-m1:
docker build --platform linux/amd64 -t rosetta-klaytn:latest https://github.com/klaytn/rosetta-klaytn.git
build-local:
docker build -t rosetta-klaytn:latest .
build-local-m1:
docker build --platform linux/amd64 -t rosetta-klaytn:latest .
# make build-release -e "version=vx.x.x"
build-release:
# make sure to always set version with vX.X.X
docker build -t rosetta-klaytn:$(version) .;
docker save rosetta-klaytn:$(version) | gzip > rosetta-klaytn-$(version).tar.gz;
# make build-release-m1 -e "version=vx.x.x"
build-release-m1:
# make sure to always set version with vX.X.X
docker build --platform linux/amd64 -t rosetta-klaytn:$(version) .;
docker save rosetta-klaytn:$(version) | gzip > rosetta-klaytn-$(version).tar.gz;
update-bootstrap-balances:
go run main.go utils:generate-bootstrap klaytn/genesis_files/mainnet.json rosetta-cli-conf/mainnet/bootstrap_balances.json;
go run main.go utils:generate-bootstrap klaytn/genesis_files/testnet.json rosetta-cli-conf/testnet/bootstrap_balances.json;
go run main.go utils:generate-bootstrap klaytn/genesis_files/localnet.json rosetta-cli-conf/localnet/bootstrap_balances.json;
run-mainnet-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-mainnet-online-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-mainnet-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest
run-mainnet-offline-m1:
docker run --platform linux/amd64 -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest
run-testnet-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-testnet-online-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-testnet-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest
run-testnet-offline-m1:
docker run --platform linux/amd64 -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest
run-local-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-local-online-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-local-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=LOCAL" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest
run-local-offline-m1:
docker run --platform linux/amd64 -d --rm -e "MODE=OFFLINE" -e "NETWORK=LOCAL" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest
run-mainnet-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
# make run-mainnet-remote-m1 -e "ken=http://x.x.x.x:8551"
run-mainnet-remote-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-testnet-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-testnet-remote-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-local-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
run-local-remote-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest
check-comments:
${GOLINT_INSTALL}
${GOLINT_CMD} -set_exit_status ${GO_FOLDERS} .
go mod tidy
lint: | check-comments
golangci-lint run --timeout 2m0s -v -E ${LINT_SETTINGS},gomnd
add-license:
${ADDLICENSE_INSTALL}
${ADDLICENCE_SCRIPT} .
check-license:
${ADDLICENSE_INSTALL}
${ADDLICENCE_SCRIPT} -check .
shorten-lines:
${GOLINES_INSTALL}
${GOLINES_CMD} -w --shorten-comments ${GO_FOLDERS} .
format:
gofmt -s -w -l .
${GOIMPORTS_CMD} -w .
check-format:
! gofmt -s -l . | read
! ${GOIMPORTS_CMD} -l . | read
salus:
docker run --rm -t -v ${PWD}:/home/repo coinbase/salus
salus-m1:
docker run --platform linux/amd64 --rm -t -v ${PWD}:/home/repo coinbase/salus
spellcheck:
${SPELLCHECK_CMD} -error .
coverage:
${GOVERALLS_INSTALL}
if [ "${COVERALLS_TOKEN}" ]; then ${TEST_SCRIPT} -coverprofile=c.out -covermode=count; ${GOVERALLS_CMD} -coverprofile=c.out -repotoken ${COVERALLS_TOKEN}; fi
coverage-local:
${TEST_SCRIPT} -cover
mocks:
rm -rf mocks;
mockery --dir services --all --case underscore --outpkg services --output mocks/services;
mockery --dir klaytn --all --case underscore --outpkg klaytn --output mocks/klaytn;
${ADDLICENSE_INSTALL}
${ADDLICENCE_SCRIPT} .;