netlify / build-image

This is the build image used for running automated builds
MIT License
496 stars 197 forks source link

fix: ensure that go is always correctly installed #887

Closed danez closed 1 year ago

danez commented 1 year ago

Summary

Fixes https://github.com/netlify/pillar-workflow/issues/1025

When installing go we always checked if GIMME_GO_VERSION (default installed version in docker 1.19.x) does not equal installGoVersion (users version from GO_VERSION or default 1.19.x).

If they do not equal we would resolve installGoVersion and install it by calling gimme.

Otherwise we would install the version from GIMME_GO_VERSION.

Checking the history GIMME_GO_VERSION was always identical to the default installGoVersion unless the user changed it, but in #870 both default value were changed to be 1.19.x. Two problems with that:

The change simplifies the code and always checks if the actual resolved version from installGoVersion is already installed or not. GIMME_GO_VERSION is not used anymore as it really does not matter, either the requested go version is installed or not.

This has one downside though: we always call gimme --resolve which goes to network for .x versions, but caches known versions for 3 hours by default, I changed that to 7 days, but that is debatable. That means that when 1.19.5 is released it might take up to a week before users with a go version of 1.19.x will get that new version. (The actual check in gimme uses the file creation time, so I do hope our caching preserves file creation times)

What I did not understand what gimme | bash was supposed to do? It installs GIMME_GO_VERSION by default, but why the pipe to bash? gimme returns a bash script, so the source call we had in the script did source the script a second time.

The alternative is to simply revert all the default versions from 1.19.x to 1.19.4, BUT bitballon currently freezes 1.19.x to new user accounts, so in any way the builds would get a installGoVersion of 1.19.x


For us to review and ship your PR efficiently, please perform the following steps:

A picture of a cute animal (not mandatory, but encouraged)