forked from geerlingguy/ansible-role-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
88 lines (75 loc) · 3.24 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
services: docker
env:
# Package install on all OSes.
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
ruby_version: 2.0.0
ruby_path_prefix: /usr
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
ruby_version: 2.3.1
ruby_path_prefix: /usr
- distro: ubuntu1404
init: /sbin/init
run_opts: ""
playbook: test.yml
ruby_version: 1.9.3
ruby_path_prefix: /usr
- distro: debian8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
ruby_version: 2.1.5
ruby_path_prefix: /usr
# Source install on latest OSes.
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test-source.yml
ruby_version: 2.3.0
ruby_path_prefix: /usr/local
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test-source.yml
ruby_version: 2.3.0
ruby_path_prefix: /usr/local
before_install:
# Pull container.
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
script:
- container_id=$(mktemp)
# Run container in detached state.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
# Install dependencies.
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
# Ansible syntax check.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
# Test role.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}'
# Test role idempotence.
- idempotence=$(mktemp)
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} | tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Make sure ruby is installed and at the correct version.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which ruby'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm test -x ${ruby_path_prefix}/bin/ruby'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ruby --version'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ${ruby_path_prefix}/bin/ruby --version | grep -qF ${ruby_version}'
# Make sure bundler is installed.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ls -lah /usr/local/bin'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which bundle'
after_failure:
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which ruby'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ruby --version'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/