From e9a782ee0d4c4b0eea958f88a553498f42d2b4c8 Mon Sep 17 00:00:00 2001 From: Robert Pirtle Date: Wed, 9 Aug 2023 15:29:56 -0700 Subject: [PATCH 1/2] chore: allow override of go binary in Makefile --- Makefile | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 844799dc90..b7e1f7de29 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ ################################################################################ PROJECT_NAME := kava# unique namespace for project +GO_BIN ?= go + GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) GIT_COMMIT := $(shell git rev-parse HEAD) GIT_COMMIT_SHORT := $(shell git rev-parse --short HEAD) @@ -26,8 +28,8 @@ VERSION := $(GIT_COMMIT_SHORT) VERSION_NUMBER := $(VERSION) endif -TENDERMINT_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') -COSMOS_SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::') +TENDERMINT_VERSION := $(shell $(GO_BIN) list -m github.com/tendermint/tendermint | sed 's:.* ::') +COSMOS_SDK_VERSION := $(shell $(GO_BIN) list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::') .PHONY: print-git-info print-git-info: @@ -186,28 +188,28 @@ all: install build: go.sum ifeq ($(OS), Windows_NT) - go build -mod=readonly $(BUILD_FLAGS) -o out/$(shell go env GOOS)/kava.exe ./cmd/kava + $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava.exe ./cmd/kava else - go build -mod=readonly $(BUILD_FLAGS) -o out/$(shell go env GOOS)/kava ./cmd/kava + $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava ./cmd/kava endif build-linux: go.sum LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build install: go.sum - go install -mod=readonly $(BUILD_FLAGS) ./cmd/kava + $(GO_BIN) install -mod=readonly $(BUILD_FLAGS) ./cmd/kava ######################################## ### Tools & dependencies go-mod-cache: go.sum - @echo "--> Download go modules to local cache" - @go mod download + @echo "--> Download $(GO_BIN) modules to local cache" + @$(GO_BIN) mod download PHONY: go-mod-cache go.sum: go.mod @echo "--> Ensuring dependencies have not been modified" - @go mod verify + @$(GO_BIN) mod verify ######################################## ### Linting @@ -216,14 +218,14 @@ go.sum: go.mod # This tool checks local markdown links as well. # Set to exclude riot links as they trigger false positives link-check: - @go get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3 + @$(GO_BIN) get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3 liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*" lint: golangci-lint run find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s - go mod verify + $(GO_BIN) mod verify .PHONY: lint format: @@ -274,40 +276,40 @@ start: # build dependency needed for cli tests test-all: build # basic app tests - @go test ./app -v + @$(GO_BIN) test ./app -v # basic simulation (seed "4" happens to not unbond all validators before reaching 100 blocks) - #@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h + #@$(GO_BIN) test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h # other sim tests - #@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h - #@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h + #@$(GO_BIN) test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h + #@$(GO_BIN) test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h # AppStateDeterminism does not use Seed flag - #@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h + #@$(GO_BIN) test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h # run module tests and short simulations test-basic: test - @go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m + @$(GO_BIN) test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m # other sim tests - @go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m - @go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m + @$(GO_BIN) test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m + @$(GO_BIN) test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m @# AppStateDeterminism does not use Seed flag - @go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m + @$(GO_BIN) test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m # run end-to-end tests (local docker container must be built, see docker-build) test-e2e: docker-build - go test -failfast -count=1 -v ./tests/e2e/... + $(GO_BIN) test -failfast -count=1 -v ./tests/e2e/... test: - @go test $$(go list ./... | grep -v 'contrib' | grep -v 'tests/e2e') + @$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e') # Run cli integration tests -# `-p 4` to use 4 cores, `-tags cli_test` to tell go not to ignore the cli package +# `-p 4` to use 4 cores, `-tags cli_test` to tell $(GO_BIN) not to ignore the cli package # These tests use the `kvd` or `kvcli` binaries in the build dir, or in `$BUILDDIR` if that env var is set. test-cli: build - @go test ./cli_test -tags cli_test -v -p 4 + @$(GO_BIN) test ./cli_test -tags cli_test -v -p 4 # Run tests for migration cli command test-migrate: - @go test -v -count=1 ./migrate/... + @$(GO_BIN) test -v -count=1 ./migrate/... # Kick start lots of sims on an AWS cluster. # This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3 From b07d428f71353463b6fbf1ed19b969d35b2d7139 Mon Sep 17 00:00:00 2001 From: Robert Pirtle Date: Wed, 9 Aug 2023 15:49:00 -0700 Subject: [PATCH 2/2] update build dir make commands with GO_BIN --- build/deps.mk | 9 +++++---- build/proto-deps.mk | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build/deps.mk b/build/deps.mk index 7d10035a27..df02675332 100644 --- a/build/deps.mk +++ b/build/deps.mk @@ -27,10 +27,11 @@ DIRS := $(BUILD_CACHE_DIR) $(BIN_DIR) ################################################################################ ### Tool Versions ### ################################################################################ +GO_BIN ?= go PROTOC_VERSION ?= v21.9 BUF_VERSION ?= v1.9.0 PROTOC_GEN_GOCOSMOS_VERSION ?= v0.3.1 -PROTOC_GEN_GRPC_GATEWAY_VERSION ?= $(shell go list -m github.com/grpc-ecosystem/grpc-gateway| sed 's:.* ::') +PROTOC_GEN_GRPC_GATEWAY_VERSION ?= $(shell $(GO_BIN) list -m github.com/grpc-ecosystem/grpc-gateway| sed 's:.* ::') PROTOC_GEN_DOC_VERSION ?= v1.5.1 SWAGGER_COMBINE_VERSION ?= v1.4.0 @@ -115,7 +116,7 @@ $(PROTOC_GEN_GOCOSMOS_VERSION_FILE): git clone -q https://github.com/regen-network/cosmos-proto.git; \ cd cosmos-proto; \ git checkout -q $(PROTOC_GEN_GOCOSMOS_VERSION); \ - GOBIN=$(ROOT_DIR)/$(BIN_DIR) go install ./protoc-gen-gocosmos + GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-gocosmos @rm -rf $(BUILD_CACHE_DIR)/protoc-gen-gocosmos PROTOC_GEN_GOCOSMOS := $(BIN_DIR)/protoc-gen-gocosmos @@ -138,8 +139,8 @@ $(PROTOC_GEN_GRPC_GATEWAY_VERSION_FILE): git clone -q https://github.com/grpc-ecosystem/grpc-gateway.git; \ cd grpc-gateway; \ git checkout -q $(PROTOC_GEN_GRPC_GATEWAY_VERSION); \ - GOBIN=$(ROOT_DIR)/$(BIN_DIR) go install ./protoc-gen-grpc-gateway; \ - GOBIN=$(ROOT_DIR)/$(BIN_DIR) go install ./protoc-gen-swagger + GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-grpc-gateway; \ + GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-swagger @rm -rf $(BUILD_CACHE_DIR)/protoc-gen-grpc-gateway PROTOC_GEN_GRPC_GATEWAY := $(BIN_DIR)/protoc-gen-grpc-gateway diff --git a/build/proto-deps.mk b/build/proto-deps.mk index 2caae24326..af040e4f5a 100644 --- a/build/proto-deps.mk +++ b/build/proto-deps.mk @@ -1,4 +1,5 @@ RSYNC_BIN ?= rsync +GO_BIN ?= go # # Versioning for google protobuf dependencies (any, http, etc) and @@ -13,12 +14,12 @@ PROTOBUF_ANY_DOWNLOAD_URL = https://raw.githubusercontent.com/protocolbuffers/pr # # Proto dependencies under go.mod # -GOGO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/gogo/protobuf) -TENDERMINT_PATH := $(shell go list -m -f '{{.Dir}}' github.com/tendermint/tendermint) -COSMOS_PROTO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-proto) -COSMOS_SDK_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk) -IBC_GO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v6) -ETHERMINT_PATH := $(shell go list -m -f '{{.Dir}}' github.com/evmos/ethermint) +GOGO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/gogo/protobuf) +TENDERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/tendermint/tendermint) +COSMOS_PROTO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/cosmos-proto) +COSMOS_SDK_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk) +IBC_GO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v6) +ETHERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/evmos/ethermint) # # Common target directories