-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathMakefile
276 lines (221 loc) · 9.67 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
#!/usr/bin/make -f
# set variables
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
ifeq (,$(VERSION))
VERSION := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
LEDGER_ENABLED ?= true
COSMOS_SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
CMT_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
DOCKER := $(shell which docker)
# process build tags
build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=juno \
-X github.com/cosmos/cosmos-sdk/version.AppName=junod \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(CMT_VERSION)
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
###############################################################################
### Build ###
###############################################################################
verify:
@echo "🔎 - Verifying Dependencies ..."
@go mod verify > /dev/null 2>&1
@go mod tidy
@echo "✅ - Verified dependencies successfully!"
@echo ""
go-cache: verify
@echo "📥 - Downloading and caching dependencies..."
@go mod download
@echo "✅ - Downloaded and cached dependencies successfully!"
@echo ""
install: go-cache
@echo "🔄 - Installing Juno..."
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/junod
@echo "✅ - Installed Juno successfully! Run it using 'junod'!"
@echo ""
@echo "====== Install Summary ======"
@echo "Juno: $(VERSION)"
@echo "Cosmos SDK: $(COSMOS_SDK_VERSION)"
@echo "Comet: $(CMT_VERSION)"
@echo "============================="
build: go-cache
@echo "🔄 - Building Juno..."
@if [ "$(OS)" = "Windows_NT" ]; then \
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o bin/junod.exe ./cmd/junod; \
else \
go build -mod=readonly $(BUILD_FLAGS) -o bin/junod ./cmd/junod; \
fi
@echo "✅ - Built Juno successfully! Run it using './bin/junod'!"
@echo ""
@echo "====== Install Summary ======"
@echo "Juno: $(VERSION)"
@echo "Cosmos SDK: $(COSMOS_SDK_VERSION)"
@echo "Comet: $(CMT_VERSION)"
@echo "============================="
test-node:
CHAIN_ID="local-1" HOME_DIR="~/.juno" TIMEOUT_COMMIT="500ms" CLEAN=true sh scripts/test_node.sh
.PHONY: verify go-cache install build test-node
###############################################################################
### Tooling ###
###############################################################################
gofumpt=mvdan.cc/gofumpt
gofumpt_version=v0.7.0
golangci_lint=github.com/golangci/golangci-lint/cmd/golangci-lint
golangci_lint_version=v1.63.4
goimports=golang.org/x/tools/cmd/goimports
goimports_version=v0.29.0
install-format:
@if ! command -v gofumpt > /dev/null; then \
echo "🔄 - Installing gofumpt $(gofumpt_version)..."; \
go install $(gofumpt)@$(gofumpt_version); \
echo "✅ - Installed gofumpt successfully!"; \
echo ""; \
fi
format: install-format
@echo "🔄 - Formatting code..."
@gofumpt -l -w .
@echo "✅ - Formatted code successfully!"
install-lint:
@if ! command -v golangci-lint > /dev/null; then \
echo "🔄 - Installing golangci-lint $(golangci_lint_version)..."; \
go install $(golangci_lint)@$(golangci_lint_version); \
echo "✅ - Installed golangci-lint successfully!"; \
echo ""; \
fi
@if ! command -v goimports > /dev/null; then \
echo "🔄 - Installing goimports $(goimports_version)..."; \
go install $(goimports)@$(goimports_version); \
echo "✅ - Installed goimports successfully!"; \
echo ""; \
fi
lint: install-lint
@echo "🔄 - Linting code..."
@find . -name '*.go' -type f -not -path "*.git*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs -I % sh -c 'gofumpt -w -l % && goimports -w -local github.com/CosmosContracts %'
@golangci-lint run --timeout=10m --fix --exclude-files ".*.pb.go"
@echo "✅ - Linted code successfully!"
.PHONY: install-format format install-lint lint
###############################################################################
### e2e interchain test ###
###############################################################################
ictest-basic: rm-testcache
cd interchaintest && go test -race -v -run TestBasicJunoStart .
ictest-statesync: rm-testcache
cd interchaintest && go test -race -v -run TestJunoStateSync .
ictest-ibchooks: rm-testcache
cd interchaintest && go test -race -v -run TestJunoIBCHooks .
ictest-tokenfactory: rm-testcache
cd interchaintest && go test -race -v -run TestJunoTokenFactory .
ictest-feeshare: rm-testcache
cd interchaintest && go test -race -v -run TestJunoFeeShare .
ictest-pfm: rm-testcache
cd interchaintest && go test -race -v -run TestPacketForwardMiddlewareRouter .
ictest-globalfee: rm-testcache
cd interchaintest && go test -race -v -run TestJunoGlobalFee .
ictest-upgrade: rm-testcache
cd interchaintest && go test -race -v -run TestBasicJunoUpgrade .
ictest-ibc: rm-testcache
cd interchaintest && go test -race -v -run TestJunoGaiaIBCTransfer .
ictest-unity-deploy: rm-testcache
cd interchaintest && go test -race -v -run TestJunoUnityContractDeploy .
ictest-drip: rm-testcache
cd interchaintest && go test -race -v -run TestJunoDrip .
ictest-feepay: rm-testcache
cd interchaintest && go test -race -v -run TestJunoFeePay .
ictest-burn: rm-testcache
cd interchaintest && go test -race -v -run TestJunoBurnModule .
ictest-cwhooks: rm-testcache
cd interchaintest && go test -race -v -run TestJunoCwHooks .
ictest-clock: rm-testcache
cd interchaintest && go test -race -v -run TestJunoClock .
rm-testcache:
go clean -testcache
.PHONY: ictest-basic ictest-statesync ictest-ibchooks ictest-tokenfactory ictest-feeshare ictest-pfm ictest-globalfee ictest-upgrade ictest-upgrade-local ictest-ibc ictest-unity-deploy ictest-unity-gov ictest-drip ictest-burn ictest-feepay ictest-cwhooks ictest-clock rm-testcache
###############################################################################
### heighliner ###
###############################################################################
heighliner=github.com/strangelove-ventures/heighliner
heighliner_version=v1.7.1
install-heighliner:
@if ! command -v heighliner > /dev/null; then \
echo "🔄 - Installing heighliner $(heighliner_version)..."; \
go install $(heighliner)@$(heighliner_version); \
echo "✅ - Installed heighliner successfully!"; \
echo ""; \
fi
local-image: install-heighliner
@echo "🔄 - Building Docker Image..."
heighliner build --chain juno --local -f ./chains.yaml
@echo "✅ - Built Docker Image successfully!"
.PHONY: install-heighliner local-image
###############################################################################
### Protobuf ###
###############################################################################
protoVer=0.15.3
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace -v /var/run/docker.sock:/var/run/docker.sock --workdir /workspace $(protoImageName)
proto-all: proto-format proto-lint proto-gen proto-gen-2 proto-swagger-gen
proto-gen:
@echo "🛠️ - Generating Protobuf"
@$(protoImage) sh ./scripts/protoc/protocgen.sh
@echo "✅ - Generated Protobuf successfully!"
proto-gen-2:
@echo "🛠️ - Generating Protobuf v2"
@$(protoImage) sh ./scripts/protoc/protocgen2.sh
@echo "✅ - Generated Protobuf v2 successfully!"
proto-swagger-gen:
@echo "📖 - Generating Protobuf Swagger"
@$(protoImage) sh ./scripts/protoc/protoc-swagger-gen.sh
@echo "✅ - Generated Protobuf Swagger successfully!"
proto-format:
@echo "🖊️ - Formatting Protobuf Swagger"
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
@echo "✅ - Formatted Protobuf successfully!"
proto-lint:
@echo "🔎 - Linting Protobuf"
@$(protoImage) buf lint --error-format=json
@echo "✅ - Linted Protobuf successfully!"
proto-check-breaking:
@echo "🔎 - Checking breaking Protobuf changes"
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main
@echo "✅ - Checked Protobuf changes successfully!"
.PHONY: proto-all proto-gen proto-gen-2 proto-swagger-gen proto-format proto-lint proto-check-breaking