forked from coinbase/chainstorage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
135 lines (111 loc) · 2.84 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
TARGET ?= ...
TEST_FILTER ?= .
ifeq ($(TEST_FILTER),.)
TEST_INTEGRATION_FILTER=TestIntegration
else
TEST_INTEGRATION_FILTER=$(TEST_FILTER)
endif
SRCS=$(shell find . -name '*.go' -type f | grep -v -e ./protos -e /mocks -e '^./config/config.go')
.EXPORT_ALL_VARIABLES:
CHAINSTORAGE_CONFIG ?= ethereum-mainnet
GO111MODULE ?= on
ifeq ($(CI),)
define docker_compose_up
docker-compose -f docker-compose-testing.yml up -d --force-recreate
sleep 10
endef
define docker_compose_down
docker-compose -f docker-compose-testing.yml down
endef
else
define docker_compose_up
endef
define docker_compose_down
endef
endif
.PHONY: build
build: config codegen fmt bin
@echo "--- build"
.PHONY: bootstrap
bootstrap:
@echo "--- bootstrap"
scripts/bootstrap.sh
.PHONY: validate
build-validate: proto
@echo "--- build-validate"
git add -N . && git diff --exit-code
.PHONY: bin
bin:
@echo "--- bin"
mkdir -p bin
go build -o bin ./$(TARGET)
.PHONY: docker-build
docker-build:
@echo "--- docker-build"
docker build -t coinbase/chainstorage .
.PHONY: validate-configs
validate-configs:
@echo "--- validate-config"
TEST_TYPE=unit go test ./internal/config -run=TestValidateConfigs$
.PHONY: test
test: fmt lint
@echo "--- test"
TEST_TYPE=unit go test ./$(TARGET) -run=$(TEST_FILTER)
.PHONY: lint
lint:
@echo "--- lint"
go vet -printfuncs=wrapf,statusf,warnf,infof,debugf,failf,equalf,containsf,fprintf,sprintf ./...
errcheck -ignoretests -ignoregenerated ./...
ineffassign ./...
.PHONY: integration
integration:
@echo "--- integration"
$(call docker_compose_up)
TEST_TYPE=integration go test ./$(TARGET) -v -p=1 -parallel=1 -timeout=15m -failfast -run=$(TEST_INTEGRATION_FILTER)
$(call docker_compose_down)
.PHONY: functional
functional:
@echo "--- functional"
$(call docker_compose_up)
TEST_TYPE=functional go test ./$(TARGET) -v -p=1 -parallel=1 -timeout=45m -failfast -run=$(TEST_INTEGRATION_FILTER)
$(call docker_compose_down)
.PHONY: benchmark
benchmark:
@echo "--- benchmark"
$(call docker_compose_up)
go test -v ./internal/blockchain/integration_test -tags=integration -run=^_ -bench=$(TEST_FILTER) -benchtime=200x
$(call docker_compose_down)
.PHONY: proto
proto:
@echo "--- proto"
./scripts/protogen.sh
.PHONY: codegen
codegen: proto
@echo "--- codegen"
./scripts/mockgen.sh
.PHONY: config
config:
@echo "--- config"
go run ./tools/config_gen ./config_templates/config .
.PHONY: fmt
fmt:
@echo "--- fmt"
@goimports -l -w -local github.com/coinbase/chainstorage $(SRCS)
.PHONY: server
server:
go run ./cmd/server
.PHONY: cron
cron:
go run ./cmd/cron
.PHONY: api
api:
go run ./cmd/api
.PHONY: worker
worker:
go run ./cmd/worker
.PHONY: localstack
localstack:
docker-compose -f docker-compose-local.yml down && docker-compose -f docker-compose-local.yml up
.PHONY: docker-run
docker-run:
docker run --rm --network host --name chainstorage coinbase/chainstorage