diff --git a/Makefile b/Makefile index 86b3c724..861278f9 100644 --- a/Makefile +++ b/Makefile @@ -26,10 +26,11 @@ GO ?= go CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker) GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man') -GO_BUILD=$(GO) build -# Go module support: set `-mod=vendor` to use the vendored sources +# Go module support: set `-mod=vendor` to use the vendored sources. +# See also hack/make.sh. ifeq ($(shell go help mod >/dev/null 2>&1 && echo true), true) - GO_BUILD=GO111MODULE=on $(GO) build -mod=vendor + GO:=GO111MODULE=on $(GO) + MOD_VENDOR=-mod=vendor endif ifeq ($(DEBUG), 1) @@ -100,10 +101,10 @@ binary-static: cmd/skopeo # Build w/o using containers binary-local: - $(GPGME_ENV) $(GO_BUILD) ${GO_DYN_FLAGS} -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo + $(GPGME_ENV) $(GO) build $(MOD_VENDOR) ${GO_DYN_FLAGS} -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo binary-local-static: - $(GPGME_ENV) $(GO_BUILD) -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo + $(GPGME_ENV) $(GO) build $(MOD_VENDOR) -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo build-container: ${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" . @@ -152,8 +153,8 @@ test-integration: build-container # complicated set of options needed to run podman-in-podman test-system: build-container DTEMP=$(shell mktemp -d --tmpdir=/var/tmp podman-tmp.XXXXXX); \ - $(CONTAINER_CMD) --privileged --net=host \ - -v $$DTEMP:/var/lib/containers:Z \ + $(CONTAINER_CMD) --privileged \ + -v $$DTEMP:/var/lib/containers:Z -v /run/systemd/journal/socket:/run/systemd/journal/socket \ "$(IMAGE)" \ bash -c 'BUILDTAGS="$(BUILDTAGS)" hack/make.sh test-system'; \ rc=$$?; \ @@ -174,7 +175,7 @@ validate-local: hack/make.sh validate-git-marks validate-gofmt validate-lint validate-vet test-unit-local: - $(GPGME_ENV) $(GO) test -tags "$(BUILDTAGS)" $$($(GO) list -tags "$(BUILDTAGS)" -e ./... | grep -v '^github\.com/containers/skopeo/\(integration\|vendor/.*\)$$') + $(GPGME_ENV) $(GO) test $(MOD_VENDOR) -tags "$(BUILDTAGS)" $$($(GO) list $(MOD_VENDOR) -tags "$(BUILDTAGS)" -e ./... | grep -v '^github\.com/containers/skopeo/\(integration\|vendor/.*\)$$') vendor: export GO111MODULE=on \ diff --git a/hack/make.sh b/hack/make.sh index 622dbf2e..c1d881c7 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -57,7 +57,15 @@ DEFAULT_BUNDLES=( test-integration ) -TESTFLAGS+=" -test.timeout=10m" +TESTFLAGS+=" -test.timeout=15m" + +# Go module support: set `-mod=vendor` to use the vendored sources +# See also the top-level Makefile. +mod_vendor= +if go help mod >/dev/null 2>&1; then + export GO111MODULE=on + mod_vendor='-mod=vendor' +fi # If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. # You can use this to select certain tests to run, eg. @@ -72,10 +80,10 @@ TESTFLAGS+=" -test.timeout=10m" go_test_dir() { dir=$1 ( - echo '+ go test' $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} "${SKOPEO_PKG}${dir#.}" + echo '+ go test' $mod_vendor $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} "${SKOPEO_PKG}${dir#.}" cd "$dir" export DEST="$ABS_DEST" # we're in a subshell, so this is safe -- our integration-cli tests need DEST, and "cd" screws it up - go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} + go test $mod_vendor $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} ) } diff --git a/hack/make/validate-vet b/hack/make/validate-vet index f95d0fc8..05c01230 100755 --- a/hack/make/validate-vet +++ b/hack/make/validate-vet @@ -1,6 +1,6 @@ #!/bin/bash -errors=$(go vet $(go list -e ./... | grep -v "$SKOPEO_PKG"/vendor)) +errors=$(go vet $mod_vendor $(go list $mod_vendor -e ./...)) if [ -z "$errors" ]; then echo 'Congratulations! All Go source files have been vetted.' diff --git a/integration/copy_test.go b/integration/copy_test.go index 75327a79..0cef118d 100644 --- a/integration/copy_test.go +++ b/integration/copy_test.go @@ -27,7 +27,7 @@ func init() { const ( v2DockerRegistryURL = "localhost:5555" // Update also policy.json v2s1DockerRegistryURL = "localhost:5556" - knownWindowsOnlyImage = "docker://mcr.microsoft.com/windows/servercore:ltsc2019" + knownWindowsOnlyImage = "docker://mcr.microsoft.com/windows/nanoserver:1909" ) type CopySuite struct {