forked from celestiaorg/celestia-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (131 loc) · 4.78 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
SHELL=/usr/bin/env bash
PROJECTNAME=$(shell basename "$(PWD)")
LDFLAGS="-X 'main.buildTime=$(shell date)' -X 'main.lastCommit=$(shell git rev-parse HEAD)' -X 'main.semanticVersion=$(shell git describe --tags --dirty=-dev)'"
ifeq (${PREFIX},)
PREFIX := /usr/local
endif
## help: Get more info on make commands.
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
.PHONY: help
## install: Install git-hooks from .githooks directory.
install-hooks:
@echo "--> Installing git hooks"
@git config core.hooksPath .githooks
.PHONY: init-hooks
## build: Build celestia-node binary.
build:
@echo "--> Building Celestia"
@go build -o build/ -ldflags ${LDFLAGS} ./cmd/celestia
.PHONY: build
## clean: Clean up celestia-node binary.
clean:
@echo "--> Cleaning up ./build"
@rm -rf build/*
## cover: generate to code coverage report.
cover:
@echo "--> Generating Code Coverage"
@go install github.com/ory/go-acc@latest
@go-acc -o coverage.txt `go list ./... | grep -v nodebuilder/tests` -- -v
.PHONY: cover
## deps: install dependencies.
deps:
@echo "--> Installing Dependencies"
@go mod download
.PHONY: deps
## install: Build and install the celestia-node binary into the $PREFIX (/usr/local/ by default) directory.
install: build
@echo "--> Installing Celestia"
@install -v ./build/* -t ${PREFIX}/bin/
.PHONY: install
## go-install: Build and install the celestia-node binary into the GOBIN directory.
go-install:
@echo "--> Installing Celestia"
@go install -ldflags ${LDFLAGS} ./cmd/celestia
.PHONY: go-install
## shed: Build cel-shed binary.
cel-shed:
@echo "--> Building cel-shed"
@go build ./cmd/cel-shed
.PHONY: cel-shed
## install-shed: Build and install the cel-shed binary into the GOBIN directory.
install-shed:
@echo "--> Installing cel-shed"
@go install ./cmd/cel-shed
.PHONY: install-shed
## key: Build cel-key binary.
cel-key:
@echo "--> Building cel-key"
@go build ./cmd/cel-key
.PHONY: cel-key
## install-key: Build and install the cel-key binary into the GOBIN directory.
install-key:
@echo "--> Installing cel-key"
@go install ./cmd/cel-key
.PHONY: install-key
## fmt: Formats only *.go (excluding *.pb.go *pb_test.go). Runs `gofmt & goimports` internally.
fmt:
@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 -local github.com/celestiaorg
@go mod tidy -compat=1.17
@cfmt -w -m=100 ./...
@markdownlint --fix --quiet --config .markdownlint.yaml .
.PHONY: fmt
## lint: Linting *.go files using golangci-lint. Look for .golangci.yml for the list of linters.
lint:
@echo "--> Running linter"
@golangci-lint run
@markdownlint --config .markdownlint.yaml '**/*.md'
.PHONY: lint
## test-unit: Running unit tests
test-unit:
@echo "--> Running unit tests"
@go test `go list ./... | grep -v nodebuilder/tests` -covermode=atomic -coverprofile=coverage.out
.PHONY: test-unit
## test-unit-race: Running unit tests with data race detector
test-unit-race:
@echo "--> Running unit tests with data race detector"
@go test -race `go list ./... | grep -v nodebuilder/tests`
.PHONY: test-unit-race
## test-swamp: Running swamp tests located in nodebuilder/tests
test-swamp:
@echo "--> Running swamp tests"
@go test ./nodebuilder/tests
.PHONY: test-swamp
## test-swamp: Running swamp tests with data race detector located in node/tests
test-swamp-race:
@echo "--> Running swamp tests with data race detector"
@go test -race ./nodebuilder/tests
.PHONY: test-swamp-race
## test-all: Running both unit and swamp tests
test:
@echo "--> Running all tests without data race detector"
@go test ./...
@echo "--> Running all tests with data race detector"
@go test -race ./...
.PHONY: test
## benchmark: Running all benchmarks
benchmark:
@echo "--> Running benchmarks"
@go test -run="none" -bench=. -benchtime=100x -benchmem ./...
.PHONY: benchmark
PB_PKGS=$(shell find . -name 'pb' -type d)
PB_CORE=$(shell go list -f {{.Dir}} -m github.com/tendermint/tendermint)
PB_GOGO=$(shell go list -f {{.Dir}} -m github.com/gogo/protobuf)
PB_CELESTIA_APP=$(shell go list -f {{.Dir}} -m github.com/celestiaorg/celestia-app)
## pb-gen: Generate protobuf code for all /pb/*.proto files in the project.
pb-gen:
@echo '--> Generating protobuf'
@for dir in $(PB_PKGS); \
do for file in `find $$dir -type f -name "*.proto"`; \
do protoc -I=. -I=${PB_CORE}/proto/ -I=${PB_GOGO} -I=${PB_CELESTIA_APP}/proto --gogofaster_out=paths=source_relative:. $$file; \
echo '-->' $$file; \
done; \
done;
.PHONY: pb-gen
## openrpc-gen: Generate OpenRPC spec for Celestia-Node's RPC api
openrpc-gen:
@echo "--> Generating OpenRPC spec"
@go run ./cmd/docgen fraud header state share das
.PHONY: openrpc-gen