From f4d4bb240fc2130ff999b2eabd7a8e12e7123a59 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Fri, 8 Nov 2024 16:57:04 -0500 Subject: [PATCH] Finish updating to go 1.22 Update references to specific versions of golang in the Makefile and the Cirrus CI configuration to match go.mod, and add a check in the 'vendor' target that CI runs that the image it's run inside is a close-enough match to the version listed in go.mod. Signed-off-by: Nalin Dahyabhai --- .cirrus.yml | 3 ++- Makefile | 5 +++-- hack/check_vendor_toolchain.sh | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100755 hack/check_vendor_toolchain.sh diff --git a/.cirrus.yml b/.cirrus.yml index d3b666433e5..5ac4bd8b717 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -120,13 +120,14 @@ vendor_task: # Runs within Cirrus's "community cluster" container: - image: docker.io/library/golang:latest + image: docker.io/library/golang:1.22 cpu: 1 memory: 1 timeout_in: 5m vendor_script: + - './hack/check_vendor_toolchain.sh Try updating the image used by the vendor_task in .cirrus.yml.' - 'make vendor' - './hack/tree_status.sh' diff --git a/Makefile b/Makefile index 37dbeb43e98..5cfebfbd2ed 100644 --- a/Makefile +++ b/Makefile @@ -202,10 +202,11 @@ test-unit: tests/testreport/testreport $(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover $(RACEFLAGS) ./cmd/buildah -args --root $$tmp/root --runroot $$tmp/runroot --storage-driver vfs --signature-policy $(shell pwd)/tests/policy.json --registries-conf $(shell pwd)/tests/registries.conf vendor-in-container: + goversion=$(shell sed -e '/^go /!d' -e '/^go /s,.* ,,g' go.mod) ; \ if test -d `go env GOCACHE` && test -w `go env GOCACHE` ; then \ - podman run --privileged --rm --env HOME=/root -v `go env GOCACHE`:/root/.cache/go-build --env GOCACHE=/root/.cache/go-build -v `pwd`:/src -w /src docker.io/library/golang:1.21 make vendor ; \ + podman run --privileged --rm --env HOME=/root -v `go env GOCACHE`:/root/.cache/go-build --env GOCACHE=/root/.cache/go-build -v `pwd`:/src -w /src docker.io/library/golang:$$goversion make vendor ; \ else \ - podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.21 make vendor ; \ + podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:$$goversion make vendor ; \ fi .PHONY: vendor diff --git a/hack/check_vendor_toolchain.sh b/hack/check_vendor_toolchain.sh new file mode 100755 index 00000000000..31f9ec28627 --- /dev/null +++ b/hack/check_vendor_toolchain.sh @@ -0,0 +1,11 @@ +#!/bin/bash +topdir=$(dirname ${BASH_SOURCE})/.. +wantversion=$(sed -e '/^go /!d' -e '/^go /s,.* ,,g' ${topdir}/go.mod) +goversion=$(go env GOVERSION) +haveversion=${goversion/go} +if test "${wantversion%.*}" != "${haveversion%.*}" ; then + echo go.mod uses Go "${wantversion%.*}" \("${wantversion}"\), but environment provides "${haveversion%.*}" \("${haveversion}"\). + echo "$@" + exit 1 +fi +exit 0