Skip to content

Commit

Permalink
chore: makefile Go min supported version check (osmosis-labs#6239)
Browse files Browse the repository at this point in the history
* chore: makefile Go min supported version check

* Update Makefile

Co-authored-by: Matt, Park <[email protected]>

---------

Co-authored-by: devbot-wizard <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
  • Loading branch information
3 people authored Aug 31, 2023
1 parent 479e449 commit bfdde37
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ DOCKER := $(shell which docker)
E2E_UPGRADE_VERSION := "v19"
#SHELL := /bin/bash

# Go version to be used in docker images
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
# currently installed Go version
GO_MODULE := $(shell cat go.mod | grep "module " | cut -d ' ' -f 2)
GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
# minimum supported Go version
GO_MINIMUM_MAJOR_VERSION = $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f2 | cut -d'.' -f1)
GO_MINIMUM_MINOR_VERSION = $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f2 | cut -d'.' -f2)
# message to be printed if Go does not meet the minimum required version
GO_VERSION_ERR_MSG = "ERROR: Go version $(GO_MINIMUM_MAJOR_VERSION).$(GO_MINIMUM_MINOR_VERSION)+ is required"

export GO111MODULE = on

Expand Down Expand Up @@ -102,10 +109,17 @@ endif
###############################################################################

check_version:
ifneq ($(GO_MINOR_VERSION),20)
@echo "ERROR: Go version 1.20 is required for this version of Osmosis."
exit 1
endif
@echo "Go version: $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION)"
@if [ $(GO_MAJOR_VERSION) -gt $(GO_MINIMUM_MAJOR_VERSION) ]; then \
echo "Go version is sufficient"; \
exit 0; \
elif [ $(GO_MAJOR_VERSION) -lt $(GO_MINIMUM_MAJOR_VERSION) ]; then \
echo '$(GO_VERSION_ERR_MSG)'; \
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(GO_MINIMUM_MINOR_VERSION) ]; then \
echo '$(GO_VERSION_ERR_MSG)'; \
exit 1; \
fi

all: install lint test

Expand Down

0 comments on commit bfdde37

Please sign in to comment.