-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (78 loc) · 2.56 KB
/
Makefile
File metadata and controls
105 lines (78 loc) · 2.56 KB
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
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
APPNAME := example
# do not override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
# Update the ldflags with the app, client & server names
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(APPNAME) \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(APPNAME)d \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
BUILD_FLAGS := -ldflags '$(ldflags)'
##############
### Test ###
##############
test-unit:
@echo Running unit tests...
@go test -mod=readonly -v -timeout 30m ./...
test-race:
@echo Running unit tests with race condition reporting...
@go test -mod=readonly -v -race -timeout 30m ./...
test-cover:
@echo Running unit tests and creating coverage report...
@go test -mod=readonly -v -timeout 30m -coverprofile=$(COVER_FILE) -covermode=atomic ./...
@go tool cover -html=$(COVER_FILE) -o $(COVER_HTML_FILE)
@rm $(COVER_FILE)
bench:
@echo Running unit tests with benchmarking...
@go test -mod=readonly -v -timeout 30m -bench=. ./...
test: govet govulncheck test-unit
.PHONY: test test-unit test-race test-cover bench
#################
### Install ###
#################
all: install
install:
@echo "--> ensure dependencies have not been modified"
@go mod verify
@echo "--> installing $(APPNAME)d"
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/$(APPNAME)d
.PHONY: all install
##################
### Protobuf ###
##################
# Use this target if you do not want to use Ignite for generating proto files
proto-deps:
@echo "Installing proto deps"
@echo "Proto deps present, run 'go tool' to see them"
proto-gen:
@echo "Generating protobuf files..."
@ignite generate proto-go --yes
.PHONY: proto-gen
#################
### Linting ###
#################
lint:
@echo "--> Running linter"
@go tool github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --timeout 15m
lint-fix:
@echo "--> Running linter and fixing issues"
@go tool github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --fix --timeout 15m
.PHONY: lint lint-fix
###################
### Development ###
###################
govet:
@echo Running go vet...
@go vet ./...
govulncheck:
@echo Running govulncheck...
@go tool golang.org/x/vuln/cmd/govulncheck@latest
@govulncheck ./...
.PHONY: govet govulncheck