-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathMakefile
233 lines (165 loc) · 7.38 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
NAME := cvms
VERSION := $(shell echo $(shell git describe --tags))
COMMIT := $(shell git log -1 --format='%H')
MODULE_NAME := "github.com/cosmostation/cvms"
BUILD_FLAGS := -ldflags "-s -w \
-X ${MODULE_NAME}/cmd.AppName=${NAME} \
-X ${MODULE_NAME}/cmd.Version=${VERSION} \
-X ${MODULE_NAME}/cmd.Commit=${COMMIT}"
GOTEST_PALETTE := "red,green"
# Load environment variables from .env file
ifneq (,$(wildcard .env))
include .env
export $(shell sed 's/=.*//' .env)
endif
###############################################################################
### Tools & Dependencies ###
###############################################################################
# Show all make targets
help:
@make2help $(MAKEFILE_LIST)
# Check currernt verison
version:
@echo "NAME: ${NAME}"
@echo "VERSION: ${VERSION}"
@echo "COMMIT: ${COMMIT}"
# Sort chain_id in support_chains.yaml
sort_support_chains:
@yq eval 'sort_keys(.)' -i ./docker/cvms/support_chains.yaml
PHONY: help version
###############################################################################
### Build ###
###############################################################################
## Binary build
build:
@echo "-> Building ${NAME}"
@go build ${BUILD_FLAGS} -trimpath -o ./bin/${NAME} ./cmd/${NAME}
## Binary install
install:
@echo "-> Installing ${NAME} into ${GOPATH}/bin/${NAME}"
@go build ${BUILD_FLAGS} -trimpath -o ${GOPATH}/bin/${NAME} ./cmd/${NAME}
## Run tests
run:
go build -o bin/${NAME}
.bin/${NAME}
## Clean ./bin/*
clean:
go clean
rm ./bin/${NAME}
PHONY: build install run clean
###############################################################################
### Docker ###
###############################################################################
## Reset indexer db
reset-db:
@echo "-> Re-up postgres container for reset"
@docker compose down -v postgres && docker compose up -d postgres
###############################################################################
### Migration ###
###############################################################################
migration:
@echo "-> Start flyway service for new schemas in CVMS"
@docker compose --profile migration up flyway
###############################################################################
### Start ###
###############################################################################
## start exporter application in debug mode
start-exporter:
@echo "-> Start CVMS in script mode"
@go run ./cmd/cvms start exporter --config ${CONFIG_PATH} --log-color-disable ${LOG_COLOR_DISABLE} --log-level ${LOG_LEVEL}
## start indexer application in debug mode
start-indexer:
@echo "-> Start CVMS Indexer"
@go run ./cmd/cvms start indexer --config ${CONFIG_PATH} --log-color-disable ${LOG_COLOR_DISABLE} --log-level ${LOG_LEVEL} --port 9300
## start exporter application for specific package
SPECIFIC_PACKAGE ?= block
start-exporter-specific-package:
@echo "-> Start CVMS in script mode, you can use this task adding a argument like 'make start-specific-package SPECIFIC_PACKAGE=eventnonce'"
@echo "Selected Package: ${SPECIFIC_PACKAGE}"
@go run ./cmd/cvms start exporter --config ./config.yaml --log-color-disable ${LOG_COLOR_DISABLE} --log-level ${LOG_LEVEL} --package-filter ${SPECIFIC_PACKAGE} --port 9200
### Test runner
SPECIFIC_PACKAGE ?= voteindexer
start-indexer-specific-package:
@echo "-> Start CVMS in script mode, you can use this task adding a argument like 'make start-specific-package SPECIFIC_PACKAGE=voteindexer'"
@echo "Selected Package: ${SPECIFIC_PACKAGE}"
@go run ./cmd/cvms start indexer --config ./config.yaml --log-color-disable ${LOG_COLOR_DISABLE} --log-level ${LOG_LEVEL} --package-filter ${SPECIFIC_PACKAGE} --port 9300
###############################################################################
### Test Packages ###
###############################################################################
# health packages
PACKAGE_NAME_BLOCK := internal/packages/health/block
## Unit testing block package
test-pkg-block:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_BLOCK}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_BLOCK}/... -v -count=1
@echo "End Unit Testing"
@echo
# utility packages
PACKAGE_NAME_BALANCE := internal/packages/utility/balance
PACKAGE_NAME_UPGRADE := internal/packages/utility/upgrade
## Unit testing upgrade package
test-pkg-upgrade:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_UPGRADE}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_UPGRADE}/... -v -count=1
@echo "End Unit Testing"
@echo
## Unit testing balance package
test-pkg-balance:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_BALANCE}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_BALANCE}/... -v -count=1
@echo "End Unit Testing"
@echo
# duty packages
PACKAGE_NAME_EVENTNONCE := internal/packages/duty/eventnonce
PACKAGE_NAME_ORACLE := internal/packages/duty/oracle
PACKAGE_NAME_YODA := internal/packages/duty/yoda
PACKAGE_NAME_AXELAR-EVM := internal/packages/duty/axelar-evm
## Unit testing oracle package
test-pkg-oracle:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_ORACLE}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_ORACLE}/... -v -count=1
@echo "End Unit Testing"
@echo
## Unit testing eventnonce package
test-pkg-eventnonce:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_EVENTNONCE}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_EVENTNONCE}/... -v -count=1
@echo "End Unit Testing"
@echo
## Unit testing axelar-evm package
test-pkg-axelarevm:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_AXELAR-EVM}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_AXELAR-EVM}/... -v -count=1
@echo "End Unit Testing"
@echo
## Unit testing yoda package
test-pkg-yoda:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_YODA}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_YODA}/... -v -count=1
@echo "End Unit Testing"
@echo
# consensus packages
PACKAGE_NAME_UPTIME := internal/packages/consensus/uptime
## Unit testing uptime package
test-pkg-uptime:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_UPTIME}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_UPTIME}/... -v -count=1
@echo "End Unit Testing"
@echo
# babylon-finality-provider packages
PACKAGE_NAME_BAYLON_FP := internal/packages/babylon/finality-provider/api
## Unit testing uptime package
test-pkg-babylon-fp:
@echo "Start Unit Testing: Current Unit Module is '${PACKAGE_NAME_BAYLON_FP}'"
@gotest ${MODULE_NAME}/${PACKAGE_NAME_BAYLON_FP}/... -v -count=1
@echo "End Unit Testing"
@echo
###############################################################################
### Test All ###
###############################################################################
## Unit testing all packages
test-pkg-all:
@echo "Start All Packages Testing..."
@gotest ./internal/packages/... -short -count=1
@echo "End Testing"
@echo