diff --git a/.circleci/config.yml b/.circleci/config.yml index 73c7eff6c..32ff25353 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,6 +5,7 @@ orbs: executors: golang: docker: + # Must match GO_VERSION_MIN in project root - image: cimg/go:1.18.1 resource_class: 2xlarge ubuntu: @@ -44,6 +45,15 @@ commands: - when: condition: << parameters.linux >> steps: + - run: + name: Check Go Version + command: | + v=`go version | { read _ _ v _; echo ${v#go}; }` + if [[ $v != `cat GO_VERSION_MIN` ]]; then + echo "GO_VERSION_MIN file does not match the go version being used." + echo "Please update image to cimg/go:`cat GO_VERSION_MIN` or update GO_VERSION_MIN to $v." + exit 1 + fi - run: sudo apt-get update - run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev - when: @@ -52,7 +62,7 @@ commands: - run: name: Install Go command: | - curl https://dl.google.com/go/go1.18.1.darwin-amd64.pkg -o /tmp/go.pkg && \ + curl https://dl.google.com/go/go`cat GO_VERSION_MIN`.darwin-amd64.pkg -o /tmp/go.pkg && \ sudo installer -pkg /tmp/go.pkg -target / - run: name: Export Go @@ -427,7 +437,8 @@ jobs: - run: name: Update Go command: | - curl -L https://golang.org/dl/go1.18.1.linux-amd64.tar.gz -o /tmp/go.tar.gz && \ + sudo rm -rf /usr/local/go && \ + curl -L https://golang.org/dl/go`cat GO_VERSION_MIN`.linux-amd64.tar.gz -o /tmp/go.tar.gz && \ sudo tar -C /usr/local -xvf /tmp/go.tar.gz - run: go version - run: diff --git a/.circleci/template.yml b/.circleci/template.yml index 4fe4e4bd3..a632df6b9 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -5,6 +5,7 @@ orbs: executors: golang: docker: + # Must match GO_VERSION_MIN in project root - image: cimg/go:1.18.1 resource_class: 2xlarge ubuntu: @@ -44,6 +45,15 @@ commands: - when: condition: << parameters.linux >> steps: + - run: + name: Check Go Version + command: | + v=`go version | { read _ _ v _; echo ${v#go}; }` + if [["[[ $v != `cat GO_VERSION_MIN` ]]"]]; then + echo "GO_VERSION_MIN file does not match the go version being used." + echo "Please update image to cimg/go:`cat GO_VERSION_MIN` or update GO_VERSION_MIN to $v." + exit 1 + fi - run: sudo apt-get update - run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev - when: @@ -52,7 +62,7 @@ commands: - run: name: Install Go command: | - curl https://dl.google.com/go/go1.18.1.darwin-amd64.pkg -o /tmp/go.pkg && \ + curl https://dl.google.com/go/go`cat GO_VERSION_MIN`.darwin-amd64.pkg -o /tmp/go.pkg && \ sudo installer -pkg /tmp/go.pkg -target / - run: name: Export Go @@ -427,7 +437,8 @@ jobs: - run: name: Update Go command: | - curl -L https://golang.org/dl/go1.18.1.linux-amd64.tar.gz -o /tmp/go.tar.gz && \ + sudo rm -rf /usr/local/go && \ + curl -L https://golang.org/dl/go`cat GO_VERSION_MIN`.linux-amd64.tar.gz -o /tmp/go.tar.gz && \ sudo tar -C /usr/local -xvf /tmp/go.tar.gz - run: go version - run: diff --git a/GO_VERSION_MIN b/GO_VERSION_MIN new file mode 100644 index 000000000..ec6d649be --- /dev/null +++ b/GO_VERSION_MIN @@ -0,0 +1 @@ +1.18.1 diff --git a/Makefile b/Makefile index c4050c136..fd755055d 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ unexport GOFLAGS GOCC?=go GOVERSION:=$(shell $(GOCC) version | tr ' ' '\n' | grep go1 | sed 's/^go//' | awk -F. '{printf "%d%03d%03d", $$1, $$2, $$3}') -ifeq ($(shell expr $(GOVERSION) \< 1018001), 1) +GOVERSIONMIN:=$(shell cat GO_VERSION_MIN | awk -F. '{printf "%d%03d%03d", $$1, $$2, $$3}') + +ifeq ($(shell expr $(GOVERSION) \< $(GOVERSIONMIN)), 1) $(warning Your Golang version is go$(shell expr $(GOVERSION) / 1000000).$(shell expr $(GOVERSION) % 1000000 / 1000).$(shell expr $(GOVERSION) % 1000)) -$(error Update Golang to version to at least 1.18.1) +$(error Update Golang to version to at least $(shell cat GO_VERSION_MIN)) endif # git modules that need to be loaded