-
Notifications
You must be signed in to change notification settings - Fork 53
/
.travis.yml
134 lines (128 loc) · 3.77 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# .travis.yml http://bertvv.github.io/notes-to-self/2015/12/13/testing-ansible-roles-with-travis-ci-part-2-multi-platform-tests/
---
sudo: required
env:
- >
distribution=ubuntu
version=14.04
extra_vars="php_fpm_version=5.6"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts=""
- >
distribution=ubuntu
version=14.04
extra_vars="php_fpm_version=7.0"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts=""
- >
distribution=ubuntu
version=14.04
extra_vars="php_fpm_version=7.1"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts=""
- >
distribution=ubuntu
version=16.04
extra_vars="php_fpm_version=5.6"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts="--privileged"
- >
distribution=ubuntu
version=16.04
extra_vars="php_fpm_version=7.0"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts="--privileged"
- >
distribution=ubuntu
version=16.04
extra_vars="php_fpm_version=7.1"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts="--privileged"
- >
distribution=debian
version=8
extra_vars="php_fpm_version=5.6"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts="--privileged"
- >
distribution=debian
version=8
extra_vars="php_fpm_version=7.0"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts="--privileged"
- >
distribution=debian
version=8
extra_vars="php_fpm_version=7.1"
container_id=$(mktemp)
init=/sbin/init
build_args=""
run_opts="--privileged"
- >
distribution=debian
version=9
extra_vars="php_fpm_version=5.6"
container_id=$(mktemp)
init=/sbin/init
build_args="--build-arg additional_packages=systemd-sysv"
run_opts="--privileged"
- >
distribution=debian
version=9
extra_vars="php_fpm_version=7.0"
container_id=$(mktemp)
init=/sbin/init
build_args="--build-arg additional_packages=systemd-sysv"
run_opts="--privileged"
- >
distribution=debian
version=9
extra_vars="php_fpm_version=7.1"
container_id=$(mktemp)
init=/sbin/init
build_args="--build-arg additional_packages=systemd-sysv"
run_opts="--privileged"
services:
- docker
before_install:
- sudo apt-get update
# Install latest Docker version to support ARG before FROM
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# Pull container
- sudo docker pull ${distribution}:${version}
# Customize container
- docker version
- sudo docker build --rm=true --file=tests/Dockerfile --build-arg image=${distribution}:${version} ${build_args} --tag=${distribution}-${version}:ansible tests
script:
# Run container in detached state
- sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" >> "${container_id}"
# Syntax check
- sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --extra-vars "${extra_vars}" --syntax-check
# Test role
- sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --extra-vars "${extra_vars}"
# Idempotence test
- >
sudo docker exec "$(cat ${container_id})" ansible-playbook "/etc/ansible/roles/role_under_test/tests/test.yml" --extra-vars "${extra_vars}"
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Clean up
- sudo docker stop "$(cat ${container_id})"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/