forked from geerlingguy/drupal-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
124 lines (102 loc) · 4.62 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
---
sudo: required
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
matrix:
- distribution: ubuntu
version: 16.04
init: /sbin/init
run_opts: "--privileged"
- distribution: ubuntu
version: 16.04
init: /sbin/init
run_opts: "--privileged"
local_config: tests/ubuntu-16-nginx.config.yml
config_dir: /var/www/drupalvm/config
- distribution: centos
version: 7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
services:
- docker
before_install:
# Pull container
- 'sudo docker pull ${distribution}:${version}'
# Customize container
- 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
# Install lint tools.
- 'gem install rubocop'
script:
- container_id=$(mktemp)
# Run container in detached state
- 'sudo docker run --detach --volume="${PWD}":${DRUPALVM_DIR}/:rw ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
# Set hostname.
- 'sudo docker exec "$(cat ${container_id})" hostname ${HOSTNAME}'
# Setup directories.
- 'sudo docker exec "$(cat ${container_id})" mkdir -p ${DRUPALVM_DIR}/drupal'
# Install dependencies.
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r ${DRUPALVM_DIR}/provisioning/requirements.yml'
# Setup config directory.
- '[[ ! -z "${config_dir}" ]] && sudo docker exec "$(cat ${container_id})" mkdir -p ${config_dir} || true'
# Copy configuration files into place.
- 'sudo docker exec "$(cat ${container_id})" cp ${DRUPALVM_DIR}/${CONFIG} ${config_dir:-$DRUPALVM_DIR}/config.yml'
- 'sudo docker exec "$(cat ${container_id})" cp ${DRUPALVM_DIR}/${MAKEFILE} ${config_dir:-$DRUPALVM_DIR}/drupal.make.yml'
- 'sudo docker exec "$(cat ${container_id})" cp ${DRUPALVM_DIR}/${COMPOSERFILE} ${config_dir:-$DRUPALVM_DIR}/drupal.composer.json'
# Override configuration variables.
- '[[ ! -z "${local_config}" ]] && sudo docker exec "$(cat ${container_id})" bash -c "cp ${DRUPALVM_DIR}/${local_config} ${config_dir:-$DRUPALVM_DIR}/local.config.yml" || true'
# Vagrantfile syntax check
- 'rubocop --except LineLength,Eval,MutableConstant'
# Ansible syntax check.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml --syntax-check'
# Run the playbook with ansible-playbook.
- >
if [ ! -z "${config_dir}" ]; then
sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml --extra-vars="config_dir=${config_dir}";
else
sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml;
fi
# Run the integration tests
- >
sudo docker exec "$(cat ${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)
- >
sudo docker exec "$(cat ${container_id})" curl -s --header Host:adminer.${HOSTNAME} localhost
| grep -q '<title>Login - Adminer'
&& (echo 'Admin install pass' && exit 0)
|| (echo 'Adminer install fail' && exit 1)
- >
sudo docker exec "$(cat ${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)
- >
sudo docker exec "$(cat ${container_id})" curl -s --header Host:xhprof.${HOSTNAME} localhost
| grep -q '<title>XHProf'
&& (echo 'XHProf install pass' && exit 0)
|| (echo 'XHProf install fail' && exit 1)
- >
sudo docker exec "$(cat ${container_id})" curl -s localhost:8025
| grep -q '<title>MailHog'
&& (echo 'MailHog install pass' && exit 0)
|| (echo 'MailHog install fail' && exit 1)
- >
sudo docker exec "$(cat ${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)
- >
sudo docker exec "$(cat ${container_id})" drush @${MACHINE_NAME}.${HOSTNAME} status
| grep -q 'Drupal bootstrap.*Successful'
&& (echo 'Drush install pass' && exit 0)
|| (echo 'Drush install fail' && exit 1)
# Clean up
- 'sudo docker stop "$(cat ${container_id})"'