renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.47k stars 2.3k forks source link

Override GOPATH to use Renovate cache #29817

Open rarkins opened 4 months ago

rarkins commented 4 months ago

Describe the proposed change(s).

Currently Containerbase defaults to /go for GOPATH, this means that installed Go modules accumulate there. Instead, we should be aiming for all managers to use cacheDir.

rarkins commented 4 months ago

Hmm: https://github.com/renovatebot/renovate/blob/b6d2c4bb32e52a2d8a5d7fe06b89297a9bb3d5b6/lib/modules/manager/gomod/artifacts.ts#L202

rarkins commented 4 months ago

This GOPATH override doesn't seem to take effect.

A new renovate/renovate container:

ubuntu@8ca7c127dcb9:/usr/src/app$ du -sh /go/*
4.0K    /go/bin
4.0K    /go/pkg
4.0K    /go/src
ubuntu@8ca7c127dc

After running on a repo where Go PRs are created:

ubuntu@344ee60b6846:/usr/src/app$ du -sh /go/*
4.0K    /go/bin
498M    /go/pkg
4.0K    /go/src
jamietanna commented 3 months ago

Interesting that we wire it in already - up until now I've been explicitly setting GOPATH in my container setup to override it to the cacheDir - it looks like we should be wiring that variable in correctly 🤔

viceice commented 3 months ago

https://github.com/containerbase/base/blob/60ada9adb2ff7b6cc5ffe97f007b8a31c6c22070/src/usr/local/containerbase/tools/v2/golang.sh#L9

this is overriding the renovate env, it will be fixed in containerbase v11

rarkins commented 1 week ago

@viceice where should we expect Go cache to be written currently (containerbase v11) or in v12?

viceice commented 1 week ago

in v11 it should be /opt/containerbase/home/go which is symlinked to /home/ubuntu/go. but renovate always set GOPATH so it should now follow that.

v12 changed /opt/containerbase/home/go to /tmp/containerbase/cache/go

we dropped default env GOPATH in v11