Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternate way to install gotip #5618

Merged
merged 12 commits into from
Jun 15, 2024
29 changes: 23 additions & 6 deletions .github/actions/setup-go-tip/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Inspired by https://github.com/actions/setup-go/issues/21#issuecomment-997208686
EraKin575 marked this conversation as resolved.
Show resolved Hide resolved
name: 'Install Go Tip'
description: 'Install Go Tip toolchain'
runs:
using: "composite"
steps:
- name: Install Go Tip
- name: Try to download Go Tip
id: try-to-download-go-tip
shell: bash
run: |
set -euo pipefail
Expand All @@ -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'
EraKin575 marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
run: |
echo "Downloaded bundle:"
ls -lah gotip.tar.gz
export GOROOT="$HOME/sdk/gotip"
Expand All @@ -39,3 +40,19 @@ runs:
echo "PATH=$PATH" >> $GITHUB_ENV
echo "Active Go version:"
go version
EraKin575 marked this conversation as resolved.
Show resolved Hide resolved

- 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this in your run https://github.com/EraKin575/test-project/actions/runs/9504391060/job/26196935810#step:7:66

Success. You may now run 'gotip'!
Run echo "Active Go version:"
Active Go version:
go version go1.22.4 linux/amd[64](https://github.com/EraKin575/test-project/actions/runs/9504391060/job/26196935810#step:7:67)

This isn't gotip. And I was expecting that, because you're not setting up env vars the same way as we do in L38-41. For example, you do GOROOT=$(go env GOROOT) - that's just default Go version, nothing to do with gotip.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Someting like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note - we could still make it work, I suppose, but then we need to change how the tests are run, e.g. make test GO=gotip

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

I don't like "designing by screenshots" - you should test it out. This is why we have the final step to print go version


EraKin575 marked this conversation as resolved.
Show resolved Hide resolved
- name: Fail if Go Tip is not installed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, we will see if the previous steps fail.

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