From e1a8ede981eb3e352fe89cf91ead1f3a4294ba1c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 1 Oct 2024 10:42:29 +0200 Subject: [PATCH] feat(templates): scaffold makefile (#4362) * feat(templates): scaffold makefile * updates * Update ignite/templates/app/files/Makefile.plush Co-authored-by: Danilo Pantani * updates --------- Co-authored-by: Danilo Pantani (cherry picked from commit 5c05d12d0c092514b61ad3426912763a9473dff0) --- changelog.md | 19 ++++ ignite/templates/app/files/Makefile.plush | 109 ++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 ignite/templates/app/files/Makefile.plush diff --git a/changelog.md b/changelog.md index a6b5808b4e..1b31a0ed68 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,25 @@ ## Unreleased +### Features + +- [#3707](https://github.com/ignite/cli/pull/3707) and [#4094](https://github.com/ignite/cli/pull/4094) Add collections support. +- [#3977](https://github.com/ignite/cli/pull/3977) Add `chain lint` command to lint the chain's codebase using `golangci-lint` +- [#3770](https://github.com/ignite/cli/pull/3770) Add `scaffold configs` and `scaffold params` commands +- [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run +- [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config +- [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg +- [#4071](https://github.com/ignite/cli/pull/4071) Support custom proto path +- [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite +- [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config +- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation +- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically +- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands +- [#4300](https://github.com/ignite/cli/pull/4300) Only panics the module in the most top function level +- [#4327](https://github.com/ignite/cli/pull/4327) Use the TxConfig from simState instead create a new one +- [#4326](https://github.com/ignite/cli/pull/4326) fAdd `buf.build` version to `ignite version` command +- [#4362](https://github.com/ignite/cli/pull/4362) Scaffold `Makefile` + ### Changes - [#4376](https://github.com/ignite/cli/pull/4376) Set different chain-id for in place testnet diff --git a/ignite/templates/app/files/Makefile.plush b/ignite/templates/app/files/Makefile.plush new file mode 100644 index 0000000000..54e9a72e80 --- /dev/null +++ b/ignite/templates/app/files/Makefile.plush @@ -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 \ No newline at end of file