forked from cosmos/iavl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (104 loc) · 3.67 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
GOTOOLS := github.com/golangci/golangci-lint/cmd/golangci-lint
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf
DOCKER := $(shell which docker)
HTTPS_GIT := https://github.com/cosmos/iavl.git
PDFFLAGS := -pdf --nodefraction=0.1
CMDFLAGS := -ldflags -X TENDERMINT_IAVL_COLORS_ON=on
LDFLAGS := -ldflags "-X github.com/cosmos/iavl.Version=$(VERSION) -X github.com/cosmos/iavl.Commit=$(COMMIT) -X github.com/cosmos/iavl.Branch=$(BRANCH)"
all: lint test install
install:
ifeq ($(COLORS_ON),)
go install ./cmd/iaviewer
go install ./cmd/iavlserver
else
go install $(CMDFLAGS) ./cmd/iaviewer
go install $(CMDFLAGS) ./cmd/iavlserver
endif
.PHONY: install
test:
@echo "--> Running go test"
@go test ./... $(LDFLAGS) -v --race
.PHONY: test
tools:
go get -v $(GOTOOLS)
.PHONY: tools
format:
find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w
.PHONY: format
# look into .golangci.yml for enabling / disabling linters
lint:
@echo "--> Running linter"
@golangci-lint run
@go mod verify
.PHONY: lint
# bench is the basic tests that shouldn't crash an aws instance
bench:
cd benchmarks && \
go test $(LDFLAGS) -bench=RandomBytes . && \
go test $(LDFLAGS) -bench=Small . && \
go test $(LDFLAGS) -bench=Medium . && \
go test $(LDFLAGS) -bench=BenchmarkMemKeySizes .
.PHONY: bench
# fullbench is extra tests needing lots of memory and to run locally
fullbench:
cd benchmarks && \
go test $(LDFLAGS) -bench=RandomBytes . && \
go test $(LDFLAGS) -bench=Small . && \
go test $(LDFLAGS) -bench=Medium . && \
go test $(LDFLAGS) -timeout=30m -bench=Large . && \
go test $(LDFLAGS) -bench=Mem . && \
go test $(LDFLAGS) -timeout=60m -bench=LevelDB .
.PHONY: fullbench
# note that this just profiles the in-memory version, not persistence
profile:
cd benchmarks && \
go test $(LDFLAGS) -bench=Mem -cpuprofile=cpu.out -memprofile=mem.out . && \
go tool pprof ${PDFFLAGS} benchmarks.test cpu.out > cpu.pdf && \
go tool pprof --alloc_space ${PDFFLAGS} benchmarks.test mem.out > mem_space.pdf && \
go tool pprof --alloc_objects ${PDFFLAGS} benchmarks.test mem.out > mem_obj.pdf
.PHONY: profile
explorecpu:
cd benchmarks && \
go tool pprof benchmarks.test cpu.out
.PHONY: explorecpu
exploremem:
cd benchmarks && \
go tool pprof --alloc_objects benchmarks.test mem.out
.PHONY: exploremem
delve:
dlv test ./benchmarks -- -test.bench=.
.PHONY: delve
all: tools
.PHONY: all
tools: protobuf
.PHONY: tools
check: check_tools
.PHONY: check
check_tools:
@# https://stackoverflow.com/a/25668869
@echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
.PHONY: check_tools
tools-clean:
rm -f $(CERTSTRAP) $(PROTOBUF) $(GOX) $(GOODMAN)
rm -rf /usr/local/include/google/protobuf
rm -f /usr/local/bin/protoc
.PHONY: tooks-clean
###
# Non Go tools
###
.PHONY: lint test tools install delve exploremem explorecpu profile fullbench bench proto-gen proto-lint proto-check-breaking
proto-lint:
@$(DOCKER_BUF) check lint --error-format=json
.PHONY: proto-lint
proto-check-breaking:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master
.PHONY: proto-check-breaking
proto-gen:
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen:master sh scripts/protocgen.sh
.PHONY: proto-gen-d