forked from celestiaorg/celestia-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
126 lines (104 loc) · 3.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
#!/usr/bin/make -f
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
IMAGE := ghcr.io/tendermint/docker-build-proto:latest
DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspace $(IMAGE)
PROJECTNAME=$(shell basename "$(PWD)")
# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \
-X github.com/cosmos/cosmos-sdk/version.AppName=celestia-appd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
ldflags += $(LDFLAGS)
BUILD_FLAGS := -ldflags '$(ldflags)'
## 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
## build: Build the celestia-appd binary into the ./build directory.
build: mod
@go install github.com/gobuffalo/packr/v2/packr2@latest
@cd ./cmd/celestia-appd && packr2
@mkdir -p build/
@go build $(BUILD_FLAGS) -o build/ ./cmd/celestia-appd
@packr2 clean
@go mod tidy -compat=1.18
.PHONY: build
## install: Build and install the celestia-appd binary into the $GOPATH/bin directory.
install: go.sum
@echo "--> Installing celestia-appd"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/celestia-appd
.PHONY: install
## mod: Update go.mod.
mod:
@echo "--> Updating go.mod"
@go mod tidy -compat=1.18
.PHONY: mod
## mod-verify: Verify dependencies have expected content.
mod-verify: mod
@echo "--> Verifying dependencies have expected content"
GO111MODULE=on go mod verify
.PHONY: mod-verify
## proto-gen: Generate protobuf files. Requires docker.
proto-gen:
@echo "--> Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen:v0.7 sh ./scripts/protocgen.sh
.PHONY: proto-gen
## proto-lint: Lint protobuf files. Requires docker.
proto-lint:
@echo "--> Linting Protobuf files"
@$(DOCKER_BUF) lint --error-format=json
.PHONY: proto-lint
## proto-format: Format protobuf files. Requires docker.
proto-format:
@echo "--> Formatting Protobuf files"
@$(DOCKER_PROTO_BUILDER) find . -name '*.proto' -path "./proto/*" -exec clang-format -i {} \;
.PHONY: proto-format
## build-docker: Build the celestia-appd docker image. Requires docker.
build-docker:
@echo "--> Building Docker image"
$(DOCKER) build -t celestiaorg/celestia-app -f docker/Dockerfile .
.PHONY: build-docker
## lint: Run linters golangci-lint and markdownlint.
lint:
@echo "--> Running golangci-lint"
@golangci-lint run
@echo "--> Running markdownlint"
@markdownlint --config .markdownlint.yaml '**/*.md'
.PHONY: lint
## fmt: Format files per linters golangci-lint and markdownlint.
fmt:
@echo "--> Running golangci-lint --fix"
@golangci-lint run --fix
@echo "--> Running markdownlint --fix"
@markdownlint --fix --quiet --config .markdownlint.yaml .
.PHONY: fmt
## test: Run unit tests.
test:
@echo "--> Running unit tests"
@go test -mod=readonly ./...
.PHONY: test
## test-short: Run unit tests in short mode.
test-short:
@echo "--> Running tests in short mode"
@go test -mod=readonly ./... -short
.PHONY: test-short
## test-race: Run unit tests in race mode.
test-race:
@echo "--> Running tests in race mode"
@VERSION=$(VERSION) go test -mod=readonly -race -short ./...
.PHONY: test-race
## test-bench: Run unit tests in bench mode.
test-bench:
@echo "--> Running tests in bench mode"
@go test -mod=readonly -bench=. ./...
.PHONY: test-bench
## test-cover: Generate test coverage.txt
test-cover:
@echo "--> Generating coverage.txt"
@export VERSION=$(VERSION); bash -x scripts/test_cover.sh
.PHONY: test-cover