From cc84faaca08f808afe12e63606c6e5dc473dab8e Mon Sep 17 00:00:00 2001 From: EraKin575 Date: Thu, 13 Jun 2024 02:27:44 +0530 Subject: [PATCH 1/5] fixed gotip installation workflow Signed-off-by: EraKin575 --- .github/actions/setup-go-tip/action.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-go-tip/action.yml b/.github/actions/setup-go-tip/action.yml index 192fb4ac717..cf745125ed6 100644 --- a/.github/actions/setup-go-tip/action.yml +++ b/.github/actions/setup-go-tip/action.yml @@ -4,7 +4,7 @@ description: 'Install Go Tip toolchain' runs: using: "composite" steps: - - name: Install Go Tip + - name: Try to download Go Tip shell: bash run: | set -euo pipefail @@ -22,11 +22,12 @@ runs: echo "Failed to download. Retrying in $wait_time seconds..." sleep $wait_time done + echo "download_status=${success}" >> $GITHUB_OUTPUT - if [[ "$success" == false ]]; then - echo "Failed to download Go Tip after $retries attempts" - exit 1 - fi + - name: Install Go Tip + if: steps.try-to-download-go-tip.outputs.download_status == 'true' + shell: bash + run: | echo "Downloaded bundle:" ls -lah gotip.tar.gz export GOROOT="$HOME/sdk/gotip" @@ -39,3 +40,12 @@ runs: echo "PATH=$PATH" >> $GITHUB_ENV echo "Active Go version:" go version + + - name: Build Go Tip from source + if: steps.try-to-download-go-tip.outputs.download_status == 'false' + shell: bash + run: | + go install golang.org/dl/gotip@latest + gotip download + echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV + echo "GOTIP_BIN=$(go env GOPATH)/bin/gotip" >> $GITHUB_ENV \ No newline at end of file From b372477641cb6aceaed080f7a59b977e5069029e Mon Sep 17 00:00:00 2001 From: EraKin575 Date: Thu, 13 Jun 2024 12:47:14 +0530 Subject: [PATCH 2/5] fixed gotip workflow Signed-off-by: EraKin575 --- .github/actions/setup-go-tip/action.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-go-tip/action.yml b/.github/actions/setup-go-tip/action.yml index cf745125ed6..4ee364a932f 100644 --- a/.github/actions/setup-go-tip/action.yml +++ b/.github/actions/setup-go-tip/action.yml @@ -1,10 +1,10 @@ -# Inspired by https://github.com/actions/setup-go/issues/21#issuecomment-997208686 name: 'Install Go Tip' description: 'Install Go Tip toolchain' runs: using: "composite" steps: - name: Try to download Go Tip + id: try-to-download-go-tip shell: bash run: | set -euo pipefail @@ -48,4 +48,11 @@ runs: go install golang.org/dl/gotip@latest gotip download echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV - echo "GOTIP_BIN=$(go env GOPATH)/bin/gotip" >> $GITHUB_ENV \ No newline at end of file + echo "GOTIP_BIN=$(go env GOPATH)/bin/gotip" >> $GITHUB_ENV + + - name: Fail if Go Tip is not installed + if: steps.try-to-download-go-tip.outputs.download_status == 'false' && failure() + shell: bash + run: | + echo "Both downloading and building Go Tip failed." + exit 1 From 498b492e9a4b594bf8ce0ef8115eed1cb65da131 Mon Sep 17 00:00:00 2001 From: EraKin575 Date: Thu, 13 Jun 2024 22:36:18 +0530 Subject: [PATCH 3/5] fixed gotip workflow Signed-off-by: EraKin575 --- .github/actions/setup-go-tip/action.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/actions/setup-go-tip/action.yml b/.github/actions/setup-go-tip/action.yml index 4ee364a932f..4c90b021b9c 100644 --- a/.github/actions/setup-go-tip/action.yml +++ b/.github/actions/setup-go-tip/action.yml @@ -3,8 +3,8 @@ description: 'Install Go Tip toolchain' runs: using: "composite" steps: - - name: Try to download Go Tip - id: try-to-download-go-tip + - name: Download Go Tip + id: download-go-tip shell: bash run: | set -euo pipefail @@ -25,7 +25,7 @@ runs: echo "download_status=${success}" >> $GITHUB_OUTPUT - name: Install Go Tip - if: steps.try-to-download-go-tip.outputs.download_status == 'true' + if: steps.download-go-tip.outputs.download_status == 'true' shell: bash run: | echo "Downloaded bundle:" @@ -42,7 +42,7 @@ runs: go version - name: Build Go Tip from source - if: steps.try-to-download-go-tip.outputs.download_status == 'false' + if: steps.download-go-tip.outputs.download_status == 'false' shell: bash run: | go install golang.org/dl/gotip@latest @@ -50,9 +50,3 @@ runs: echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV echo "GOTIP_BIN=$(go env GOPATH)/bin/gotip" >> $GITHUB_ENV - - name: Fail if Go Tip is not installed - if: steps.try-to-download-go-tip.outputs.download_status == 'false' && failure() - shell: bash - run: | - echo "Both downloading and building Go Tip failed." - exit 1 From c7a543e9b9376fdf6ba2c92f53aeb4b4fdb31a97 Mon Sep 17 00:00:00 2001 From: EraKin575 Date: Thu, 13 Jun 2024 23:29:59 +0530 Subject: [PATCH 4/5] added go version step Signed-off-by: EraKin575 --- .github/actions/setup-go-tip/action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-go-tip/action.yml b/.github/actions/setup-go-tip/action.yml index 4c90b021b9c..d557da31b3a 100644 --- a/.github/actions/setup-go-tip/action.yml +++ b/.github/actions/setup-go-tip/action.yml @@ -1,3 +1,4 @@ +# Inspired by https://github.com/actions/setup-go/issues/21#issuecomment-997208686 name: 'Install Go Tip' description: 'Install Go Tip toolchain' runs: @@ -38,8 +39,6 @@ runs: echo "GOROOT=$GOROOT" >> $GITHUB_ENV echo "GOPATH=$GOPATH" >> $GITHUB_ENV echo "PATH=$PATH" >> $GITHUB_ENV - echo "Active Go version:" - go version - name: Build Go Tip from source if: steps.download-go-tip.outputs.download_status == 'false' @@ -49,4 +48,10 @@ runs: gotip download echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV echo "GOTIP_BIN=$(go env GOPATH)/bin/gotip" >> $GITHUB_ENV + + - name: Check Go Version + shell: bash + run: | + echo "Active Go version:" + go version From cf91ff3f46891e39bd67b2fac96e9b0e05fb8485 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Sat, 15 Jun 2024 17:11:36 -0400 Subject: [PATCH 5/5] fix Signed-off-by: Yuri Shkuro --- .github/actions/setup-go-tip/action.yml | 58 ++++++++++++++++++------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/.github/actions/setup-go-tip/action.yml b/.github/actions/setup-go-tip/action.yml index d557da31b3a..f67ac6a58b7 100644 --- a/.github/actions/setup-go-tip/action.yml +++ b/.github/actions/setup-go-tip/action.yml @@ -5,14 +5,15 @@ runs: using: "composite" steps: - name: Download Go Tip - id: download-go-tip + id: download shell: bash run: | + echo Download Go Tip set -euo pipefail tip=$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}') echo "Go Tip version: ${tip}" - retries=10 - wait_time=30 + retries=3 + wait_time=10 success=false for ((i=1; i<=retries; i++)); do url="https://storage.googleapis.com/go-build-snap/go/linux-amd64/${tip}.tar.gz" @@ -23,35 +24,62 @@ runs: echo "Failed to download. Retrying in $wait_time seconds..." sleep $wait_time done - echo "download_status=${success}" >> $GITHUB_OUTPUT + echo "success=${success}" >> $GITHUB_OUTPUT - - name: Install Go Tip - if: steps.download-go-tip.outputs.download_status == 'true' + - name: Unpack gotip bundle + if: steps.download.outputs.success == 'true' shell: bash run: | + echo Unpack gotip bundle + set -euo pipefail echo "Downloaded bundle:" ls -lah gotip.tar.gz export GOROOT="$HOME/sdk/gotip" - export GOPATH="$HOME/go" mkdir -p $GOROOT tar -C $GOROOT -xzf gotip.tar.gz - export PATH="$GOROOT/bin/:$GOPATH/bin:$PATH" echo "GOROOT=$GOROOT" >> $GITHUB_ENV - echo "GOPATH=$GOPATH" >> $GITHUB_ENV - echo "PATH=$PATH" >> $GITHUB_ENV + + # If download failed, we will try to build tip from source. + # This requires Go toolchain, so install it first. + - name: Install Go toolchain + if: steps.download.outputs.success == 'false' + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: 1.22.x - name: Build Go Tip from source - if: steps.download-go-tip.outputs.download_status == 'false' + if: steps.download.outputs.success == 'false' shell: bash run: | + echo Build Go Tip from source + set -euo pipefail go install golang.org/dl/gotip@latest gotip download - echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV - echo "GOTIP_BIN=$(go env GOPATH)/bin/gotip" >> $GITHUB_ENV - + export GOROOT="$(gotip env GOROOT)" + echo "GOROOT=$GOROOT" >> $GITHUB_ENV + # for some reason even though we put gotip at the front of PATH later, + # the go binary installed in previous step still takes precedence. So remove it. + rm -f $(which go) + + - name: Setup Go environment + shell: bash + run: | + echo Setup Go environment + set -euo pipefail + $GOROOT/bin/go version + GOPATH="$HOME/gotip" + PATH="$GOROOT/bin:$GOPATH/bin:$PATH" + echo "GOPATH=$GOPATH" >> $GITHUB_ENV + echo "PATH=$PATH" >> $GITHUB_ENV + - name: Check Go Version shell: bash run: | + echo Check Go Version + set -euo pipefail + echo "GOPATH=$GOPATH" + echo "GOROOT=$GOROOT" + echo "which go:" + which -a go echo "Active Go version:" go version -