X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=travis%2Fexecute.sh;fp=travis%2Fexecute.sh;h=52e3d26c545b4086ea5df9023728545f78994cd2;hp=0000000000000000000000000000000000000000;hb=361865654f56f29af19d6d32d48278bbe838c2de;hpb=242470ab3c7a4b31e025eab3eb1b9d1fef874606 diff --git a/travis/execute.sh b/travis/execute.sh new file mode 100755 index 0000000..52e3d26 --- /dev/null +++ b/travis/execute.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -eu -o pipefail + +RELEASE="${RELEASE:-stretch}" +export RELEASE + +# run shellcheck tests +docker run koalaman/shellcheck:stable --version +docker run -v "$(pwd)":/code koalaman/shellcheck:stable -e SC2181 /code/chroot-script /code/grml-debootstrap + +# build Debian package +wget -O- https://travis.debian.net/script.sh | sh - + +if ! [ "${TRAVIS_DEBIAN_DISTRIBUTION:-}" = "unstable" ] ; then + echo "TRAVIS_DEBIAN_DISTRIBUTION is $TRAVIS_DEBIAN_DISTRIBUTION and not unstable, skipping VM build tests." + exit 0 +fi + +# copy only the binary from the TRAVIS_DEBIAN_INCREMENT_VERSION_NUMBER=true build +cp ../grml-debootstrap_*travis*deb . + +# we need to run in privileged mode to be able to use loop devices +docker run --privileged -v "$(pwd)":/code --rm -i -t debian:stretch /code/travis/build-vm.sh + +[ -x ./goss ] || curl -fsSL https://goss.rocks/install | GOSS_DST="$(pwd)" sh + +sudo apt-get update +sudo apt-get -y install qemu-system-x86 + +# sudo timeout --preserve-status --foreground 120 qemu-system-x86_64 -hda qemu.img -serial stdio -display none | tee -a qemu.log +sudo qemu-system-x86_64 -hda qemu.img -serial stdio -display none | tee -a qemu.log & + +timeout=120 +success=0 +while [ "$timeout" -gt 0 ]; do + ((timeout--)) + if ./goss --gossfile ./travis/goss.yaml validate --format nagios ; then + success=1 + sleep 1 + break + else + echo "Tests didn't pass YET, will retry again [$timeout retries left]" + sleep 1 + fi +done + +if [ "$success" = "1" ] ; then + echo "All tests passed! (◕‿◕)" +else + echo "Reached timeout after $timeout seconds with failing tests. ¯\(º o)/¯ ☂" >&2 + echo "Latest test run results:" + ./goss --gossfile ./travis/goss.yaml validate + exit 1 +fi