.travis.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. sudo: required
  3. env:
  4. - distro: centos7
  5. init: /usr/lib/systemd/systemd
  6. run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
  7. - distro: ubuntu1604
  8. init: /lib/systemd/systemd
  9. run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
  10. - distro: ubuntu1404
  11. init: /sbin/init
  12. run_opts: ""
  13. - distro: ubuntu1204
  14. init: /sbin/init
  15. run_opts: ""
  16. services:
  17. - docker
  18. before_install:
  19. # Pull container
  20. - 'sudo docker pull geerlingguy/docker-${distro}-ansible:latest'
  21. script:
  22. - container_id=$(mktemp)
  23. # Run container in detached state.
  24. - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
  25. # Install dependencies.
  26. - 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
  27. # Ansible syntax check.
  28. - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
  29. # Test role.
  30. - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
  31. # Test role idempotence.
  32. - idempotence=$(mktemp)
  33. - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
  34. - >
  35. tail ${idempotence}
  36. | grep -q 'changed=0.*failed=0'
  37. && (echo 'Idempotence test: pass' && exit 0)
  38. || (echo 'Idempotence test: fail' && exit 1)
  39. # Check if we get an installation page.
  40. - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm curl http://localhost:3000/install'
  41. after_success:
  42. # Clean up.
  43. - 'sudo docker stop "$(cat ${container_id})"'
  44. notifications:
  45. webhooks: https://galaxy.ansible.com/api/v1/notifications/