Skip to content

CI: remove "sudo" to fix incorrect Go versions (incorrect PATH, GOROOT) - #22

Merged
thaJeztah merged 2 commits into
moby:masterfrom
thaJeztah:suno
Nov 1, 2020
Merged

CI: remove "sudo" to fix incorrect Go versions (incorrect PATH, GOROOT)#22
thaJeztah merged 2 commits into
moby:masterfrom
thaJeztah:suno

Conversation

@thaJeztah

@thaJeztahthaJeztah commented Nov 1, 2020

Copy link
Copy Markdown
Member

We were using sudo (without -E), causing environment variables that were set by actions/setup-go to be lost.

We need to preserve environment variables, including PATH, because actions/setup-go@v2 installs Go in specific paths to allow multiple versions to be installed/cached on workers, for example, in "/opt/hostedtoolcache/go/1.13.15/x64".

While it's possible to fix by adding both -E, and env "PATH=$PATH" (sudo -E does not preserve PATHas a security measure (see https://unix.stackexchange.com/a/83194/78656), this repository does not need sudo for its tests to run, so we might as well remove it altogether.

Also removing the setup-go step from the Lint stage, as it runs in a container, so Go is not needed on the host.

For details, see my debugging steps in #21

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

@AkihiroSuda@dims PTAL

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

Actually; why do we need sudo? Is there anything in this repo that requires sudo privileges? 🤔

We were using `sudo` (without `-E`), causing environment variables that
were set by `actions/setup-go` to be lost.
We need to preserve environment variables, including `PATH`, because
`actions/setup-go@v2` installs Go in specific paths to allow multiple
versions to be installed/cached on workers, for example, in
`"/opt/hostedtoolcache/go/1.13.15/x64"`.
While it's possible to fix by adding both `-E`, and `env "PATH=$PATH"`
(sudo -E does not preserve `PATH`as a security measure (see
https://unix.stackexchange.com/a/83194/78656), this repository does
not need `sudo` for its tests to run, so we might as well remove
it altogether.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This stage runs in a container, so Go is not needed on the host.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztahthaJeztah changed the title CI: fix incorrect Go versions, due to sudoCI: remove "sudo" to fix incorrect Go versions (incorrect PATH, GOROOT)Nov 1, 2020
@thaJeztah

Copy link
Copy Markdown
MemberAuthor

Updated; now removed sudo 😅

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

let me go ahead and merge this one

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@thaJeztah@AkihiroSuda