Skip to content

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

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

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

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Nov 1, 2020

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
Member Author

@AkihiroSuda @dims PTAL

@thaJeztah
Copy link
Member Author

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>
@thaJeztah thaJeztah changed the title CI: fix incorrect Go versions, due to sudo CI: remove "sudo" to fix incorrect Go versions (incorrect PATH, GOROOT) Nov 1, 2020
@thaJeztah
Copy link
Member Author

Updated; now removed sudo 😅

@thaJeztah
Copy link
Member Author

let me go ahead and merge this one

Sign up for free to 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