From 41e767c62790340d09dfb64783f6d7255ed7037b Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Tue, 26 Mar 2019 15:45:34 -0600 Subject: [PATCH] Use GOCACHE. It was always being recreated (#64) * Use GOCACHE. It was always being recreated * Silent build again like it should be * test fixups --- makefile_components/base_build_go.mak | 4 +++- tests/pkg/clean/build_tools_test.go | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/makefile_components/base_build_go.mak b/makefile_components/base_build_go.mak index 00cdc43..4c8cc3a 100644 --- a/makefile_components/base_build_go.mak +++ b/makefile_components/base_build_go.mak @@ -12,6 +12,7 @@ DOCKERBUILDCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) -e CGO_ENABLED=0 \ -e GOOS=$@ \ -e GOPATH="//workdir/$(GOTMP)" \ + -e GOCACHE="//workdir/$(GOTMP)/.cache" \ -e GOFLAGS="$(USEMODVENDOR)" \ -w //workdir \ $(BUILD_IMAGE) @@ -19,6 +20,7 @@ DOCKERBUILDCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) DOCKERTESTCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) \ -v "$(S)$(PWD):/workdir$(DOCKERMOUNTFLAG)" \ -e GOPATH="//workdir/$(GOTMP)" \ + -e GOCACHE="//workdir/$(GOTMP)/.cache" \ -e GOFLAGS="$(USEMODVENDOR)" \ -w //workdir \ $(BUILD_IMAGE) @@ -84,7 +86,7 @@ linux darwin windows: pull $(GOFILES) @echo "building $@ from $(SRC_AND_UNDER)" @echo $(shell if [ "$(BUILD_OS)" = "windows" ]; then echo "windows build: BUILD_OS=$(BUILD_OS) DOCKER_TOOLBOX_INSTALL_PATH=$(DOCKER_TOOLBOX_INSTALL_PATH) PWD=$(PWD) S=$(S)"; fi ) @mkdir -p $(GOTMP)/{.cache,pkg,src,bin} - $(DOCKERBUILDCMD) \ + @$(DOCKERBUILDCMD) \ go install -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER) && touch $@ $( shell if [ -d $(GOTMP) ]; then chmod -R u+w $(GOTMP); fi ) @echo $(VERSION) >VERSION.txt diff --git a/tests/pkg/clean/build_tools_test.go b/tests/pkg/clean/build_tools_test.go index 2944cd6..9914b1c 100644 --- a/tests/pkg/clean/build_tools_test.go +++ b/tests/pkg/clean/build_tools_test.go @@ -62,11 +62,11 @@ func TestBuild(t *testing.T) { a.NoError(err, "Failed to 'make darwin'") a.Contains(string(v), "building darwin") - v, err = exec.Command("make", "linux").Output() - a.NoError(err) + v, err = exec.Command("bash", "-c", "pwd && make linux").Output() + a.NoError(err, "failed 'make linux', err=%v, output='%v'", err, string(v)) a.Contains(string(v), "building linux") - v, err = exec.Command("make", "windows").Output() + v, err = exec.Command("bash", "-c", "pwd && make windows").Output() a.NoError(err) a.Contains(string(v), "building windows")