-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
40 lines (35 loc) · 1.42 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
---
sudo: required
env:
- distribution: ubuntu
version: 14.04
init: /sbin/init
run_opts: ''
playbook: travis_test.yml
branches:
only:
- master
services:
- docker
before_install:
# Pull OS container
- 'sudo docker pull ${distribution}:${version}'
# Build customisations
- 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
script:
# Create container_id
- container_id=$(mktemp)
# Run container in detached mode
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
# Ansible syntax check
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
# Run role tests
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}'
# Run role idempotence tests
- >
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}
| grep -q 'unreachable=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Clean up
- sudo docker stop "$(cat ${container_id})"