-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(templates): scaffold makefile (#4362)
* feat(templates): scaffold makefile * updates * Update ignite/templates/app/files/Makefile.plush Co-authored-by: Danilo Pantani <[email protected]> * updates --------- Co-authored-by: Danilo Pantani <[email protected]>
- Loading branch information
1 parent
62726ab
commit 5c05d12
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
COMMIT := $(shell git log -1 --format='%H') | ||
APPNAME := <%= AppName %> | ||
|
||
# don't override user values | ||
ifeq (,$(VERSION)) | ||
VERSION := $(shell git describe --exact-match 2>/dev/null) | ||
# if VERSION is empty, then populate it with branch's 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 proto-image if you do not want to use Ignite for generating proto files | ||
protoVer=0.15.1 | ||
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) | ||
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) | ||
|
||
proto-gen: | ||
@echo "Generating protobuf files..." | ||
@ignite generate proto-go --yes | ||
|
||
.PHONY: proto-gen | ||
|
||
################# | ||
### Linting ### | ||
################# | ||
|
||
golangci_lint_cmd=golangci-lint | ||
golangci_version=v1.61.0 | ||
|
||
lint: | ||
@echo "--> Running linter" | ||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) | ||
@$(golangci_lint_cmd) run ./... --timeout 15m | ||
|
||
lint-fix: | ||
@echo "--> Running linter and fixing issues" | ||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) | ||
@$(golangci_lint_cmd) run ./... --fix --timeout 15m | ||
|
||
.PHONY: lint lint-fix | ||
|
||
################### | ||
### Development ### | ||
################### | ||
|
||
govet: | ||
@echo Running go vet... | ||
@go vet ./... | ||
|
||
govulncheck: | ||
@echo Running govulncheck... | ||
@go install golang.org/x/vuln/cmd/govulncheck@latest | ||
@govulncheck ./... | ||
|
||
.PHONY: govet govulncheck |