forked from InjectiveLabs/peggo
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
117 lines (93 loc) · 4.51 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
BUILD_DIR ?= $(CURDIR)/build
SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
###############################################################################
## Version ##
###############################################################################
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
###############################################################################
## Build / Install ##
###############################################################################
ldflags = -X github.com/umee-network/peggo/cmd/peggo.Version=$(VERSION) \
-X github.com/umee-network/peggo/cmd/peggo.Commit=$(COMMIT) \
-X github.com/umee-network/peggo/cmd/peggo.SDKVersion=$(SDK_VERSION)
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
build_tags += $(BUILD_TAGS)
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
build: go.sum
@echo "--> Building..."
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILD_DIR)/ ./...
install: go.sum
@echo "--> Installing..."
go install -mod=readonly $(BUILD_FLAGS) ./...
.PHONY: build install
###############################################################################
## Tests & Linting ##
###############################################################################
PACKAGES_UNIT=$(shell go list ./... | grep -v '/e2e' | grep -v '/solidity' | grep -v '/test' )
PACKAGES_E2E=$(shell go list ./... | grep '/e2e')
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-cover test-race test-e2e
test-unit: ARGS=-timeout=5m -tags='norace'
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
test-unit-cover: ARGS=-timeout=5m -tags='norace' -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)
test-e2e: ARGS=-timeout=20m -v
test-e2e: TEST_PACKAGES=$(PACKAGES_E2E)
$(TEST_TARGETS): run-tests
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
@echo "--> Running tests"
@go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) | tparse
else
@echo "--> Running tests"
@go test -mod=readonly $(ARGS) $(TEST_PACKAGES)
endif
test-integration:
@echo "--> Running tests"
@go test -mod=readonly -race ./test/... -v
lint:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=10m
mocks:
@echo "--> Generating mocks"
@go run github.com/golang/mock/mockgen -destination=mocks/cosmos.go \
-package=mocks github.com/umee-network/peggo/cmd/peggo/client \
CosmosClient
@go run github.com/golang/mock/mockgen -destination=mocks/evm_provider.go \
-package=mocks github.com/umee-network/peggo/orchestrator/ethereum/provider \
EVMProviderWithRet
@go run github.com/golang/mock/mockgen -destination=mocks/gravity_queryclient.go \
-package=mocks github.com/Gravity-Bridge/Gravity-Bridge/module/x/gravity/types \
QueryClient
@go run github.com/golang/mock/mockgen -destination=mocks/gravity/gravity_contract.go \
-package=gravity github.com/umee-network/peggo/orchestrator/ethereum/gravity \
Contract
.PHONY: test-integration lint mocks
###############################################################################
## Solidity ##
###############################################################################
gen: solidity-wrappers
SOLIDITY_DIR = ../Gravity-Bridge/solidity
solidity-wrappers: $(SOLIDITY_DIR)/contracts/*.sol
cd $(SOLIDITY_DIR)/contracts/ ; \
for file in $(^F) ; do \
mkdir -p ../wrappers/$${file} ; \
echo abigen --type=peggy --pkg wrappers --out=../wrappers/$${file}/wrapper.go --sol $${file} ; \
abigen --type=peggy --pkg wrappers --out=../wrappers/$${file}/wrapper.go --sol $${file} ; \
done
###############################################################################
## Docker ##
###############################################################################
docker-build:
@docker build -t umeenet/peggo-e2e --platform=linux/amd64 -f contrib/images/e2e.dockerfile .
docker-build-debug:
@docker build -t umeenet/peggo-e2e --build-arg IMG_TAG=debug -f contrib/images/e2e.dockerfile .
.PHONY: docker-build docker-build-debug