forked from Frzk/ansible-role-nftables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
55 lines (47 loc) · 1.49 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
---
sudo: required
language: bash
services:
- docker
# Build matrix
env:
- distribution: centos
version: 7
- distribution: debian
version: 9
- distribution: ubuntu
version: 18.04
before_install:
# Pull the image corresponding to the environment vars from Docker Hub:
- docker pull "kblr/${distribution}${version}-ansible:latest"
script:
# 0/ Run the container:
- >
docker run
--name "${TRAVIS_COMMIT}.${distribution}-${version}"
--detach
--privileged
--mount type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly
--mount type=bind,source="$(pwd)",target=/etc/ansible/roles/under_test,readonly
"kblr/${distribution}${version}-ansible:latest"
# 1/ Check role syntax:
- >
docker exec "${TRAVIS_COMMIT}.${distribution}-${version}"
ansible-playbook -v /etc/ansible/roles/under_test/tests/test.yml --syntax-check
# 2/ Check first run:
- >
docker exec "${TRAVIS_COMMIT}.${distribution}-${version}"
ansible-playbook -v /etc/ansible/roles/under_test/tests/test.yml
# 3/ Check idempotence:
- >
docker exec "${TRAVIS_COMMIT}.${distribution}-${version}"
ansible-playbook -v /etc/ansible/roles/under_test/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
after_script:
# Remove container:
- docker rm -f "${TRAVIS_COMMIT}.${distribution}-${version}"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
...