This repository was archived by the owner on Feb 13, 2023. It is now read-only.
-
- Notifications
You must be signed in to change notification settings - Fork 634
Use Docker-based Travis CI tests for multi-platform support #412
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits Select commit Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a nice, simple change :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit worried of how to override these sort of things at first. Then I just tried to see what happens if you re-declare a YAML variable with a different value 😄 No errors!