Skip to content

Commit 4a7f6f8

Browse files
authored
Merge pull request #237 from gfouillet/fix/snap-go-ne
fix(ci-run): add fallback for Go version installation in CI script
2 parents c677b88 + bfd1892 commit 4a7f6f8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

jobs/ci-run/scripts/package-juju-source.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,24 @@ if [ -z "$GOVERSION" ]; then
1111
exit 1
1212
fi
1313

14+
1415
export PATH="/snap/bin:$PATH"
1516
GO_MAJOR_MINOR=$(echo ${GOVERSION} | cut -d '.' -f1,2)
16-
sudo snap refresh go --channel="${GO_MAJOR_MINOR}/stable" || sudo snap install go --channel="${GO_MAJOR_MINOR}/stable" --classic
17+
if sudo snap refresh go --channel="${GO_MAJOR_MINOR}/stable" || sudo snap install go --channel="${GO_MAJOR_MINOR}/stable" --classic; then
18+
echo "Successfully installed Go ${GO_MAJOR_MINOR}"
19+
else
20+
# If specific version installation fails, install latest available
21+
echo "Failed to install Go ${GO_MAJOR_MINOR}, installing latest available version"
22+
if sudo snap refresh go --channel=latest/stable || sudo snap install go --channel=latest/stable --classic; then
23+
echo "Successfully installed latest Go version: $(go version)"
24+
# Export GOTOOLCHAIN to use the expected version
25+
# Note: this is a hack which avoid breaking the CI if for some reason snap go is behind the required version for
26+
# Juju. It is not something that should happens regularly, and whenever the snap go is available, this hack won't
27+
# be used.
28+
export GOTOOLCHAIN="go${GOVERSION}.0+auto"
29+
echo "Exported GOTOOLCHAIN=${GOTOOLCHAIN}"
30+
fi
31+
fi
1732

1833
# TODO - fix this workaround
1934
# As we clone the full history (can't shallow clone otherwise queued jobs miss

0 commit comments

Comments
 (0)