forked from 0xsequence/ethkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (103 loc) · 3.44 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
SHELL = bash -o pipefail
TEST_FLAGS ?= -v
#MOD_VENDOR ?= -mod=vendor
GOMODULES ?= on
GITTAG ?= $(shell git describe --exact-match --tags HEAD 2>/dev/null || :)
GITBRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || :)
LONGVERSION ?= $(shell git describe --tags --long --abbrev=8 --always HEAD)$(echo -$GITBRANCH | tr / - | grep -v '\-master' || :)
VERSION ?= $(if $(GITTAG),$(GITTAG),$(LONGVERSION))
GITCOMMIT ?= $(shell git log -1 --date=iso --pretty=format:%H)
GITCOMMITDATE ?= $(shell git log -1 --date=iso --pretty=format:%cd)
all:
@echo "***********************************"
@echo "** ethkit build **"
@echo "***********************************"
@echo "make <cmd>"
@echo ""
@echo "commands:"
@echo ""
@echo " + Development:"
@echo " - build"
@echo " - test"
@echo ""
@echo ""
@echo " + Dep management:"
@echo " - dep-upgrade-all"
@echo ""
build: build-pkgs build-cli
build-pkgs:
go build ./...
build-cli:
@GOBIN=$$PWD/bin $(MAKE) install
clean:
rm -rf ./bin
install:
GOGC=off GO111MODULE=$(GOMODULES) \
go install -v \
$(MOD_VENDOR) \
-ldflags='-X "main.VERSION=$(VERSION)" -X "main.GITBRANCH=$(GITBRANCH)" -X "main.GITCOMMIT=$(GITCOMMIT)" -X "main.GITCOMMITDATE=$(GITCOMMITDATE)"' \
./cmd/ethkit
#
# Testing
#
# Run baseline tests
test: check-testchain-running go-test
# Run testchain and tests concurrently
test-concurrently:
cd ./tools/testchain && yarn concurrently -k --success first 'yarn start:hardhat' 'cd ../.. && make go-test'
# Run tests with reorgme
test-with-reorgme: check-reorgme-running
REORGME=true $(MAKE) go-test
# Go test short-hand, and skip testing go-ethereum
go-test: test-clean
GOGC=off go test $(TEST_FLAGS) $(MOD_VENDOR) -race -run=$(TEST) `go list ./... | grep -v go-ethereum`
# Go test short-hand, including go-ethereum
go-test-all: test-clean
GOGC=off go test $(TEST_FLAGS) $(MOD_VENDOR) -run=$(TEST) ./...
test-clean:
GOGC=off go clean -testcache
.PHONY: tools
tools:
cd ./ethtest/testchain && yarn install
cd ./ethtest/reorgme && yarn install
bootstrap:
cd ./ethtest/testchain && yarn install
#
# Testchain
#
start-testchain:
cd ./ethtest/testchain && yarn start:hardhat
start-testchain-verbose:
cd ./ethtest/testchain && yarn start:hardhat:verbose
start-testchain-geth:
cd ./ethtest/testchain && yarn start:geth
start-testchain-geth-verbose:
cd ./ethtest/testchain && yarn start:geth:verbose
check-testchain-running:
@curl http://localhost:8545 -H"Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' --write-out '%{http_code}' --silent --output /dev/null | grep 200 > /dev/null \
|| { echo "*****"; echo "Oops! testchain is not running. Please run 'make start-testchain' in another terminal or use 'test-concurrently'."; echo "*****"; exit 1; }
#
# Reorgme
#
start-reorgme:
cd ./ethtest/reorgme && yarn start:server
start-reorgme-detached:
cd ./ethtest/reorgme && yarn start:server:detached
stop-reorgme-detached:
cd ./ethtest/reorgme && yarn start:stop:detached
reorgme-logs:
cd ./ethtest/reorgme && yarn chain:logs
check-reorgme-running:
cd ./ethtest/reorgme && bash isRunning.sh
#
# Dep management
#
dep-upgrade-all:
GO111MODULE=on go get -u ./...
# .PHONY: vendor
# vendor:
# @export GO111MODULE=on && \
# go mod tidy && \
# rm -rf ./vendor && \
# go mod vendor && \
# go run github.com/goware/modvendor -copy="**/*.c **/*.h **/*.s **/*.proto"