Use GO_VERSION to set / verify go version

This commit is contained in:
Ian Davis 2022-10-14 15:13:11 +01:00
parent cf60d862f8
commit 296eaff73c
2 changed files with 24 additions and 4 deletions

View File

@ -5,6 +5,7 @@ orbs:
executors: executors:
golang: golang:
docker: docker:
# Must match GO_VERSION in project root
- image: cimg/go:1.18.1 - image: cimg/go:1.18.1
resource_class: 2xlarge resource_class: 2xlarge
ubuntu: ubuntu:
@ -44,6 +45,15 @@ commands:
- when: - when:
condition: << parameters.linux >> condition: << parameters.linux >>
steps: steps:
- run:
name: Check Go Version
command: |
v=`go version | { read _ _ v _; echo ${v#go}; }`
if [[ $v != `cat GO_VERSION` ]]; then
echo "GO_VERSION file does not match the go version being used."
echo "Please update image to cimg/go:`cat GO_VERSION` or update GO_VERSION to $v."
exit 1
fi
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev - run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev
- when: - when:
@ -52,7 +62,7 @@ commands:
- run: - run:
name: Install Go name: Install Go
command: | 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`.darwin-amd64.pkg -o /tmp/go.pkg && \
sudo installer -pkg /tmp/go.pkg -target / sudo installer -pkg /tmp/go.pkg -target /
- run: - run:
name: Export Go name: Export Go
@ -428,7 +438,7 @@ jobs:
name: Update Go name: Update Go
command: | command: |
sudo rm -rf /usr/local/go && \ sudo rm -rf /usr/local/go && \
curl -L https://golang.org/dl/go1.18.1.linux-amd64.tar.gz -o /tmp/go.tar.gz && \ curl -L https://golang.org/dl/go`cat GO_VERSION`.linux-amd64.tar.gz -o /tmp/go.tar.gz && \
sudo tar -C /usr/local -xvf /tmp/go.tar.gz sudo tar -C /usr/local -xvf /tmp/go.tar.gz
- run: go version - run: go version
- run: - run:

View File

@ -5,6 +5,7 @@ orbs:
executors: executors:
golang: golang:
docker: docker:
# Must match GO_VERSION in project root
- image: cimg/go:1.18.1 - image: cimg/go:1.18.1
resource_class: 2xlarge resource_class: 2xlarge
ubuntu: ubuntu:
@ -44,6 +45,15 @@ commands:
- when: - when:
condition: << parameters.linux >> condition: << parameters.linux >>
steps: steps:
- run:
name: Check Go Version
command: |
v=`go version | { read _ _ v _; echo ${v#go}; }`
if [["[[ $v != `cat GO_VERSION` ]]"]]; then
echo "GO_VERSION file does not match the go version being used."
echo "Please update image to cimg/go:`cat GO_VERSION` or update GO_VERSION to $v."
exit 1
fi
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev - run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev
- when: - when:
@ -52,7 +62,7 @@ commands:
- run: - run:
name: Install Go name: Install Go
command: | 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`.darwin-amd64.pkg -o /tmp/go.pkg && \
sudo installer -pkg /tmp/go.pkg -target / sudo installer -pkg /tmp/go.pkg -target /
- run: - run:
name: Export Go name: Export Go
@ -428,7 +438,7 @@ jobs:
name: Update Go name: Update Go
command: | command: |
sudo rm -rf /usr/local/go && \ sudo rm -rf /usr/local/go && \
curl -L https://golang.org/dl/go1.18.1.linux-amd64.tar.gz -o /tmp/go.tar.gz && \ curl -L https://golang.org/dl/go`cat GO_VERSION`.linux-amd64.tar.gz -o /tmp/go.tar.gz && \
sudo tar -C /usr/local -xvf /tmp/go.tar.gz sudo tar -C /usr/local -xvf /tmp/go.tar.gz
- run: go version - run: go version
- run: - run: