-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring makefile to separate lint, proto and test out of it.
- Loading branch information
1 parent
66d5733
commit c4af91f
Showing
7 changed files
with
188 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
|
||
include scripts/makefiles/build.mk | ||
include scripts/makefiles/docker.mk | ||
include scripts/makefiles/lint.mk | ||
include scripts/makefiles/proto.mk | ||
include scripts/makefiles/test.mk | ||
include tests/e2e/Makefile | ||
|
||
.DEFAULT_GOAL := help | ||
help: | ||
|
@@ -117,30 +121,47 @@ ifeq (,$(findstring nostrip,$(QUASAR_BUILD_OPTIONS))) | |
endif | ||
|
||
############################################################################### | ||
### Proto & Mock Generation ### | ||
### Build & Install ### | ||
############################################################################### | ||
|
||
proto-all: proto-format proto-gen | ||
BUF_VERSION=1.26.1 | ||
BUILDER_VERSION=0.13.5 | ||
proto-gen: | ||
@echo "Generating Protobuf files" | ||
@sh ./scripts/protocgen.sh | ||
update-deps: | ||
@go mod tidy; | ||
|
||
build: build-check-version go.sum | ||
# back up before build | ||
@cp go.mod go.mod.backup | ||
@cp go.sum go.sum.backup | ||
@go mod tidy | ||
|
||
mkdir -p $(BUILDDIR)/ | ||
GOWORK=off go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ $(GO_MODULE)/cmd/quasarnoded | ||
|
||
proto-gen-1: | ||
@echo "🤖 Generating code from protobuf..." | ||
@echo "PWD is $(PWD)" | ||
# clean up before install | ||
@mv go.mod.backup go.mod | ||
@mv go.sum.backup go.sum | ||
@rm -f go.mod.bak | ||
@go mod tidy | ||
|
||
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \ | ||
ghcr.io/cosmos/proto-builder:$(BUILDER_VERSION) sh ./scripts/protocgen.sh | ||
@echo "✅ Completed code generation!" | ||
install: build-check-version go.sum | ||
# back up before build | ||
@cp go.mod go.mod.backup | ||
@cp go.sum go.sum.backup | ||
@go mod tidy | ||
|
||
proto-doc: | ||
@echo "Generating Protoc docs" | ||
@sh ./scripts/generate-docs.sh | ||
GOWORK=off go install -mod=readonly $(BUILD_FLAGS) $(GO_MODULE)/cmd/quasarnoded | ||
|
||
.PHONY: proto-gen proto-doc | ||
# clean up before install | ||
@mv go.mod.backup go.mod | ||
@mv go.sum.backup go.sum | ||
@rm -f go.mod.bak | ||
@go mod tidy | ||
|
||
############################################################################### | ||
### Go Mock ### | ||
############################################################################### | ||
|
||
# todo : need ideas on external libraries | ||
# example : mockgen -source=/path/to/go/pkg/mod/github.com/cosmos/ibc-go/[email protected]/modules/core/05-port/types/module.go -destination=/path/to/quasar/mock/ics4_wrapper_mocks.go -package=mock -mock_names=MockICS4Wrapper | ||
mocks: $(MOCKSDIR)/ | ||
mockgen -package=mock -destination=$(MOCKSDIR)/ibc_channel_mocks.go $(GOMOD)/x/qoracle/types ChannelKeeper | ||
# mockgen -package=mock -destination=$(MOCKSDIR)/ica_mocks.go $(GOMOD)/x/intergamm/types ICAControllerKeeper | ||
|
@@ -153,48 +174,6 @@ mocks: $(MOCKSDIR)/ | |
$(MOCKSDIR)/: | ||
mkdir -p $(MOCKSDIR)/ | ||
|
||
############################################################################### | ||
### Tests & Simulation ### | ||
############################################################################### | ||
|
||
PACKAGES_UNIT=$(shell go list ./x/epochs/... ./x/qoracle/... ./x/tokenfactory/... | grep -E -v "simapp|e2e" | grep -E -v "x/qoracle/client/cli") | ||
PACKAGES_E2E=$(shell go list ./... | grep '/tests/e2e') | ||
PACKAGES_SIM=$(shell go list ./... | grep '/tests/simulator') | ||
TEST_PACKAGES=./... | ||
|
||
include tests/e2e/Makefile | ||
|
||
test: test-unit test-build | ||
|
||
test-all: check test-race test-cover | ||
|
||
test-unit: | ||
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock norace' $(PACKAGES_UNIT) | ||
|
||
test-race: | ||
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' $(PACKAGES_UNIT) | ||
|
||
test-cover: | ||
@VERSION=$(VERSION) go test -mod=readonly -timeout 30m -coverprofile=coverage.txt -tags='norace' -covermode=atomic $(PACKAGES_UNIT) | ||
|
||
test-sim-suite: | ||
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_SIM) | ||
|
||
test-sim-app: | ||
@VERSION=$(VERSION) go test -mod=readonly -run ^TestFullAppSimulation -v $(PACKAGES_SIM) | ||
|
||
test-sim-determinism: | ||
@VERSION=$(VERSION) go test -mod=readonly -run ^TestAppStateDeterminism -v $(PACKAGES_SIM) | ||
|
||
test-sim-bench: | ||
@VERSION=$(VERSION) go test -benchmem -run ^BenchmarkFullAppSimulation -bench ^BenchmarkFullAppSimulation -cpuprofile cpu.out $(PACKAGES_SIM) | ||
|
||
benchmark: | ||
@go test -mod=readonly -bench=. $(PACKAGES_UNIT) | ||
|
||
lint: | ||
@echo "--> Running linter" | ||
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=10m | ||
|
||
.PHONY: all build-linux install format lint build \ | ||
test test-all test-build test-cover test-unit test-race benchmark |
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
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,47 @@ | ||
############################################################################### | ||
### Linting ### | ||
############################################################################### | ||
lint-help: | ||
@echo "lint subcommands" | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make lint-[command]" | ||
@echo "" | ||
@echo "Available Commands:" | ||
@echo " all Run all linters" | ||
@echo " fix-typo Run codespell to fix typos" | ||
@echo " format Run linters with auto-fix" | ||
@echo " markdown Run markdown linter with auto-fix" | ||
@echo " mdlint Run markdown linter" | ||
@echo " setup-pre-commit Set pre-commit git hook" | ||
@echo " typo Run codespell to check typos" | ||
lint: lint-help | ||
|
||
lint-all: | ||
@echo "--> Running linter" | ||
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=10m | ||
@docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" | ||
|
||
lint-format: | ||
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --fix | ||
@go run mvdan.cc/gofumpt -l -w x/ app/ ante/ tests/ | ||
@docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --fix | ||
|
||
lint-mdlint: | ||
@echo "--> Running markdown linter" | ||
@docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" | ||
|
||
lint-markdown: | ||
@docker run -v $(PWD):/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.md" --fix | ||
|
||
lint-typo: | ||
@codespell | ||
|
||
lint-fix-typo: | ||
@codespell -w | ||
|
||
lint-setup-pre-commit: | ||
@cp .git/hooks/pre-commit .git/hooks/pre-commit.bak 2>/dev/null || true | ||
@echo "Installing pre-commit hook..." | ||
@ln -sf ../../scripts/hooks/pre-commit.sh .git/hooks/pre-commit | ||
@echo "Pre-commit hook installed successfully" |
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,35 @@ | ||
############################################################################### | ||
### Proto & Mock Generation ### | ||
############################################################################### | ||
proto-help: | ||
@echo "proto subcommands" | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make proto-[command]" | ||
@echo "" | ||
@echo "Available Commands:" | ||
@echo " all Run proto-format and proto-gen" | ||
@echo " gen Generate Protobuf files" | ||
@echo " gen-1 Generate Protobuf files (old relic)" | ||
@echo " doc Generate proto docs" | ||
|
||
proto: proto-help | ||
proto-all: proto-gen | ||
|
||
# todo : @AJ needs to address this after removing third_party. Refer this for removal https://github.com/osmosis-labs/osmosis/blob/188abfcd15544ca07d468c0dc0169876ffde6079/scripts/makefiles/proto.mk#L39 | ||
proto-gen: | ||
@echo "Generating Protobuf files" | ||
@sh ./scripts/protocgen.sh | ||
|
||
# todo : @AK need the reason why it was there earlier | ||
proto-gen-1: | ||
@echo "🤖 Generating code from protobuf..." | ||
@echo "PWD is $(PWD)" | ||
|
||
@docker run --rm --volume "$(PWD)":/workspace --workdir /workspace \ | ||
ghcr.io/cosmos/proto-builder:$(BUILDER_VERSION) sh ./scripts/protocgen.sh | ||
@echo "✅ Completed code generation!" | ||
|
||
proto-doc: | ||
@echo "Generating Protoc docs" | ||
@sh ./scripts/generate-docs.sh |
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,53 @@ | ||
############################################################################### | ||
### Tests ### | ||
############################################################################### | ||
|
||
PACKAGES_UNIT=$(shell go list ./x/epochs/... ./x/qoracle/... ./x/tokenfactory/... ./x/qtransfer/... ./x/qvesting/... ./app/... | grep -E -v "simapp|e2e" | grep -E -v "x/qoracle/client/cli") | ||
PACKAGES_E2E=$(shell go list ./... | grep '/tests/e2e') | ||
PACKAGES_SIM=$(shell go list ./... | grep '/tests/simulator') | ||
TEST_PACKAGES=./... | ||
|
||
test-help: | ||
@echo "test subcommands" | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make test-[command]" | ||
@echo "" | ||
@echo "Available Commands:" | ||
@echo " all Run all tests" | ||
@echo " benchmark Run benchmark tests" | ||
@echo " cover Run coverage tests" | ||
@echo " race Run race tests" | ||
@echo " sim-app Run sim app tests" | ||
@echo " sim-bench Run sim benchmark tests" | ||
@echo " sim-determinism Run sim determinism tests" | ||
@echo " sim-suite Run sim suite tests" | ||
@echo " unit Run unit tests" | ||
|
||
test: test-help | ||
|
||
test-all: test-unit test-race test-sim-app | ||
|
||
test-unit: | ||
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock norace' $(PACKAGES_UNIT) | ||
|
||
test-race: | ||
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' $(PACKAGES_UNIT) | ||
|
||
test-cover: | ||
@VERSION=$(VERSION) go test -mod=readonly -timeout 30m -coverprofile=coverage.txt -tags='norace' -covermode=atomic $(PACKAGES_UNIT) | ||
|
||
test-sim-suite: | ||
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_SIM) | ||
|
||
test-sim-app: | ||
@VERSION=$(VERSION) go test -mod=readonly -run ^TestFullAppSimulation -v $(PACKAGES_SIM) | ||
|
||
test-sim-determinism: | ||
@VERSION=$(VERSION) go test -mod=readonly -run ^TestAppStateDeterminism -v $(PACKAGES_SIM) | ||
|
||
test-sim-bench: | ||
@VERSION=$(VERSION) go test -benchmem -run ^BenchmarkFullAppSimulation -bench ^BenchmarkFullAppSimulation -cpuprofile cpu.out $(PACKAGES_SIM) | ||
|
||
test-benchmark: | ||
@go test -mod=readonly -bench=. $(PACKAGES_UNIT) |
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