-
Notifications
You must be signed in to change notification settings - Fork 3
/
.travis.yml
105 lines (88 loc) · 3.67 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
# This file provides integration with the Travis-CI.org build service.
---
version: ~> 1.0
# Strictly speaking, we don't really need to set a language as we are
# building inside containers, but this speeds build time by requesting
# a minimal host image (e.g., no need to install stuff we won't use).
# See: https://docs.travis-ci.com/user/languages/minimal-and-generic/
os: linux
language: shell
# We set the following environment variables in order to trigger one
# build per list item (one build for each OS distribution).
env:
- distro: debian9
# - distro: debian8
# - distro: ubuntu1804
# - distro: ubuntu1604
# - distro: centos7
# - distro: fedora27
# The above `env` list creates what Travis CI calls a build matrix.
# We can customize the settings for each job in the build matrix by
# specifying them explicitly. See:
# https://docs.travis-ci.com/user/customizing-the-build/
#jobs:
# allow_failures:
# - env: distro=debian8
# - env: distro=ubuntu1804
# - env: distro=ubuntu1604
# - env: distro=centos7
# - env: distro=fedora27
# Execute these commands before Travis starts its install phase.
# See https://docs.travis-ci.com/user/job-lifecycle/#the-job-lifecycle
#before_install:
# Set up Travis's build environment for our project with these steps.
install:
# Ensure IPv6 NetFilter kernel module is loaded.
# (Travis removed this by default at some point.)
- sudo modprobe ip6table_filter
- docker pull geerlingguy/docker-${distro}-ansible
- container_id=$(mktemp)
# Run container, passing the USER environment variable manually set
# to the root user, since the project looks up the current user.
- >
docker run --detach --privileged -e USER=root
--publish 80:80
--volume /sys/fs/cgroup:/sys/fs/cgroup:ro
--volume "${PWD}":/tmp/build
geerlingguy/docker-${distro}-ansible:latest > "${container_id}"
# Set up the container itself to run our tests.
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook /tmp/build/tests/setup.yaml
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-galaxy install -r /tmp/build/requirements.yaml
# Run these commands in sequence (a "script") to test our project.
# Each command listed must return an exit code of `0` for the build,
# in its entirety, to be considered successful. Otherwise, it fails.
script:
# Perform a basic syntax check of all loaded Ansible playbook code.
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook --syntax-check /tmp/build/tests/travis.yaml
# Run the test playbook to ensure Ansible completes successfully.
- >
docker exec --tty "$(cat ${container_id})" env TERM=xterm
ansible-playbook /tmp/build/tests/travis.yaml
# Run the test playbook again to ensure playbook idempotence.
- idempotence=$(mktemp)
- >
docker exec "$(cat ${container_id})"
ansible-playbook /tmp/build/tests/travis.yaml
| tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Make HTTP requests to ensure the playbook is actually functional.
- curl http://localhost/ # Make sure landing page is available.
# from outside the container.
- >
docker exec "$(cat ${container_id})" env TERM=xterm
nc -z localhost 8080 # Make sure Calibre server is running.
# Politely clean up after ourselves. These commands won't affect the
# build status but will still be run regardless of success or failure.
# See https://docs.travis-ci.com/user/job-lifecycle/#breaking-the-build
after_script:
- docker rm -f "$(cat ${container_id})"