diff --git a/.gitignore b/.gitignore index 71b747b..2dbb4d0 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ ChangeLog # Files created by releasenotes build releasenotes/build + +# Vagrant testing artifacts +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..d09fc56 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,13 @@ +Vagrant.configure(2) do |config| + config.vm.box = "ubuntu/trusty64" + config.vm.provider "virtualbox" do |v| + v.memory = 2048 + v.cpus = 2 + end + config.vm.provision "shell", inline: <<-SHELL + sudo su - + cd /vagrant + apt-get update + ./run_tests.sh + SHELL +end \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh index 2e24671..0362a71 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -15,24 +15,29 @@ set -euov -ROLE_NAME=$(basename $(pwd)) FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true} -pushd tests - ansible-galaxy install \ - --role-file=ansible-role-requirements.yml \ - --ignore-errors \ - --force +# prep the host +if [ "$(which apt-get)" ]; then + apt-get install -y build-essential python2.7 python-dev git-core libssl-dev +fi - ansible-playbook -i inventory \ - --syntax-check \ - --list-tasks \ - -e "rolename=${ROLE_NAME}" \ - test.yml +# get pip, if necessary +if [ ! "$(which pip)" ]; then + curl --silent --show-error --retry 5 \ + https://bootstrap.pypa.io/get-pip.py | sudo python2.7 +fi - ansible-lint test.yml +# install tox +pip install tox - if ${FUNCTIONAL_TEST}; then - ansible-playbook -i inventory -e "rolename=${ROLE_NAME}" test.yml +# run through each tox env and execute the test +for tox_env in $(awk -F= '/envlist/ {print $2}' tox.ini | sed 's/,/ /g'); do + if [ "${tox_env}" != "functional" ]; then + tox -e ${tox_env} + elif [ "${tox_env}" == "functional" ]; then + if ${FUNCTIONAL_TEST}; then + tox -e ${tox_env} + fi fi -popd +done