Commit d9f97bdc authored by Jérome Perrin's avatar Jérome Perrin

component/golang: clear user cache after build

While running tests using all.bash, `$HOME/.cache/go-build/` is
populated with data referencing the build folder. This is problematic
when using shared parts and installing a not pinned software release
multiple times, like it is the case on test node.

A scenario like this can happen:

 - a first succesful build install in `<shared>/golang1.21/<HASH1>`
 - golang1.21 section is changed in a the software release
 - golang1.21 is installed in `<shared>/golang1.21/<HASH2>`, running
   test fails because the cache `<software_folder>/.cache/go-build/` in
   references paths from `<shared>/golang1.21/<HASH1>/.build/go/src`,
   that was used when building the first build and have been removed
   while installing.

This is visible with errors like this:

    2024-03-21 20:52:37,214 INFO     slapgrid_sr: 2024-03-21 20:52:37 slapos[23849] INFO vet: can't parse raw cgo file: open ../../../../a984f246a1b2789081965ab5c05674a8/.build/go/src/net/cgo_linux.go: no such file or directory
parent 77411007
......@@ -19,11 +19,18 @@ shared = true
configure-command = :
location = @@LOCATION@@
make-binary =
make-targets =
cd src &&
unset GOBIN &&
# build and test Go and its standard library
./all.bash &&
# clean intermediate cache before installing
# contrary to build cache in gowork, build cache, that Go uses during its own build, is not reused anywhere:
# https://github.com/golang/go/blob/go1.18.2-0-g8ed0e51b5e/src/cmd/dist/build.go#L239-L242
make-targets= cd src && unset GOBIN && ./all.bash && GOCACHE=`pwd`/../pkg/obj/go-build ../bin/go clean -cache && cp -alf .. ${:location}
GOCACHE=`pwd`/../pkg/obj/go-build ../bin/go clean -cache &&
# also clean the global cache, which is used during the tests.
../bin/go clean -cache &&
cp -alf .. ${:location}
# some testdata files have an issue with slapos.extension.strip.
post-install = ${findutils:location}/bin/find ${:location}/src -type d -name testdata -exec rm -rf {} \; || true
environment =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment