forked from ssvlabs/ssv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
168 lines (140 loc) · 5.04 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
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
ifndef $(HOST_ADDRESS)
HOST_ADDRESS=$(shell dig @resolver4.opendns.com myip.opendns.com +short)
export HOST_ADDRESS
endif
ifndef $(BUILD_PATH)
BUILD_PATH="/go/bin/ssvnode"
export BUILD_PATH
endif
# Node command.
NODE_COMMAND=--config=${CONFIG_PATH}
ifneq ($(SHARE_CONFIG),)
NODE_COMMAND+= --share-config=${SHARE_CONFIG}
endif
# Bootnode command.
BOOTNODE_COMMAND=--config=${CONFIG_PATH}
COV_CMD="-cover"
ifeq ($(COVERAGE),true)
COV_CMD=-coverpkg=./... -covermode="atomic" -coverprofile="coverage.out"
endif
UNFORMATTED=$(shell gofmt -s -l .)
#Lint
.PHONY: lint-prepare
lint-prepare:
@echo "Preparing Linter"
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s latest
.PHONY: lint
lint:
./bin/golangci-lint run -v ./...
@if [ ! -z "${UNFORMATTED}" ]; then \
echo "Some files requires formatting, please run 'go fmt ./...'"; \
exit 1; \
fi
.PHONY: full-test
full-test:
@echo "Running all tests"
@go test -tags blst_enabled -timeout 20m ${COV_CMD} -p 1 -v ./...
.PHONY: integration-test
integration-test:
@echo "Running integration tests"
@go test -tags blst_enabled -count=1 -timeout 20m ${COV_CMD} -p 1 -v ./integration/...
.PHONY: unit-test
unit-test:
@echo "Running unit tests"
@go test -tags blst_enabled -timeout 20m ${COV_CMD} -race -p 1 -v `go list ./... | grep -ve "spectest\|integration\|ssv/scripts/"`
.PHONY: spec-test
spec-test:
@echo "Running spec tests"
@go test -tags blst_enabled -timeout 90m ${COV_CMD} -race -count=1 -p 1 -v `go list ./... | grep spectest`
.PHONY: spec-test-raceless
spec-test-raceless:
@echo "Running spec tests without race flag"
@go test -tags blst_enabled -timeout 20m -count=1 -p 1 -v `go list ./... | grep spectest`
#Test
.PHONY: docker-spec-test
docker-spec-test:
@echo "Running spec tests in docker"
@docker build -t ssv_tests -f tests.Dockerfile .
@docker run --rm ssv_tests make spec-test
#Test
.PHONY: docker-unit-test
docker-unit-test:
@echo "Running unit tests in docker"
@docker build -t ssv_tests -f tests.Dockerfile .
@docker run --rm ssv_tests make unit-test
.PHONY: docker-integration-test
docker-integration-test:
@echo "Running integration tests in docker"
@docker build -t ssv_tests -f tests.Dockerfile .
@docker run --rm ssv_tests make integration-test
#Build
.PHONY: build
build:
CGO_ENABLED=1 go build -o ./bin/ssvnode -ldflags "-X main.Version=`git describe --tags $(git rev-list --tags --max-count=1)`" ./cmd/ssvnode/
.PHONY: start-node
start-node:
@echo "Build ${BUILD_PATH}"
@echo "Build ${CONFIG_PATH}"
@echo "Build ${CONFIG_PATH2}"
@echo "Command ${NODE_COMMAND}"
ifdef DEBUG_PORT
@echo "Running node-${NODE_ID} in debug mode"
@dlv --continue --accept-multiclient --headless --listen=:${DEBUG_PORT} --api-version=2 exec \
${BUILD_PATH} start-node -- ${NODE_COMMAND}
else
@echo "Running node on address: ${HOST_ADDRESS})"
@${BUILD_PATH} start-node ${NODE_COMMAND}
endif
.PHONY: docker
docker:
@echo "node ${NODES_ID}"
@docker rm -f ssv_node && docker build -t ssv_node . && docker run -d --env-file .env --restart unless-stopped --name=ssv_node -p 13000:13000 -p 12000:12000/udp -it ssv_node make BUILD_PATH=/go/bin/ssvnode start-node && docker logs ssv_node --follow
.PHONY: docker-image
docker-image:
@echo "node ${NODES_ID}"
@sudo docker rm -f ssv_node && docker run -d --env-file .env --restart unless-stopped --name=ssv_node -p 13000:13000 -p 12000:12000/udp 'bloxstaking/ssv-node:latest' make BUILD_PATH=/go/bin/ssvnode start-node
NODES=ssv-node-1 ssv-node-2 ssv-node-3 ssv-node-4
.PHONY: docker-all
docker-all:
@echo "nodes $(NODES)"
@docker-compose up --build $(NODES)
NODES=ssv-node-1 ssv-node-2 ssv-node-3 ssv-node-4
.PHONY: docker-local
docker-local:
@echo "nodes $(NODES)"
@docker-compose -f docker-compose-local.yaml up --build $(NODES)
DEBUG_NODES=ssv-node-1-dev ssv-node-2-dev ssv-node-3-dev ssv-node-4-dev
.PHONY: docker-debug
docker-debug:
@echo $(DEBUG_NODES)
@docker-compose up --build $(DEBUG_NODES)
.PHONY: stop
stop:
@docker-compose down
.PHONY: start-boot-node
start-boot-node:
@echo "Running start-boot-node"
${BUILD_PATH} start-boot-node ${BOOTNODE_COMMAND}
MONITOR_NODES=prometheus grafana
.PHONY: docker-monitor
docker-monitor:
@echo $(MONITOR_NODES)
@docker-compose up --build $(MONITOR_NODES)
.PHONY: mock
mock:
go generate ./...
.PHONY: mockgen-install
mockgen-install:
go install github.com/golang/mock/mockgen@v1.6.0
@which mockgen || echo "Error: ensure `go env GOPATH` is added to PATH"
.PHONY: format
format:
# both format commands must ignore generated files which are named *mock* or enr_fork_id_encoding.go
# the argument to gopls format can be a list of files
find . -name "*.go" ! -path '*mock*' ! -name 'enr_fork_id_encoding.go' -type f -print0 | xargs -0 -P 1 sh -c 'gopls -v format -w $0'
# the argument to gopls imports must be a single file so this entire command takes a few mintues to run
find . -name "*.go" ! -path '*mock*' ! -name 'enr_fork_id_encoding.go' -type f -print0 | xargs -0 -P 10 -I{} sh -c 'gopls -v imports -w "{}"'