#!/usr/bin/bash
# A thin wrapper for ansible-playbook which has a nice check for
# TEST_SUBJECTS being set.
set -xeuo pipefail

dn=$(cd $(dirname $0) && pwd)
if ! test -d build; then
    mkdir -p build
    (cd build && ${dn}/../../ci/build-rpm.sh)
fi

# https://fedoraproject.org/wiki/CI/Tests
if test -z "${TEST_SUBJECTS:-}"; then
    cat <<EOF

error: TEST_SUBJECTS must be set; e.g.:

  curl -Lo fedora-atomic-host.qcow2 'https://getfedora.org/atomic_qcow2_latest'
  export TEST_SUBJECTS=\$(pwd)/fedora-atomic-host.qcow2

If you're doing interactive development, we recommend caching the qcow2
somewhere persistent.
EOF
    exit 1
fi
for subj in ${TEST_SUBJECTS}; do
    ls -al ${subj} && file ${subj}
done

# This is required
rpm -q standard-test-roles

export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)}
ls -al /dev/kvm
# Sadly having this on makes the reboot playbook break
export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
exec ansible-playbook --tags=atomic "$@"

#!/usr/bin/bash
# A thin wrapper for ansible-playbook which has a nice check for
# TEST_SUBJECTS being set.
set -xeuo pipefail

dn=$(cd $(dirname $0) && pwd)
if ! test -d build; then
    mkdir -p build
    (cd build && ${dn}/../../ci/build-rpm.sh)
else
    # XXX: we should invalidate based on `git describe` or something
    echo "NOTE: Re-using prebuilt RPMs:"
    find build -name '*.rpm'
fi

# https://fedoraproject.org/wiki/CI/Tests
if test -z "${TEST_SUBJECTS:-}"; then
    cat <<EOF

error: TEST_SUBJECTS must be set; e.g.:

  curl -Lo fedora-atomic-host.qcow2 'https://getfedora.org/atomic_qcow2_latest'
  export TEST_SUBJECTS=\$(pwd)/fedora-atomic-host.qcow2

If you're doing interactive development, we recommend caching the qcow2
somewhere persistent.
EOF
    exit 1
fi
for subj in ${TEST_SUBJECTS}; do
    ls -al ${subj} && file ${subj}
done

# This is required
rpm -q standard-test-roles

export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)}
ls -al /dev/kvm
# Sadly having this on makes the reboot playbook break
export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
exec ansible-playbook --tags=atomic "$@"

Add NOTE when re-using RPMs
tests/installed: Add NOTE when re-using RPMs

One gotcha here is that we don't invalidate the RPMs if we're not
sitting on the same commit anymore. Shouldn't be too hard to fix, though
let's at least make a note of it for now.

Closes: #1668
Approved by: cgwalters
