forked from KYVENetwork/chain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
175 lines (140 loc) Β· 6.54 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
COMMIT := $(shell git log -1 --format='%H')
GO_VERSION := $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1,2)
VERSION := v1.4.0 # $(shell echo $(shell git describe --tags) | sed 's/^v//')
TEAM_ALLOCATION := 165000000000000
ifeq ($(ENV),kaon)
$(info π Using Kaon environment...)
DENOM := tkyve
TEAM_TGE := 2023-02-07T14:00:00
TEAM_FOUNDATION_ADDRESS := kyve1vut528et85755xsncjwl6dx8xakuv26hxgyv0n
TEAM_BCP_ADDRESS := kyve1vut528et85755xsncjwl6dx8xakuv26hxgyv0n
else ifeq ($(ENV),mainnet)
$(info π Using mainnet environment...)
DENOM := ukyve
TEAM_TGE := 2023-03-14T14:03:14
TEAM_FOUNDATION_ADDRESS := kyve1xjpl57p7f49y5gueu7rlfytaw9ramcn5zhjy2g
TEAM_BCP_ADDRESS := kyve1fnh4kghr25tppskap50zk5j385pt65tyyjaraa
endif
ldflags := $(LDFLAGS)
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=kyve \
-X github.com/cosmos/cosmos-sdk/version.AppName=kyved \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/KYVENetwork/chain/x/global/types.Denom=$(DENOM) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_FOUNDATION_STRING=$(TEAM_FOUNDATION_ADDRESS) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_BCP_STRING=$(TEAM_BCP_ADDRESS) \
-X github.com/KYVENetwork/chain/x/team/types.TEAM_ALLOCATION_STRING=$(TEAM_ALLOCATION) \
-X github.com/KYVENetwork/chain/x/team/types.TGE_STRING=$(TEAM_TGE)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -ldflags '$(ldflags)' -tags 'ledger' -trimpath
.PHONY: proto-setup proto-format proto-lint proto-gen \
format lint vet test build release dev
all: ensure_environment ensure_version proto-all format lint test build
###############################################################################
### Build ###
###############################################################################
build: ensure_environment ensure_version
@echo "π€ Building kyved..."
@go build $(BUILD_FLAGS) -o "$(PWD)/build/" ./cmd/kyved
@echo "β
Completed build!"
install: ensure_environment ensure_version
@echo "π€ Installing kyved..."
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/kyved
@echo "β
Completed installation!"
release: ensure_environment ensure_version
@echo "π€ Creating kyved releases..."
@rm -rf release
@mkdir -p release
@GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) ./cmd/kyved
@tar -czf release/kyved_$(ENV)_darwin_amd64.tar.gz kyved
@sha256sum release/kyved_$(ENV)_darwin_amd64.tar.gz >> release/release_$(ENV)_checksum
@GOOS=darwin GOARCH=arm64 go build $(BUILD_FLAGS) ./cmd/kyved
@tar -czf release/kyved_$(ENV)_darwin_arm64.tar.gz kyved
@sha256sum release/kyved_$(ENV)_darwin_arm64.tar.gz >> release/release_$(ENV)_checksum
@GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) ./cmd/kyved
@tar -czf release/kyved_$(ENV)_linux_amd64.tar.gz kyved
@sha256sum release/kyved_$(ENV)_linux_amd64.tar.gz >> release/release_$(ENV)_checksum
@GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) ./cmd/kyved
@tar -czf release/kyved_$(ENV)_linux_arm64.tar.gz kyved
@sha256sum release/kyved_$(ENV)_linux_arm64.tar.gz >> release/release_$(ENV)_checksum
@rm kyved
@echo "β
Completed release creation!"
###############################################################################
### Checks ###
###############################################################################
ensure_environment:
ifndef ENV
$(error β Please specify a build environment..)
endif
ensure_version:
ifneq ($(GO_VERSION),1.20)
$(error β Please run Go v1.20.x..)
endif
###############################################################################
### Development ###
###############################################################################
# TODO(@john): Switch to the Docker image?
dev:
@ignite chain serve --reset-once --skip-proto --verbose
###############################################################################
### Formatting & Linting ###
###############################################################################
gofumpt_cmd=mvdan.cc/gofumpt
golangci_lint_cmd=github.com/golangci/golangci-lint/cmd/golangci-lint
format:
@echo "π€ Running formatter..."
@go run $(gofumpt_cmd) -l -w .
@echo "β
Completed formatting!"
lint:
@echo "π€ Running linter..."
@go run $(golangci_lint_cmd) run --skip-dirs scripts --timeout=10m
@echo "β
Completed linting!"
# TODO(@john): Can we remove this since we use GolangCI?
vet:
@echo "π€ Running vet..."
@go vet ./...
@echo "β
Completed vet!"
###############################################################################
### Protobuf ###
###############################################################################
BUF_VERSION=1.20.0
proto-all: proto-format proto-lint proto-gen
proto-format:
@echo "π€ Running protobuf formatter..."
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \
bufbuild/buf:$(BUF_VERSION) format --diff --write
@echo "β
Completed protobuf formatting!"
proto-gen:
@echo "π€ Generating code from protobuf..."
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \
kyve-proto sh ./proto/generate.sh
@echo "β
Completed code generation!"
proto-lint:
@echo "π€ Running protobuf linter..."
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \
bufbuild/buf:$(BUF_VERSION) lint
@echo "β
Completed protobuf linting!"
proto-setup:
@echo "π€ Setting up protobuf environment..."
@docker build --rm --tag kyve-proto:latest --file proto/Dockerfile .
@echo "β
Setup protobuf environment!"
###############################################################################
### Tests & Simulation ###
###############################################################################
heighliner:
@echo "π€ Building Kaon image..."
@heighliner build --chain kaon --local 1> /dev/null
@echo "β
Completed build!"
@echo "π€ Building KYVE image..."
@heighliner build --chain kyve --local 1> /dev/null
@echo "β
Completed build!"
heighliner-setup:
@echo "π€ Installing Heighliner..."
@git clone https://github.com/strangelove-ventures/heighliner.git
@cd heighliner && go install && cd ..
@rm -rf heighliner
@echo "β
Completed installation!"
test:
@echo "π€ Running tests..."
@go test -cover -mod=readonly ./x/...
@echo "β
Completed tests!"