-
Notifications
You must be signed in to change notification settings - Fork 33
/
.travis.yml
88 lines (80 loc) · 3.63 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
---
sudo: required
language: python
services:
- docker
env:
global:
- role: weareinteractive.users
matrix:
- distribution: Ubuntu
distribution_version: "22.04"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y python openssh-client'"
- distribution: Ubuntu
distribution_version: "20.04"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y python openssh-client'"
- distribution: Ubuntu
distribution_version: "18.04"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y python openssh-client'"
- distribution: Ubuntu
distribution_version: "16.04"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y openssh-client'"
- distribution: Debian
distribution_version: "11"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y openssh-client'"
- distribution: Debian
distribution_version: "10"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y openssh-client'"
- distribution: Debian
distribution_version: "9"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y openssh-client'"
- distribution: Debian
distribution_version: "8"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'apt-get update && apt-get install -y openssh-client'"
- distribution: Centos
distribution_version: "7"
init: /lib/systemd/systemd
run_opts: "'--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro'"
before_test: "'yum makecache && yum install -y openssh-clients'"
before_install:
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- docker pull ansiblecheck/ansiblecheck:"${distribution,,}"-"${distribution_version}"
script:
- container_id=$(mktemp)
# Start The Built Container In The Background
- docker run -d -v "${PWD}":/etc/ansible/roles/${role}:ro ${run_opts} ansiblecheck/ansiblecheck:"${distribution,,}"-"${distribution_version}" "${init}" > "${container_id}"
# Print ansible version
- docker exec -t "$(cat ${container_id})" env TERM=xterm ansible --version
# Ansible syntax check.
- 'docker exec -t "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/${role}/tests/main.yml --syntax-check'
# Install dependencies
- docker exec -t "$(cat ${container_id})" env TERM=xterm sh -c "${before_test}"
# Test role.
- 'docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook /etc/ansible/roles/${role}/tests/main.yml'
# Test Idempotence
- idempotence=$(mktemp)
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/${role}/tests/main.yml | tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/