forked from geerlingguy/drupal-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
139 lines (119 loc) · 5.03 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
135
136
137
138
139
---
services: docker
env:
global:
- CONFIG: tests/config.yml
MAKEFILE: example.drupal.make.yml
COMPOSERFILE: example.drupal.composer.json
HOSTNAME: drupalvm.dev
MACHINE_NAME: drupalvm
IP: 192.168.88.88
DRUPALVM_DIR: /var/www/drupalvm
DRUSH_BIN: drush
TEST_INSTALLED_EXTRAS: true
matrix:
# Defaults - Ubuntu 16.04.
- type: defaults
distro: ubuntu1604
init: /sbin/init
run_opts: "--privileged"
# Nginx and Drush make file test - Ubuntu 16.04.
- type: nginx-drush-make
distro: ubuntu1604
init: /sbin/init
run_opts: "--privileged"
local_config: tests/ubuntu-16-nginx.config.yml
config_dir: /var/www/drupalvm/config
# PostgreSQL - Ubuntu 16.04.
- type: postgresql
distro: ubuntu1604
init: /sbin/init
run_opts: "--privileged"
local_config: tests/ubuntu-16-postgresql.config.yml
config_dir: /var/www/drupalvm/config
DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/drush/drush/drush"
TEST_INSTALLED_EXTRAS: false
# Defaults - CentOS 7.
- type: centos
distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
before_install:
# Pull container.
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
# Install lint tools.
- 'gem install rubocop'
script:
# Run container in detached state and store the id.
- 'tmpfile=$(mktemp)'
- 'docker run --detach --volume="${PWD}":${DRUPALVM_DIR}/:rw ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${tmpfile}"'
- 'container_id=$(cat ${tmpfile})'
# Set hostname.
- 'docker exec ${container_id} hostname ${HOSTNAME}'
# Setup directories.
- 'docker exec ${container_id} mkdir -p ${DRUPALVM_DIR}/drupal'
# Setup config directory.
- '[[ ! -z "${config_dir}" ]] && docker exec ${container_id} mkdir -p ${config_dir} || true'
# Copy configuration files into place.
- 'docker exec ${container_id} cp ${DRUPALVM_DIR}/${CONFIG} ${config_dir:-$DRUPALVM_DIR}/config.yml'
- 'docker exec ${container_id} cp ${DRUPALVM_DIR}/${MAKEFILE} ${config_dir:-$DRUPALVM_DIR}/drupal.make.yml'
- 'docker exec ${container_id} cp ${DRUPALVM_DIR}/${COMPOSERFILE} ${config_dir:-$DRUPALVM_DIR}/drupal.composer.json'
# Override configuration variables.
- '[[ ! -z "${local_config}" ]] && docker exec ${container_id} bash -c "cp ${DRUPALVM_DIR}/${local_config} ${config_dir:-$DRUPALVM_DIR}/local.config.yml" || true'
# Vagrantfile syntax check.
- 'rubocop ./Vagrantfile --except LineLength,Eval,MutableConstant,BlockLength'
# Ansible syntax check.
- 'docker exec --tty ${container_id} env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml --syntax-check'
# Run the test setup playbook with ansible-playbook.
- 'docker exec --tty ${container_id} env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/tests/test-setup.yml'
# Run the playbook with ansible-playbook.
- >
if [ ! -z "${config_dir}" ]; then
docker exec --tty ${container_id} env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml --extra-vars="config_dir=${config_dir}";
else
docker exec --tty ${container_id} env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml;
fi
# Run integration tests.
- >
docker exec ${container_id} curl -s --header Host:${HOSTNAME} localhost
| grep -q '<title>Welcome to Drupal'
&& (echo 'Drupal install pass' && exit 0)
|| (echo 'Drupal install fail' && exit 1)
- >
if [ $TEST_INSTALLED_EXTRAS = true ]; then
docker exec ${container_id} curl -s --header Host:adminer.${HOSTNAME} localhost \
| grep -q '<title>Login - Adminer' \
&& (echo 'Adminer install pass' && exit 0) \
|| (echo 'Adminer install fail' && exit 1)
fi
- >
if [ $TEST_INSTALLED_EXTRAS = true ]; then
docker exec ${container_id} curl -s --header Host:pimpmylog.${HOSTNAME} localhost \
| grep -q '<title>Pimp my Log' \
&& (echo 'Pimp my Log install pass' && exit 0) \
|| (echo 'Pimp my Log install fail' && exit 1)
fi
- >
if [ $TEST_INSTALLED_EXTRAS = true ]; then
docker exec ${container_id} curl -s localhost:8025 \
| grep -q '<title>MailHog' \
&& (echo 'MailHog install pass' && exit 0) \
|| (echo 'MailHog install fail' && exit 1)
fi
- >
if [ $TEST_INSTALLED_EXTRAS = true ]; then
docker exec ${container_id} curl -sI --header Host:${HOSTNAME} localhost:81 \
| grep -q 'Via: .* varnish' \
&& (echo 'Varnish install pass' && exit 0) \
|| (echo 'Varnish install fail' && exit 1)
fi
- >
docker exec ${container_id} curl -s --header Host:${IP} localhost
| grep -q "<li>${IP} ${HOSTNAME}</li>"
&& (echo 'Dashboard install pass' && exit 0)
|| (echo 'Dashboard install fail' && exit 1)
- >
docker exec ${container_id} ${DRUSH_BIN} @${MACHINE_NAME}.${HOSTNAME} status
| grep -q 'Drupal bootstrap.*Successful'
&& (echo 'Drush install pass' && exit 0)
|| (echo 'Drush install fail' && exit 1)