Merge ~cgrabowski/maas:backport-go-mod-cache-update-to-3.2 into maas:3.2

Proposed by Christian Grabowski
Status: Merged
Approved by: Christian Grabowski
Approved revision: 3b0d4cc2116eabd21854809248b093743b65391c
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~cgrabowski/maas:backport-go-mod-cache-update-to-3.2
Merge into: maas:3.2
Diff against target: 32 lines (+11/-6)
1 file modified
src/host-info/Makefile (+11/-6)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Anton Troyanov Approve
Review via email: mp+428811@code.launchpad.net

Commit message

set the GOMODCACHE var when building go packages
This also drops the dependency on the "vendor" target when building since this
is not needed during build and might cause network traffic to update packages,
which fails in Launchpad package builds.
(cherry picked from commit 435d8e6f966a6af015cba8096fa40423d4638ed6)

To post a comment you must log in.
Revision history for this message
Anton Troyanov (troyanov) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b backport-go-mod-cache-update-to-3.2 lp:~cgrabowski/maas/+git/maas into -b 3.2 lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/372/consoleText
COMMIT: 3b0d4cc2116eabd21854809248b093743b65391c

review: Needs Fixing
Revision history for this message
Christian Grabowski (cgrabowski) wrote :

jenkins: !test

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b backport-go-mod-cache-update-to-3.2 lp:~cgrabowski/maas/+git/maas into -b 3.2 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 3b0d4cc2116eabd21854809248b093743b65391c

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

LANDING
-b backport-go-mod-cache-update-to-3.2 lp:~cgrabowski/maas/+git/maas into -b 3.2 lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci.internal:8080/job/maas-tester/374/consoleText

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/host-info/Makefile b/src/host-info/Makefile
2index 5e5400f..48a7a93 100644
3--- a/src/host-info/Makefile
4+++ b/src/host-info/Makefile
5@@ -19,16 +19,21 @@ CMD_DIR := ./cmd
6 PACKAGE_DIR := $(CMD_DIR)/machine-resources
7 HARDWARE_SYNC_DIR := $(CMD_DIR)/hardware-sync
8 VENDOR_DIR := $(PACKAGE_DIR)/vendor
9-GO_CACHE_DIR := $(shell [ -d $(HOME)/.cache ] && echo $(HOME)/.cache/go-cache || mktemp --tmpdir -d tmp.go-cacheXXX)
10+# Explicitly set cache dirs to avoid situations where we can't mkdir under $HOME (e.g. Launchpad builds)
11+export GOCACHE := $(shell [ -d $(HOME)/.cache ] && echo $(HOME)/.cache/go-cache || mktemp --tmpdir -d tmp.go-cacheXXX)
12+export GOMODCACHE := $(shell [ -d $(HOME)/go ] && echo $(HOME)/go/pkg/mod || mktemp --tmpdir -d tmp.go-mod-cacheXXX)
13
14 .DEFAULT_GOAL := build
15
16-# XXX: Explicitly set GOCACHE to avoid situations where we can't mkdir $HOME/.cache (autopkgtest VM)
17-$(MACHINE_RESOURCES_BINARIES): vendor
18- GOCACHE=$(GO_CACHE_DIR) GOARCH=$(DEB_GO_ARCH_$(notdir $@)) go build -mod vendor -ldflags '-s -w' -o $@ $(PACKAGE_DIR)
19+# build static binaries since they need to run on different Ubuntu releases
20+GO_BUILD := CGO_ENABLED=0 go build -mod=vendor -ldflags '-s -w -extldflags "-static"'
21
22-$(HARDWARE_SYNC_BINARIES): vendor
23- GOCACHE=$(GO_CACHE_DIR) GOARCH=$(DEB_GO_ARCH_$(notdir $@)) go build -mod vendor -ldflags '-s -w' -o $@ $(HARDWARE_SYNC_DIR)
24+.DEFAULT_GOAL := build
25+
26+$(MACHINE_RESOURCES_BINARIES): TARGET_DIR=$(PACKAGE_DIR)
27+$(HARDWARE_SYNC_BINARIES): TARGET_DIR=$(HARDWARE_SYNC_DIR)
28+$(HARDWARE_SYNC_BINARIES) $(MACHINE_RESOURCES_BINARIES):
29+ GOARCH=$(DEB_GO_ARCH_$(notdir $@)) $(GO_BUILD) -o $@ $(TARGET_DIR)
30
31 build: $(MACHINE_RESOURCES_BINARIES)
32 .PHONY: build

Subscribers

People subscribed via source and target branches