-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Makefile
218 lines (174 loc) · 7.68 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
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
DIRTY := $(shell git status --porcelain | wc -l | xargs)
GAIA_VERSION := v7.0.1
AKASH_VERSION := v0.16.3
OSMOSIS_VERSION := v8.0.0
WASMD_VERSION := v0.25.0
DOCKER := $(shell which docker)
GOPATH := $(shell go env GOPATH)
GOBIN := $(GOPATH)/bin
all: lint install
###############################################################################
# Build / Install
###############################################################################
ldflags = -X github.com/cosmos/relayer/v2/cmd.Version=$(VERSION) \
-X github.com/cosmos/relayer/v2/cmd.Commit=$(COMMIT) \
-X github.com/cosmos/relayer/v2/cmd.Dirty=$(DIRTY)
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -ldflags '$(ldflags)'
#? build: Build the rly binary
build: go.sum
ifeq ($(OS),Windows_NT)
@echo "building rly binary..."
@go build -mod=readonly $(BUILD_FLAGS) -o build/rly.exe main.go
else
@echo "building rly binary..."
@go build $(BUILD_FLAGS) -o build/rly main.go
endif
#? build-zip: Build rly binaries for all supported operating systems
build-zip: go.sum
@echo "building rly binaries for windows, mac and linux"
@GOOS=linux GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/linux-amd64-rly main.go
@GOOS=darwin GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/darwin-amd64-rly main.go
@GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/windows-amd64-rly.exe main.go
@tar -czvf release.tar.gz ./build
#? install: Install rly binary to GOBIN
install: go.sum
@echo "installing rly binary..."
@go build -mod=readonly $(BUILD_FLAGS) -o $(GOBIN)/rly main.go
#? build-gaia-docker: Build Docker image for Gaia
build-gaia-docker:
docker build -t cosmos/gaia:$(GAIA_VERSION) --build-arg VERSION=$(GAIA_VERSION) -f ./docker/gaiad/Dockerfile .
#? build-akash-docker: Build Docker image for Akash
build-akash-docker:
docker build -t ovrclk/akash:$(AKASH_VERSION) --build-arg VERSION=$(AKASH_VERSION) -f ./docker/akash/Dockerfile .
#? build-osmosis-docker: Build Docker image for Osmosis
build-osmosis-docker:
docker build -t osmosis-labs/osmosis:$(OSMOSIS_VERSION) --build-arg VERSION=$(OSMOSIS_VERSION) -f ./docker/osmosis/Dockerfile .
###############################################################################
# Tests / CI
###############################################################################
#? test: Run all unit tests
test:
@go test -mod=readonly -race ./...
#? interchaintest: Run interchain TestRelayerInProcess tests
interchaintest:
cd interchaintest && go test -race -v -run TestRelayerInProcess .
#? interchaintest-docker: Run interchain TestRelayerDocker tests
interchaintest-docker:
cd interchaintest && go test -race -v -run TestRelayerDocker .
#? interchaintest-docker-events: Run interchain TestRelayerDockerEventProcessor tests
interchaintest-docker-events:
cd interchaintest && go test -race -v -run TestRelayerDockerEventProcessor .
#? interchaintest-docker-legacy: Run interchain TestRelayerDockerLegacyProcessor tests
interchaintest-docker-legacy:
cd interchaintest && go test -race -v -run TestRelayerDockerLegacyProcessor .
#? interchaintest-events: Run interchain TestRelayerEventProcessor tests
interchaintest-events:
cd interchaintest && go test -race -v -run TestRelayerEventProcessor .
#? interchaintest-legacy: Run interchain TestRelayerLegacyProcessor tests
interchaintest-legacy:
cd interchaintest && go test -race -v -run TestRelayerLegacyProcessor .
#? interchaintest-multiple: Run interchain TestRelayerMultiplePathsSingleProcess tests
interchaintest-multiple:
cd interchaintest && go test -race -v -run TestRelayerMultiplePathsSingleProcess .
#? interchaintest-misbehaviour: Run interchain TestRelayerMisbehaviourDetection tests
interchaintest-misbehaviour:
cd interchaintest && go test -race -v -run TestRelayerMisbehaviourDetection .
#? interchaintest-fee-middleware: Run interchain TestRelayerFeeMiddleware tests
interchaintest-fee-middleware:
cd interchaintest && go test -race -v -run TestRelayerFeeMiddleware .
#? interchaintest-fee-grant: Run interchain TestRelayerFeeGrant tests
interchaintest-fee-grant:
cd interchaintest && go test -race -v -run TestRelayerFeeGrant .
#? interchaintest-scenario: Run interchain TestScenario tests
interchaintest-scenario: ## Scenario tests are suitable for simple networks of 1 validator and no full nodes. They test specific functionality.
cd interchaintest && go test -timeout 30m -race -v -run TestScenario ./...
#? coverage: Generate and view test coverage report
coverage:
@echo "viewing test coverage..."
@go tool cover --html=coverage.out
#? lint: Run linters and gofmt
lint:
@golangci-lint run
@find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -d -s
@go mod verify
###############################################################################
# Chain Code Downloads
###############################################################################
CHAIN_CODE := ./chain-code
GAIA_REPO := $(CHAIN_CODE)/gaia
#? get-gaia: Download the Gaia repository
get-gaia:
@mkdir -p $(CHAIN_CODE)/
@git clone --branch $(GAIA_VERSION) --depth=1 https://github.com/cosmos/gaia.git $(GAIA_REPO)
#? build-gaia: Build and install Gaia to GOBIN
build-gaia:
@[ -d $(GAIA_REPO) ] || { echo "Repository for gaia does not exist at $(GAIA_REPO). Try running 'make get-gaia'..." ; exit 1; }
@cd $(GAIA_REPO) && \
make install &> /dev/null
@gaiad version --long
.PHONY: two-chains test test-integration interchaintest install build lint coverage clean
PACKAGE_NAME := github.com/cosmos/relayer
GOLANG_CROSS_VERSION ?= v1.21.5
SYSROOT_DIR ?= sysroots
SYSROOT_ARCHIVE ?= sysroots.tar.bz2
.PHONY: sysroot-pack
#? sysroot-pack: Pack the sysroot directory into an archive
sysroot-pack:
@tar cf - $(SYSROOT_DIR) -P | pv -s $[$(du -sk $(SYSROOT_DIR) | awk '{print $1}') * 1024] | pbzip2 > $(SYSROOT_ARCHIVE)
.PHONY: sysroot-unpack
#? sysroot-unpack: Unpack the sysroot archive
sysroot-unpack:
@pv $(SYSROOT_ARCHIVE) | pbzip2 -cd | tar -xf -
.PHONY: release-dry-run
#? release-dry-run: Perform a dry run of the release process using Docker
release-dry-run:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish
.PHONY: release
#? release: Run goreleaser to build and release cross-platform rly binary version
release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist
protoVer=0.11.2
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
#? proto-all: Run proto-format proto-lint proto-gen
proto-all: proto-format proto-lint proto-gen
#? proto-gen: Generate Protobuf files
proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh
#? proto-format: Format Protobuf files using clang-format
proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
#? proto-lint: Lint Protobuf files
proto-lint:
@$(protoImage) buf lint --error-format=json
#? help: Get more info on make commands
help: Makefile
@echo " Available commands:"
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
.PHONY: help