1+ BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
2+ COMMIT := $(shell git log -1 --format='% H')
3+ APPNAME := junction
4+
5+ # do not override user values
6+ ifeq (,$(VERSION ) )
7+ VERSION := $(shell git describe --exact-match 2>/dev/null)
8+ # if VERSION is empty, then populate it with branch name and raw commit hash
9+ ifeq (,$(VERSION))
10+ VERSION := $(BRANCH ) -$(COMMIT )
11+ endif
12+ endif
13+
14+ # Update the ldflags with the app, client & server names
15+ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(APPNAME ) \
16+ -X github.com/cosmos/cosmos-sdk/version.AppName=$(APPNAME ) d \
17+ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION ) \
18+ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT )
19+
20+ BUILD_FLAGS := -ldflags '$(ldflags ) '
21+
22+ # #############
23+ # ## Test ###
24+ # #############
25+
26+ test-unit :
27+ @echo Running unit tests...
28+ @go test -mod=readonly -v -timeout 30m ./...
29+
30+ test-race :
31+ @echo Running unit tests with race condition reporting...
32+ @go test -mod=readonly -v -race -timeout 30m ./...
33+
34+ test-cover :
35+ @echo Running unit tests and creating coverage report...
36+ @go test -mod=readonly -v -timeout 30m -coverprofile=$(COVER_FILE ) -covermode=atomic ./...
37+ @go tool cover -html=$(COVER_FILE ) -o $(COVER_HTML_FILE )
38+ @rm $(COVER_FILE )
39+
40+ bench :
41+ @echo Running unit tests with benchmarking...
42+ @go test -mod=readonly -v -timeout 30m -bench=. ./...
43+
44+ test : govet govulncheck test-unit
45+
46+ .PHONY : test test-unit test-race test-cover bench
47+
48+ # ################
49+ # ## Install ###
50+ # ################
51+
52+ all : install
53+
54+ install :
55+ @echo " --> ensure dependencies have not been modified"
56+ @go mod verify
57+ @echo " --> installing $( APPNAME) d"
58+ @go install $(BUILD_FLAGS ) -mod=readonly ./cmd/$(APPNAME ) d
59+
60+ .PHONY : all install
61+
62+ # #################
63+ # ## Protobuf ###
64+ # #################
65+
66+ # Use this target if you do not want to use Ignite for generating proto files
67+
68+ proto-deps :
69+ @echo " Installing proto deps"
70+ @echo " Proto deps present, run 'go tool' to see them"
71+
72+ proto-gen :
73+ @echo " Generating protobuf files..."
74+ @ignite generate proto-go --yes
75+
76+ .PHONY : proto-gen
77+
78+ # ################
79+ # ## Linting ###
80+ # ################
81+
82+ lint :
83+ @echo " --> Running linter"
84+ @go tool github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --timeout 15m
85+
86+ lint-fix :
87+ @echo " --> Running linter and fixing issues"
88+ @go tool github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --fix --timeout 15m
89+
90+ .PHONY : lint lint-fix
91+
92+ # ##################
93+ # ## Development ###
94+ # ##################
95+
96+ govet :
97+ @echo Running go vet...
98+ @go vet ./...
99+
100+ govulncheck :
101+ @echo Running govulncheck...
102+ @go tool golang.org/x/vuln/cmd/govulncheck@latest
103+ @govulncheck ./...
104+
105+ .PHONY : govet govulncheck
0 commit comments