From f2a219db56fac192459d92497b3edb5c5daa2348 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 17 Sep 2024 13:29:13 +0200 Subject: [PATCH] feat(templates): scaffold makefile --- ignite/templates/app/files/Makefile.plush | 78 +++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 ignite/templates/app/files/Makefile.plush diff --git a/ignite/templates/app/files/Makefile.plush b/ignite/templates/app/files/Makefile.plush new file mode 100644 index 0000000000..e4d9ddfd75 --- /dev/null +++ b/ignite/templates/app/files/Makefile.plush @@ -0,0 +1,78 @@ +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)' + +################# +### Build ### +################# + +test: + @echo "--> Running tests" + go test -v ./... + +.PHONY: test + +################# +### 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 \ No newline at end of file