mirror of
https://github.com/containers/skopeo.git
synced 2025-07-07 19:59:32 +00:00
Cirrus: Run checks directly on the host
In order to meet achievable deadlines converting from Travis to Cirrus CI, one significant artifact was carried forward (instead of fixing): Depending on a `--privileged` container to execute all/most automated checks/tests. Prior attempts to remove this aspect resulted in several test failures. Fixing the problems was viewed as more time-consuming than simply preserving this runtime environment. Time has passed, and the code has since moved on. This commit removes the legacy need to execute CI operations in a `--privileged` container, instead running them directly on the host. At the same time, the necessary test binaries are obtained from the same container used for development/local testing purposes. This ensures the two experiences are virtually always identical. Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
parent
3e127edb9c
commit
ab87b15fea
12
.cirrus.yml
12
.cirrus.yml
@ -29,7 +29,7 @@ env:
|
|||||||
PRIOR_UBUNTU_NAME: "ubuntu-2010"
|
PRIOR_UBUNTU_NAME: "ubuntu-2010"
|
||||||
|
|
||||||
# Google-cloud VM Images
|
# Google-cloud VM Images
|
||||||
IMAGE_SUFFIX: "c6248193773010944"
|
IMAGE_SUFFIX: "c6724387953967104"
|
||||||
FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}"
|
FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}"
|
||||||
PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}"
|
PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}"
|
||||||
UBUNTU_CACHE_IMAGE_NAME: "ubuntu-${IMAGE_SUFFIX}"
|
UBUNTU_CACHE_IMAGE_NAME: "ubuntu-${IMAGE_SUFFIX}"
|
||||||
@ -41,8 +41,8 @@ env:
|
|||||||
UBUNTU_CONTAINER_FQIN: "quay.io/libpod/ubuntu_podman:${IMAGE_SUFFIX}"
|
UBUNTU_CONTAINER_FQIN: "quay.io/libpod/ubuntu_podman:${IMAGE_SUFFIX}"
|
||||||
PRIOR_UBUNTU_CONTAINER_FQIN: "quay.io/libpod/prior-ubuntu_podman:${IMAGE_SUFFIX}"
|
PRIOR_UBUNTU_CONTAINER_FQIN: "quay.io/libpod/prior-ubuntu_podman:${IMAGE_SUFFIX}"
|
||||||
|
|
||||||
# Equivilent to image produced by 'make build-container'
|
# Built along with the standard PR-based workflow in c/automation_images
|
||||||
SKOPEO_CI_CONTAINER_FQIN: "quay.io/skopeo/ci:${DEST_BRANCH}"
|
SKOPEO_CIDEV_CONTAINER_FQIN: "quay.io/libpod/skopeo_cidev:${IMAGE_SUFFIX}"
|
||||||
|
|
||||||
|
|
||||||
# Default timeout for each task
|
# Default timeout for each task
|
||||||
@ -57,8 +57,8 @@ validate_task:
|
|||||||
# under Cirrus-CI, due to challenges obtaining the starting commit ID.
|
# under Cirrus-CI, due to challenges obtaining the starting commit ID.
|
||||||
# Only do validation for PRs.
|
# Only do validation for PRs.
|
||||||
only_if: $CIRRUS_PR != ''
|
only_if: $CIRRUS_PR != ''
|
||||||
container: &build_container
|
container:
|
||||||
image: "${SKOPEO_CI_CONTAINER_FQIN}"
|
image: '${SKOPEO_CIDEV_CONTAINER_FQIN}'
|
||||||
cpu: 4
|
cpu: 4
|
||||||
memory: 8
|
memory: 8
|
||||||
script: |
|
script: |
|
||||||
@ -145,7 +145,7 @@ test_skopeo_task:
|
|||||||
disk: 200
|
disk: 200
|
||||||
image_name: ${FEDORA_CACHE_IMAGE_NAME}
|
image_name: ${FEDORA_CACHE_IMAGE_NAME}
|
||||||
matrix:
|
matrix:
|
||||||
- name: "Skopeo Test"
|
- name: "Skopeo Test" # N/B: Name ref. by hack/get_fqin.sh
|
||||||
env:
|
env:
|
||||||
BUILDTAGS: 'btrfs_noversion libdm_no_deferred_remove'
|
BUILDTAGS: 'btrfs_noversion libdm_no_deferred_remove'
|
||||||
- name: "Skopeo Test w/ opengpg"
|
- name: "Skopeo Test w/ opengpg"
|
||||||
|
56
Dockerfile
56
Dockerfile
@ -1,56 +0,0 @@
|
|||||||
FROM registry.fedoraproject.org/fedora:latest
|
|
||||||
|
|
||||||
RUN dnf -y update && dnf install -y make git golang golang-github-cpuguy83-md2man \
|
|
||||||
# storage deps
|
|
||||||
btrfs-progs-devel \
|
|
||||||
device-mapper-devel \
|
|
||||||
# gpgme bindings deps
|
|
||||||
libassuan-devel gpgme-devel \
|
|
||||||
gnupg \
|
|
||||||
# htpasswd for system tests
|
|
||||||
httpd-tools \
|
|
||||||
# OpenShift deps
|
|
||||||
which tar wget hostname util-linux bsdtar socat ethtool device-mapper iptables tree findutils nmap-ncat e2fsprogs xfsprogs lsof docker iproute \
|
|
||||||
bats jq podman runc \
|
|
||||||
golint \
|
|
||||||
openssl \
|
|
||||||
&& dnf clean all
|
|
||||||
|
|
||||||
# Install two versions of the registry. The first is an older version that
|
|
||||||
# only supports schema1 manifests. The second is a newer version that supports
|
|
||||||
# both. This allows integration-cli tests to cover push/pull with both schema1
|
|
||||||
# and schema2 manifests.
|
|
||||||
RUN set -x \
|
|
||||||
&& export GO111MODULE=off \
|
|
||||||
&& REGISTRY_COMMIT_SCHEMA1=ec87e9b6971d831f0eff752ddb54fb64693e51cd \
|
|
||||||
&& REGISTRY_COMMIT=47a064d4195a9b56133891bbb13620c3ac83a827 \
|
|
||||||
&& export GOPATH="$(mktemp -d)" \
|
|
||||||
&& git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \
|
|
||||||
&& (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \
|
|
||||||
&& GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
|
|
||||||
go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \
|
|
||||||
&& (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1") \
|
|
||||||
&& GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
|
|
||||||
go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry \
|
|
||||||
&& rm -rf "$GOPATH"
|
|
||||||
|
|
||||||
RUN set -x \
|
|
||||||
&& export GO111MODULE=off \
|
|
||||||
&& export GOPATH=$(mktemp -d) \
|
|
||||||
&& git clone --depth 1 -b v1.5.0-alpha.3 git://github.com/openshift/origin "$GOPATH/src/github.com/openshift/origin" \
|
|
||||||
# The sed edits out a "go < 1.5" check which works incorrectly with go ≥ 1.10. \
|
|
||||||
&& sed -i -e 's/\[\[ "\${go_version\[2]}" < "go1.5" ]]/false/' "$GOPATH/src/github.com/openshift/origin/hack/common.sh" \
|
|
||||||
&& (cd "$GOPATH/src/github.com/openshift/origin" && make clean build && make all WHAT=cmd/dockerregistry) \
|
|
||||||
&& cp -a "$GOPATH/src/github.com/openshift/origin/_output/local/bin/linux"/*/* /usr/local/bin \
|
|
||||||
&& cp "$GOPATH/src/github.com/openshift/origin/images/dockerregistry/config.yml" /atomic-registry-config.yml \
|
|
||||||
&& rm -rf "$GOPATH" \
|
|
||||||
&& mkdir /registry
|
|
||||||
|
|
||||||
ENV GOPATH /usr/share/gocode:/go
|
|
||||||
ENV PATH $GOPATH/bin:/usr/share/gocode/bin:$PATH
|
|
||||||
ENV container_magic 85531765-346b-4316-bdb8-358e4cca9e5d
|
|
||||||
RUN go version
|
|
||||||
WORKDIR /go/src/github.com/containers/skopeo
|
|
||||||
COPY . /go/src/github.com/containers/skopeo
|
|
||||||
|
|
||||||
#ENTRYPOINT ["hack/dind"]
|
|
@ -1,12 +0,0 @@
|
|||||||
FROM registry.fedoraproject.org/fedora:33
|
|
||||||
|
|
||||||
RUN dnf update -y && \
|
|
||||||
dnf install -y \
|
|
||||||
btrfs-progs-devel \
|
|
||||||
device-mapper-devel \
|
|
||||||
golang \
|
|
||||||
gpgme-devel \
|
|
||||||
make
|
|
||||||
|
|
||||||
ENV GOPATH=/
|
|
||||||
WORKDIR /src/github.com/containers/skopeo
|
|
96
Makefile
96
Makefile
@ -1,4 +1,4 @@
|
|||||||
.PHONY: all binary build-container docs docs-in-container build-local clean install install-binary install-completions shell test-integration .install.vndr vendor vendor-in-container
|
.PHONY: all binary docs docs-in-container build-local clean install install-binary install-completions shell test-integration .install.vndr vendor vendor-in-container
|
||||||
|
|
||||||
export GOPROXY=https://proxy.golang.org
|
export GOPROXY=https://proxy.golang.org
|
||||||
|
|
||||||
@ -29,12 +29,10 @@ ifeq ($(GOBIN),)
|
|||||||
GOBIN := $(GOPATH)/bin
|
GOBIN := $(GOPATH)/bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Required for integration-tests to detect they are running inside a specific
|
# Multiple scripts are sensitive to this value, make sure it's exported/available
|
||||||
# container image. Env. var defined in image, make does not automatically
|
# N/B: Need to use 'command -v' here for compatibility with MacOS.
|
||||||
# pass to children unless explicitly exported
|
export CONTAINER_RUNTIME ?= $(if $(shell command -v podman),podman,docker)
|
||||||
export container_magic
|
GOMD2MAN ?= $(if $(shell command -v go-md2man),go-md2man,$(GOBIN)/go-md2man)
|
||||||
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
|
|
||||||
GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man')
|
|
||||||
|
|
||||||
# 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.
|
# See also hack/make.sh.
|
||||||
@ -54,9 +52,32 @@ ifeq ($(GOOS), linux)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||||
IMAGE := skopeo-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
|
|
||||||
# set env like gobuildtag?
|
# If $TESTFLAGS is set, it is passed as extra arguments to 'go test'.
|
||||||
CONTAINER_CMD := ${CONTAINER_RUNTIME} run --rm -i -e TESTFLAGS="$(TESTFLAGS)" #$(CONTAINER_ENVS)
|
# You can increase test output verbosity with the option '-test.vv'.
|
||||||
|
# You can select certain tests to run, with `-test.run <regex>` for example:
|
||||||
|
#
|
||||||
|
# make test-unit TESTFLAGS='-test.run ^TestManifestDigest$'
|
||||||
|
#
|
||||||
|
# For integration test, we use [gocheck](https://labix.org/gocheck).
|
||||||
|
# You can increase test output verbosity with the option '-check.vv'.
|
||||||
|
# You can limit test selection with `-check.f <regex>`, for example:
|
||||||
|
#
|
||||||
|
# make test-integration TESTFLAGS='-check.f CopySuite.TestCopy.*'
|
||||||
|
export TESTFLAGS ?= -v -check.v -test.timeout=15m
|
||||||
|
|
||||||
|
# This is assumed to be set non-empty when operating inside a CI/automation environment
|
||||||
|
CI ?=
|
||||||
|
|
||||||
|
# This env. var. is interpreted by some tests as a permission to
|
||||||
|
# modify local configuration files and services.
|
||||||
|
export SKOPEO_CONTAINER_TESTS ?= $(if $(CI),1,0)
|
||||||
|
|
||||||
|
# This is a compromise, we either use a container for this or require
|
||||||
|
# the local user to have a compatible python3 development environment.
|
||||||
|
# Define it as a "resolve on use" variable to avoid calling out when possible
|
||||||
|
SKOPEO_CIDEV_CONTAINER_FQIN ?= $(shell hack/get_fqin.sh)
|
||||||
|
CONTAINER_CMD ?= ${CONTAINER_RUNTIME} run --rm -i -e TESTFLAGS="$(TESTFLAGS)" -e CI=$(CI) -e SKOPEO_CONTAINER_TESTS=1
|
||||||
# if this session isn't interactive, then we don't want to allocate a
|
# if this session isn't interactive, then we don't want to allocate a
|
||||||
# TTY, which would fail, but if it is interactive, we do want to attach
|
# TTY, which would fail, but if it is interactive, we do want to attach
|
||||||
# so that the user can send e.g. ^C through.
|
# so that the user can send e.g. ^C through.
|
||||||
@ -64,7 +85,8 @@ INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
|
|||||||
ifeq ($(INTERACTIVE), 1)
|
ifeq ($(INTERACTIVE), 1)
|
||||||
CONTAINER_CMD += -t
|
CONTAINER_CMD += -t
|
||||||
endif
|
endif
|
||||||
CONTAINER_RUN := $(CONTAINER_CMD) "$(IMAGE)"
|
CONTAINER_GOSRC = /src/github.com/containers/skopeo
|
||||||
|
CONTAINER_RUN ?= $(CONTAINER_CMD) --security-opt label=disable -v $(CURDIR):$(CONTAINER_GOSRC) -w $(CONTAINER_GOSRC) $(SKOPEO_CIDEV_CONTAINER_FQIN)
|
||||||
|
|
||||||
GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)
|
GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)
|
||||||
|
|
||||||
@ -105,12 +127,9 @@ help:
|
|||||||
@echo " * 'shell' - Run the built image and attach to a shell"
|
@echo " * 'shell' - Run the built image and attach to a shell"
|
||||||
@echo " * 'clean' - Clean artifacts"
|
@echo " * 'clean' - Clean artifacts"
|
||||||
|
|
||||||
# Build a container image (skopeobuild) that has everything we need to build.
|
# Do the build and the output (skopeo) should appear in current dir
|
||||||
# Then do the build and the output (skopeo) should appear in current dir
|
|
||||||
binary: cmd/skopeo
|
binary: cmd/skopeo
|
||||||
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage .
|
$(CONTAINER_RUN) make bin/skopeo $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'
|
||||||
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/src/github.com/containers/skopeo \
|
|
||||||
skopeobuildimage make bin/skopeo $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'
|
|
||||||
|
|
||||||
# Update nix/nixpkgs.json its latest stable commit
|
# Update nix/nixpkgs.json its latest stable commit
|
||||||
.PHONY: nixpkgs
|
.PHONY: nixpkgs
|
||||||
@ -136,18 +155,13 @@ bin/skopeo.%:
|
|||||||
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build $(MOD_VENDOR) ${SKOPEO_LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo
|
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build $(MOD_VENDOR) ${SKOPEO_LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo
|
||||||
local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64 bin/skopeo.windows.386.exe bin/skopeo.windows.amd64.exe
|
local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64 bin/skopeo.windows.386.exe bin/skopeo.windows.amd64.exe
|
||||||
|
|
||||||
build-container:
|
|
||||||
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" .
|
|
||||||
|
|
||||||
$(MANPAGES): %: %.md
|
$(MANPAGES): %: %.md
|
||||||
sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@
|
sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@
|
||||||
|
|
||||||
docs: $(MANPAGES)
|
docs: $(MANPAGES)
|
||||||
|
|
||||||
docs-in-container:
|
docs-in-container:
|
||||||
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile.build -t skopeobuildimage .
|
${CONTAINER_RUN} $(MAKE) docs $(if $(DEBUG),DEBUG=$(DEBUG))
|
||||||
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/src/github.com/containers/skopeo \
|
|
||||||
skopeobuildimage make docs $(if $(DEBUG),DEBUG=$(DEBUG)) BUILDTAGS='$(BUILDTAGS)'
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin docs/*.1
|
rm -rf bin docs/*.1
|
||||||
@ -171,40 +185,42 @@ install-completions:
|
|||||||
install -m 755 -d ${DESTDIR}${BASHCOMPLETIONSDIR}
|
install -m 755 -d ${DESTDIR}${BASHCOMPLETIONSDIR}
|
||||||
install -m 644 completions/bash/skopeo ${DESTDIR}${BASHCOMPLETIONSDIR}/skopeo
|
install -m 644 completions/bash/skopeo ${DESTDIR}${BASHCOMPLETIONSDIR}/skopeo
|
||||||
|
|
||||||
shell: build-container
|
shell:
|
||||||
$(CONTAINER_RUN) bash
|
$(CONTAINER_RUN) bash
|
||||||
|
|
||||||
check: validate test-unit test-integration test-system
|
check: validate test-unit test-integration test-system
|
||||||
|
|
||||||
# The tests can run out of entropy and block in containers, so replace /dev/random.
|
test-integration:
|
||||||
test-integration: build-container
|
$(CONTAINER_RUN) $(MAKE) test-integration-local
|
||||||
$(CONTAINER_RUN) bash -c 'rm -f /dev/random; ln -sf /dev/urandom /dev/random; SKOPEO_CONTAINER_TESTS=1 BUILDTAGS="$(BUILDTAGS)" $(MAKE) test-integration-local'
|
|
||||||
|
|
||||||
# Intended for CI, shortcut 'build-container' since already running inside container.
|
|
||||||
test-integration-local:
|
# Intended for CI, assumed to be running in quay.io/libpod/skopeo_cidev container.
|
||||||
|
test-integration-local: bin/skopeo
|
||||||
hack/make.sh test-integration
|
hack/make.sh test-integration
|
||||||
|
|
||||||
# complicated set of options needed to run podman-in-podman
|
# complicated set of options needed to run podman-in-podman
|
||||||
test-system: build-container
|
# TODO: The $(RM) command will likely fail w/o `podman unshare`
|
||||||
|
test-system:
|
||||||
DTEMP=$(shell mktemp -d --tmpdir=/var/tmp podman-tmp.XXXXXX); \
|
DTEMP=$(shell mktemp -d --tmpdir=/var/tmp podman-tmp.XXXXXX); \
|
||||||
$(CONTAINER_CMD) --privileged \
|
$(CONTAINER_CMD) --privileged \
|
||||||
|
-v $(CURDIR):$(CONTAINER_GOSRC) -w $(CONTAINER_GOSRC) \
|
||||||
-v $$DTEMP:/var/lib/containers:Z -v /run/systemd/journal/socket:/run/systemd/journal/socket \
|
-v $$DTEMP:/var/lib/containers:Z -v /run/systemd/journal/socket:/run/systemd/journal/socket \
|
||||||
"$(IMAGE)" \
|
"$(SKOPEO_CIDEV_CONTAINER_FQIN)" \
|
||||||
bash -c 'BUILDTAGS="$(BUILDTAGS)" $(MAKE) test-system-local'; \
|
$(MAKE) test-system-local; \
|
||||||
rc=$$?; \
|
rc=$$?; \
|
||||||
$(RM) -rf $$DTEMP; \
|
-$(RM) -rf $$DTEMP; \
|
||||||
exit $$rc
|
exit $$rc
|
||||||
|
|
||||||
# Intended for CI, shortcut 'build-container' since already running inside container.
|
# Intended for CI, assumed to already be running in quay.io/libpod/skopeo_cidev container.
|
||||||
test-system-local:
|
test-system-local: bin/skopeo
|
||||||
hack/make.sh test-system
|
hack/make.sh test-system
|
||||||
|
|
||||||
test-unit: build-container
|
test-unit:
|
||||||
# Just call (make test unit-local) here instead of worrying about environment differences
|
# Just call (make test unit-local) here instead of worrying about environment differences
|
||||||
$(CONTAINER_RUN) make test-unit-local BUILDTAGS='$(BUILDTAGS)'
|
$(CONTAINER_RUN) $(MAKE) test-unit-local
|
||||||
|
|
||||||
validate: build-container
|
validate:
|
||||||
$(CONTAINER_RUN) make validate-local
|
$(CONTAINER_RUN) $(MAKE) validate-local
|
||||||
|
|
||||||
# This target is only intended for development, e.g. executing it from an IDE. Use (make test) for CI or pre-release testing.
|
# This target is only intended for development, e.g. executing it from an IDE. Use (make test) for CI or pre-release testing.
|
||||||
test-all-local: validate-local validate-docs test-unit-local
|
test-all-local: validate-local validate-docs test-unit-local
|
||||||
@ -219,7 +235,7 @@ validate-docs:
|
|||||||
hack/man-page-checker
|
hack/man-page-checker
|
||||||
hack/xref-helpmsgs-manpages
|
hack/xref-helpmsgs-manpages
|
||||||
|
|
||||||
test-unit-local:
|
test-unit-local: bin/skopeo
|
||||||
$(GPGME_ENV) $(GO) test $(MOD_VENDOR) -tags "$(BUILDTAGS)" $$($(GO) list $(MOD_VENDOR) -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:
|
vendor:
|
||||||
@ -228,4 +244,4 @@ vendor:
|
|||||||
$(GO) mod verify
|
$(GO) mod verify
|
||||||
|
|
||||||
vendor-in-container:
|
vendor-in-container:
|
||||||
podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.16 make vendor
|
podman run --privileged --rm --env HOME=/root -v $(CURDIR):/src -w /src quay.io/libpod/golang:1.16 $(MAKE) vendor
|
||||||
|
@ -6,6 +6,19 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# BEGIN Global export of all variables
|
||||||
|
set -a
|
||||||
|
|
||||||
|
# Due to differences across platforms and runtime execution environments,
|
||||||
|
# handling of the (otherwise) default shell setup is non-uniform. Rather
|
||||||
|
# than attempt to workaround differences, simply force-load/set required
|
||||||
|
# items every time this library is utilized.
|
||||||
|
USER="$(whoami)"
|
||||||
|
HOME="$(getent passwd $USER | cut -d : -f 6)"
|
||||||
|
# Some platforms set and make this read-only
|
||||||
|
[[ -n "$UID" ]] || \
|
||||||
|
UID=$(getent passwd $USER | cut -d : -f 3)
|
||||||
|
|
||||||
if [[ -r "/etc/automation_environment" ]]; then
|
if [[ -r "/etc/automation_environment" ]]; then
|
||||||
source /etc/automation_environment
|
source /etc/automation_environment
|
||||||
source $AUTOMATION_LIB_PATH/common_lib.sh
|
source $AUTOMATION_LIB_PATH/common_lib.sh
|
||||||
@ -23,42 +36,78 @@ OS_RELEASE_VER="$(source /etc/os-release; echo $VERSION_ID | tr -d '.')"
|
|||||||
# Combined to ease some usage
|
# Combined to ease some usage
|
||||||
OS_REL_VER="${OS_RELEASE_ID}-${OS_RELEASE_VER}"
|
OS_REL_VER="${OS_RELEASE_ID}-${OS_RELEASE_VER}"
|
||||||
|
|
||||||
export "PATH=$PATH:$GOPATH/bin"
|
# This is the magic interpreted by the tests to allow modifying local config/services.
|
||||||
|
SKOPEO_CONTAINER_TESTS=1
|
||||||
|
|
||||||
|
PATH=$PATH:$GOPATH/bin
|
||||||
|
|
||||||
|
# END Global export of all variables
|
||||||
|
set +a
|
||||||
|
|
||||||
podmanmake() {
|
|
||||||
req_env_vars GOPATH SKOPEO_PATH SKOPEO_CI_CONTAINER_FQIN
|
|
||||||
warn "Accumulated technical-debt requires execution inside a --privileged container. This is very likely hiding bugs!"
|
|
||||||
showrun podman run -it --rm --privileged \
|
|
||||||
-e GOPATH=$GOPATH \
|
|
||||||
-v $GOPATH:$GOPATH:Z \
|
|
||||||
-w $SKOPEO_PATH \
|
|
||||||
$SKOPEO_CI_CONTAINER_FQIN \
|
|
||||||
make "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
_run_setup() {
|
_run_setup() {
|
||||||
if [[ "$OS_RELEASE_ID" == "fedora" ]]; then
|
local mnt
|
||||||
# This is required as part of the standard Fedora VM setup
|
local errmsg
|
||||||
|
req_env_vars SKOPEO_CIDEV_CONTAINER_FQIN
|
||||||
|
if [[ "$OS_RELEASE_ID" != "fedora" ]]; then
|
||||||
|
die "Unknown/unsupported distro. $OS_REL_VER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -r "/.ci_setup_complete" ]]; then
|
||||||
|
warn "Thwarted an attempt to execute setup more than once."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This is required as part of the standard Fedora GCE VM setup
|
||||||
growpart /dev/sda 1
|
growpart /dev/sda 1
|
||||||
resize2fs /dev/sda1
|
resize2fs /dev/sda1
|
||||||
|
|
||||||
# VM's come with the distro. skopeo pre-installed
|
# VM's come with the distro. skopeo package pre-installed
|
||||||
dnf erase -y skopeo
|
dnf erase -y skopeo
|
||||||
else
|
|
||||||
die "Unknown/unsupported distro. $OS_REL_VER"
|
# A slew of compiled binaries are pre-built and distributed
|
||||||
|
# within the CI/Dev container image, but we want to run
|
||||||
|
# things directly on the host VM. Fortunately they're all
|
||||||
|
# located in the container under /usr/local/bin
|
||||||
|
msg "Accessing contents of $SKOPEO_CIDEV_CONTAINER_FQIN"
|
||||||
|
podman pull --quiet $SKOPEO_CIDEV_CONTAINER_FQIN
|
||||||
|
mnt=$(podman mount $(podman create $SKOPEO_CIDEV_CONTAINER_FQIN))
|
||||||
|
|
||||||
|
# The container and VM images are built in tandem in the same repo.
|
||||||
|
# automation, but the sources are in different directories. It's
|
||||||
|
# possible for a mismatch to happen, but should (hopefully) be unlikely.
|
||||||
|
# Double-check to make sure.
|
||||||
|
if ! fgrep -qx "ID=$OS_RELEASE_ID" $mnt/etc/os-release || \
|
||||||
|
! fgrep -qx "VERSION_ID=$OS_RELEASE_VER" $mnt/etc/os-release; then
|
||||||
|
die "Somehow $SKOPEO_CIDEV_CONTAINER_FQIN is not based on $OS_REL_VER."
|
||||||
fi
|
fi
|
||||||
|
msg "Copying test binaries from $SKOPEO_CIDEV_CONTAINER_FQIN /usr/local/bin/"
|
||||||
|
cp -a "$mnt/usr/local/bin/"* "/usr/local/bin/"
|
||||||
|
msg "Configuring the openshift registry"
|
||||||
|
|
||||||
|
# TODO: Put directory & yaml into more sensible place + update integration tests
|
||||||
|
mkdir -vp /registry
|
||||||
|
cp -a "$mnt/atomic-registry-config.yml" /
|
||||||
|
|
||||||
|
msg "Cleaning up"
|
||||||
|
podman umount --latest
|
||||||
|
podman rm --latest
|
||||||
|
|
||||||
|
# Ensure setup can only run once
|
||||||
|
touch "/.ci_setup_complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
_run_vendor() {
|
_run_vendor() {
|
||||||
podmanmake vendor BUILDTAGS="$BUILDTAGS"
|
make vendor BUILDTAGS="$BUILDTAGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
_run_build() {
|
_run_build() {
|
||||||
make bin/skopeo BUILDTAGS="$BUILDTAGS"
|
make bin/skopeo BUILDTAGS="$BUILDTAGS"
|
||||||
|
make install PREFIX=/usr/local
|
||||||
}
|
}
|
||||||
|
|
||||||
_run_cross() {
|
_run_cross() {
|
||||||
podmanmake local-cross BUILDTAGS="$BUILDTAGS"
|
make local-cross BUILDTAGS="$BUILDTAGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
_run_doccheck() {
|
_run_doccheck() {
|
||||||
@ -66,18 +115,22 @@ _run_doccheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_run_unit() {
|
_run_unit() {
|
||||||
podmanmake test-unit-local BUILDTAGS="$BUILDTAGS"
|
make test-unit-local BUILDTAGS="$BUILDTAGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
_run_integration() {
|
_run_integration() {
|
||||||
podmanmake test-integration-local BUILDTAGS="$BUILDTAGS"
|
# Ensure we start with a clean-slate
|
||||||
|
podman system reset --force
|
||||||
|
|
||||||
|
make test-integration-local BUILDTAGS="$BUILDTAGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
_run_system() {
|
_run_system() {
|
||||||
# Ensure we start with a clean-slate
|
# Ensure we start with a clean-slate
|
||||||
podman system reset --force
|
podman system reset --force
|
||||||
|
|
||||||
# Executes with containers required for testing.
|
# Executes with containers required for testing.
|
||||||
showrun make test-system-local BUILDTAGS="$BUILDTAGS"
|
make test-system-local BUILDTAGS="$BUILDTAGS"
|
||||||
}
|
}
|
||||||
|
|
||||||
req_env_vars SKOPEO_PATH BUILDTAGS
|
req_env_vars SKOPEO_PATH BUILDTAGS
|
||||||
|
34
hack/get_fqin.sh
Executable file
34
hack/get_fqin.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This script is intended to be called from the Makefile. It's purpose
|
||||||
|
# is to automation correspondence between the environment used for local
|
||||||
|
# development and CI.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_FILEPATH=$(realpath "${BASH_SOURCE[0]}")
|
||||||
|
SCRIPT_DIRPATH=$(dirname "$SCRIPT_FILEPATH")
|
||||||
|
REPO_DIRPATH=$(realpath "$SCRIPT_DIRPATH/../")
|
||||||
|
|
||||||
|
# When running under CI, we already have the necessary information,
|
||||||
|
# simply provide it to the Makefile.
|
||||||
|
if [[ -n "$SKOPEO_CIDEV_CONTAINER_FQIN" ]]; then
|
||||||
|
echo "$SKOPEO_CIDEV_CONTAINER_FQIN"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $(command -v podman) ]]; then CONTAINER_RUNTIME=podman; fi
|
||||||
|
CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-docker}
|
||||||
|
|
||||||
|
# Borrow the get_ci_vm container image since it's small, and
|
||||||
|
# by necessity contains a script that can accurately interpret
|
||||||
|
# env. var. values from any .cirrus.yml runtime context.
|
||||||
|
$CONTAINER_RUNTIME run --rm \
|
||||||
|
--security-opt label=disable \
|
||||||
|
-v $REPO_DIRPATH:/src:ro \
|
||||||
|
--entrypoint=/usr/share/automation/bin/cirrus-ci_env.py \
|
||||||
|
quay.io/libpod/get_ci_vm:latest \
|
||||||
|
--envs="Skopeo Test" /src/.cirrus.yml | \
|
||||||
|
egrep -m1 '^SKOPEO_CIDEV_CONTAINER_FQIN' | \
|
||||||
|
awk -F "=" -e '{print $2}' | \
|
||||||
|
tr -d \'\"
|
47
hack/make.sh
47
hack/make.sh
@ -2,15 +2,14 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# This script builds various binary from a checkout of the skopeo
|
# This script builds various binary from a checkout of the skopeo
|
||||||
# source code.
|
# source code. DO NOT CALL THIS SCRIPT DIRECTLY.
|
||||||
#
|
#
|
||||||
# Requirements:
|
# Requirements:
|
||||||
# - The current directory should be a checkout of the skopeo source code
|
# - The current directory should be a checkout of the skopeo source code
|
||||||
# (https://github.com/containers/skopeo). Whatever version is checked out
|
# (https://github.com/containers/skopeo). Whatever version is checked out
|
||||||
# will be built.
|
# will be built.
|
||||||
# - The script is intended to be run inside the docker container specified
|
# - The script is intended to be run inside the container specified
|
||||||
# in the Dockerfile at the root of the source. In other words:
|
# in the output of hack/get_fqin.sh
|
||||||
# DO NOT CALL THIS SCRIPT DIRECTLY.
|
|
||||||
# - The right way to call this script is to invoke "make" from
|
# - The right way to call this script is to invoke "make" from
|
||||||
# your checkout of the skopeo repository.
|
# your checkout of the skopeo repository.
|
||||||
# the Makefile will do a "docker build -t skopeo ." and then
|
# the Makefile will do a "docker build -t skopeo ." and then
|
||||||
@ -23,21 +22,19 @@ export SKOPEO_PKG='github.com/containers/skopeo'
|
|||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
export MAKEDIR="$SCRIPTDIR/make"
|
export MAKEDIR="$SCRIPTDIR/make"
|
||||||
|
|
||||||
# We're a nice, sexy, little shell script, and people might try to run us;
|
# Set this to 1 to enable installation/modification of environment/services
|
||||||
# but really, they shouldn't. We want to be in a container!
|
export SKOPEO_CONTAINER_TESTS=${SKOPEO_CONTAINER_TESTS:-0}
|
||||||
# The magic value is defined inside our Dockerfile.
|
|
||||||
if [[ "$container_magic" != "85531765-346b-4316-bdb8-358e4cca9e5d" ]]; then
|
if [[ "$SKOPEO_CONTAINER_TESTS" == "0" ]] && [[ "$CI" != "true" ]]; then
|
||||||
{
|
(
|
||||||
echo "# WARNING! I don't seem to be running in a Docker container."
|
echo "***************************************************************"
|
||||||
echo "# The result of this command might be an incorrect build, and will not be"
|
echo "WARNING: Executing tests directly on the local development"
|
||||||
echo "# officially supported."
|
echo " host is highly discourraged. Many important items"
|
||||||
echo "#"
|
echo " will be skipped. For manual execution, please utilize"
|
||||||
echo "# Try this instead: make all"
|
echo " the Makefile targets WITHOUT the '-local' suffix."
|
||||||
echo "#"
|
echo "***************************************************************"
|
||||||
} >&2
|
) > /dev/stderr
|
||||||
else
|
sleep 5s
|
||||||
echo "# I appear to be running inside my designated container image, good!"
|
|
||||||
export SKOPEO_CONTAINER_TESTS=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@ -56,8 +53,6 @@ DEFAULT_BUNDLES=(
|
|||||||
test-integration
|
test-integration
|
||||||
)
|
)
|
||||||
|
|
||||||
TESTFLAGS+=" -test.timeout=15m"
|
|
||||||
|
|
||||||
# Go module support: set `-mod=vendor` to use the vendored sources
|
# Go module support: set `-mod=vendor` to use the vendored sources
|
||||||
# See also the top-level Makefile.
|
# See also the top-level Makefile.
|
||||||
mod_vendor=
|
mod_vendor=
|
||||||
@ -66,16 +61,6 @@ if go help mod >/dev/null 2>&1; then
|
|||||||
mod_vendor='-mod=vendor'
|
mod_vendor='-mod=vendor'
|
||||||
fi
|
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.
|
|
||||||
#
|
|
||||||
# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit
|
|
||||||
#
|
|
||||||
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
|
|
||||||
# to run certain tests on your local host, you should run with command:
|
|
||||||
#
|
|
||||||
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli
|
|
||||||
#
|
|
||||||
go_test_dir() {
|
go_test_dir() {
|
||||||
dir=$1
|
dir=$1
|
||||||
(
|
(
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
bundle_test_integration() {
|
bundle_test_integration() {
|
||||||
TESTFLAGS="$TESTFLAGS -check.v"
|
|
||||||
go_test_dir ./integration
|
go_test_dir ./integration
|
||||||
}
|
}
|
||||||
|
|
||||||
# subshell so that we can export PATH without breaking other things
|
# subshell so that we can export PATH without breaking other things
|
||||||
(
|
(
|
||||||
make bin/skopeo ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"}
|
|
||||||
make PREFIX=/usr install
|
make PREFIX=/usr install
|
||||||
bundle_test_integration
|
bundle_test_integration
|
||||||
) 2>&1
|
) 2>&1
|
||||||
|
@ -11,7 +11,6 @@ sed -i \
|
|||||||
/etc/containers/storage.conf
|
/etc/containers/storage.conf
|
||||||
|
|
||||||
# Build skopeo, install into /usr/bin
|
# Build skopeo, install into /usr/bin
|
||||||
make bin/skopeo ${BUILDTAGS:+BUILDTAGS="$BUILDTAGS"}
|
|
||||||
make PREFIX=/usr install
|
make PREFIX=/usr install
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
|
Loading…
Reference in New Issue
Block a user