Skip to content

Commit

Permalink
fixup! Add CI test for build-push image
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Dec 10, 2021
1 parent 18fe1ed commit 13d9b49
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ test_build-push_task:
env:
TEST_FQIN: quay.io/buildah/do_not_use
# Robot account credentials for test-push to $TEST_FQIN
BUILDAH_USERNAME: TODO:ENCRYPTED[FIXME]
BUILDAH_PASSWORD: TODO:ENCRYPTED[FIXME]
BUILDAH_USERNAME: ENCRYPTED[92b5976239bc4cd86736238bdd612848d7d5a4e1cc8ff8176de03f123fad23074401290fa0004b627ff7b15eeaff50dd]
BUILDAH_PASSWORD: ENCRYPTED[b63475150caf6e08d32e9ed0478e60f9de660a075f14e6327934353e2f23c3bf8508fb5bb7fb04f0e87b18e30fafc75b]
script: bash ./build-push/test.sh


Expand Down
54 changes: 40 additions & 14 deletions build-push/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,50 @@
# `test_build-push` task. It is not intended to be used otherwise
# and may cause harm.
set -e
SCRIPT_DIRPATH=$(dirname ${BASH_SOURCE[0]})
SCRIPT_DIRPATH=$(dirname $(realpath "${BASH_SOURCE[0]}"))
source $SCRIPT_DIRPATH/../lib.sh

req_env_vars CIRRUS_CI TEST_FQIN BUILDAH_USERNAME

set +e

# Architectures to test with (golang standard names)
TESTARCHES="amd64 ppc64le s390x"
# Prevent test images generated by this CI run interfearing with others
FAKE_VERSION=$RANDOM
# Embedded script to discard implied 'latest' in favor of $FAKE_VERSION
MODCMD="set -ex;
podman tag \$FQIN:latest \$FQIN:$FAKE_VERSION;
podman manifest rm \$FQIN:latest;"
TESTTMP=$(mktemp -p '' -d build-push-test-XXXX)
# shellcheck disable=SC2154
build-push.sh \
--arches=amd64,s390x,arm64,ppc64le \
$TEST_FQIN \
$SCRIPT_DIRPATH/test_context
bp_ret=$?
_DNFARCH="dnf --installroot=$TESTTMP --setopt=ignorearch=true --releasever=$OS_RELEASE_VER --setopt=cachedir=$TESTTMP/var/cache/dnf -q -y --setopt=arch="
PREPCMD="set -ex;
for arch in $TESTARCHES; do
${_DNFARCH}\$arch makecache;
${_DNFARCH}\$arch --downloadonly install iputils;
done
"

# FIXME: Confirm the result & remove the test image
cleanup(){
set +e
msg "Cleaning up"
showrun rm -rf "$TESTTMP"
# shellcheck disable=SC2154
showrun skopeo delete docker://$TEST_FQIN:$FAKE_VERSION
}
trap "cleanup" EXIT

# Note: local arch (amd64) is implied
msg "Building ping test multiarch container image '$TEST_FQIN' (in debug mode)"
env DEBUG=1 build-push.sh \
--arches=s390x,ppc64le \
--prepcmd="$PREPCMD" \
--modcmd="$MODCMD" \
$TEST_FQIN \
$SCRIPT_DIRPATH/test_context \
--build-arg BASE_TAG=$OS_RELEASE_VER \
--volume $TESTTMP/var/cache/dnf:/var/cache/dnf:O

if ((bp_ret)); then
msg "PASS"
else
die "FAIL"
fi
msg "Testing ping container for each arch"
for arch in $TESTARCHES; do
showrun podman run -i --rm --arch=$arch $TEST_FQIN:$FAKE_VERSION ping -q -c 3 8.8.4.4
done
3 changes: 3 additions & 0 deletions build-push/test_context/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARG BASE_TAG
FROM registry.fedoraproject.org/fedora:$BASE_TAG
RUN dnf install -y iputils

0 comments on commit 13d9b49

Please sign in to comment.