This repository has been archived by the owner on Feb 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #412 from oxyc/tests
Use Docker-based Travis CI tests for multi-platform support
- Loading branch information
Showing
10 changed files
with
196 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,104 @@ | ||
--- | ||
language: python | ||
python: "2.7" | ||
sudo: required | ||
|
||
install: | ||
# Install Ansible. | ||
- pip install ansible | ||
env: | ||
global: | ||
- CONFIG: example.config.yml | ||
MAKEFILE: example.drupal.make.yml | ||
HOSTNAME: drupalvm.dev | ||
MACHINE_NAME: drupalvm | ||
matrix: | ||
- distribution: centos | ||
version: 6 | ||
init: /sbin/init | ||
run_opts: "--privileged" | ||
additional_vars: "centos-6-vars.yml" | ||
- distribution: centos | ||
version: 7 | ||
init: /usr/lib/systemd/systemd | ||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" | ||
additional_vars: "centos-7-vars.yml" | ||
# - distribution: ubuntu | ||
# version: 14.04 | ||
# init: /sbin/init | ||
# run_opts: "--privileged" | ||
# - distribution: ubuntu | ||
# version: 12.04 | ||
# init: /sbin/init | ||
# run_opts: "--privileged" | ||
|
||
# Add ansible.cfg to set local roles path. | ||
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg" | ||
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' | ||
|
||
script: | ||
# Copy example files into place. | ||
- cp example.config.yml config.yml | ||
- cp example.drupal.make.yml drupal.make.yml | ||
- container_id=$(mktemp) | ||
|
||
# Run container in detached state | ||
- 'sudo docker run --detach --volume="${PWD}":/var/www/drupalvm/: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 /var/www/drupalvm/drupal' | ||
|
||
# Install dependencies. | ||
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /var/www/drupalvm/provisioning/requirements.yml' | ||
|
||
# Make sure Ansible requirements install correctly. | ||
- 'ansible-galaxy install -r provisioning/requirements.yml' | ||
# Copy configuration files into place. | ||
- 'sudo docker exec "$(cat ${container_id})" cp /var/www/drupalvm/$CONFIG /var/www/drupalvm/config.yml' | ||
- 'sudo docker exec "$(cat ${container_id})" cp /var/www/drupalvm/$MAKEFILE /var/www/drupalvm/drupal.make.yml' | ||
|
||
# Run Ansible's syntax and playbook check on the main playbook. | ||
- 'ansible-playbook -i "localhost," -c local provisioning/playbook.yml --syntax-check' | ||
# Append additional variables if set. | ||
- '[[ $additional_vars ]] && sudo docker exec "$(cat ${container_id})" bash -c "cat /var/www/drupalvm/tests/${additional_vars} >> /var/www/drupalvm/config.yml" || true' | ||
|
||
# Check the config file and drupal make file YAML syntax. | ||
# Ansible syntax check. | ||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /var/www/drupalvm/provisioning/playbook.yml --syntax-check' | ||
|
||
# Run the playbook with ansible-playbook. | ||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /var/www/drupalvm/provisioning/playbook.yml' | ||
|
||
# Run the integration tests | ||
- > | ||
python -c "import yaml; yaml.load( open('example.config.yml', 'r'), Loader=yaml.CLoader )" | ||
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) | ||
- > | ||
python -c "import yaml; yaml.load( open('example.drupal.make.yml', 'r'), Loader=yaml.CLoader )" | ||
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})" 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})"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM centos:6 | ||
|
||
# Install Ansible | ||
RUN yum -y update; yum clean all; | ||
RUN yum -y install epel-release | ||
RUN yum -y install git ansible sudo which curl tar unzip xz logrotate | ||
RUN yum clean all | ||
|
||
# Disable requiretty | ||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers | ||
|
||
# Install Ansible inventory file | ||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts | ||
|
||
CMD ["/usr/sbin/init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM centos:7 | ||
|
||
# Install systemd -- See https://hub.docker.com/_/centos/ | ||
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs | ||
RUN yum -y update; yum clean all; \ | ||
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ | ||
rm -f /lib/systemd/system/multi-user.target.wants/*; \ | ||
rm -f /etc/systemd/system/*.wants/*; \ | ||
rm -f /lib/systemd/system/local-fs.target.wants/*; \ | ||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ | ||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ | ||
rm -f /lib/systemd/system/basic.target.wants/*; \ | ||
rm -f /lib/systemd/system/anaconda.target.wants/*; | ||
|
||
# Install Ansible | ||
RUN yum -y install epel-release | ||
RUN yum -y install git ansible sudo which curl tar unzip xz logrotate initscripts | ||
RUN yum clean all | ||
|
||
# Disable requiretty | ||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers | ||
|
||
# Install Ansible inventory file | ||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts | ||
|
||
VOLUME ["/sys/fs/cgroup"] | ||
CMD ["/usr/sbin/init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM ubuntu:12.04 | ||
RUN apt-get update | ||
|
||
# Install Ansible | ||
RUN apt-get install -y software-properties-common python-software-properties git | ||
RUN apt-add-repository -y ppa:ansible/ansible | ||
RUN apt-get update | ||
RUN apt-get install -y ansible ufw curl | ||
|
||
# Install Ansible inventory file | ||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM ubuntu:14.04 | ||
RUN apt-get update | ||
|
||
# Install Ansible | ||
RUN apt-get install -y software-properties-common git | ||
RUN apt-add-repository -y ppa:ansible/ansible | ||
RUN apt-get update | ||
RUN apt-get install -y ansible ufw curl | ||
|
||
# Install Ansible inventory file | ||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
drupalvm_webserver: nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
mysql_packages: | ||
- mariadb | ||
- mariadb-server | ||
- mariadb-libs | ||
- MySQL-python | ||
- perl-DBD-MySQL | ||
mysql_daemon: mariadb | ||
mysql_log_error: /var/log/mariadb/mariadb.log | ||
mysql_syslog_tag: mariadb | ||
mysql_pid_file: /var/run/mariadb/mariadb.pid |