@@ -4,88 +4,64 @@ services: docker
44env :
55 # Package install on all OSes.
66 - distro : centos7
7- init : /usr/lib/systemd/systemd
8- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
97 playbook : test.yml
108 ruby_version : 2.0.0
119 ruby_path_prefix : /usr
1210 - distro : ubuntu1604
13- init : /lib/systemd/systemd
14- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1511 playbook : test.yml
1612 ruby_version : 2.3.1
1713 ruby_path_prefix : /usr
1814 - distro : ubuntu1404
19- init : /sbin/init
20- run_opts : " "
2115 playbook : test.yml
2216 ruby_version : 1.9.3
2317 ruby_path_prefix : /usr
2418 - distro : debian8
25- init : /lib/systemd/systemd
26- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
2719 playbook : test.yml
2820 ruby_version : 2.1.5
2921 ruby_path_prefix : /usr
3022
3123 # Source install on latest OSes.
3224 - distro : centos7
33- init : /usr/lib/systemd/systemd
34- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
3525 playbook : test-source.yml
3626 ruby_version : 2.3.0
3727 ruby_path_prefix : /usr/local
3828 - distro : ubuntu1604
39- init : /lib/systemd/systemd
40- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
4129 playbook : test-source.yml
4230 ruby_version : 2.3.0
4331 ruby_path_prefix : /usr/local
4432
45- before_install :
46- # Pull container.
47- - ' docker pull geerlingguy/docker-${distro}-ansible:latest'
48-
4933script :
50- - container_id=$(mktemp)
51- # Run container in detached state.
52- - ' docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
53-
54- # Install dependencies.
55- - ' docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
56-
57- # Ansible syntax check.
58- - ' docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
34+ # Configure test script so we can run extra tests after playbook is run.
35+ - export container_id=$(date +%s)
36+ - export cleanup=false
5937
60- # Test role.
61- - ' docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}'
38+ # Download test shim.
39+ - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
40+ - chmod +x ${PWD}/tests/test.sh
6241
63- # Test role idempotence.
64- - idempotence=$(mktemp)
65- - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} | tee -a ${idempotence}
66- - >
67- tail ${idempotence}
68- | grep -q 'changed=0.*failed=0'
69- && (echo 'Idempotence test: pass' && exit 0)
70- || (echo 'Idempotence test: fail' && exit 1)
42+ # Run tests.
43+ - ${PWD}/tests/test.sh
7144
7245 # Make sure ruby is installed and at the correct version.
73- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm which ruby'
74- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm test -x ${ruby_path_prefix}/bin/ruby'
46+ - ' docker exec --tty $ {container_id} env TERM=xterm which ruby'
47+ - ' docker exec --tty $ {container_id} env TERM=xterm test -x ${ruby_path_prefix}/bin/ruby'
7548
76- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm ruby --version'
77- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm ${ruby_path_prefix}/bin/ruby --version | grep -qF ${ruby_version}'
49+ - ' docker exec --tty $ {container_id} env TERM=xterm ruby --version'
50+ - ' docker exec --tty $ {container_id} env TERM=xterm ${ruby_path_prefix}/bin/ruby --version | grep -qF ${ruby_version}'
7851
7952 # Make sure bundler is installed.
80- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm ls -lah /usr/local/bin'
81- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm which bundle'
53+ - ' docker exec --tty $ {container_id} env TERM=xterm ls -lah /usr/local/bin'
54+ - ' docker exec --tty $ {container_id} env TERM=xterm which bundle'
8255
8356 # Make sure user installed gems are available.
84- - ' docker exec --tty "$(cat ${container_id})" env TERM=xterm bash --login -c "which sass"'
57+ - |
58+ if [ "${distro}" != "ubuntu1404" ]; then
59+ docker exec --tty ${container_id} env TERM=xterm bash --login -c "which sass"
60+ fi
8561
8662after_failure :
87- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm which ruby'
88- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm ruby --version'
63+ - ' docker exec --tty $ {container_id} env TERM=xterm which ruby'
64+ - ' docker exec --tty $ {container_id} env TERM=xterm ruby --version'
8965
9066notifications :
9167 webhooks : https://galaxy.ansible.com/api/v1/notifications/
0 commit comments