diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index af7a1e022..96b493831 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,4 @@ # These are supported funding model platforms - +--- github: geerlingguy patreon: geerlingguy diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..71587e092 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,99 @@ +--- +name: CI +'on': + pull_request: + push: + branches: + - master + schedule: + - cron: "20 3 * * 0" + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Set up Ruby. + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6 + + - name: Install test dependencies. + run: | + pip3 install yamllint + gem install rubocop + + - name: Lint code. + run: | + yamllint . + rubocop ./Vagrantfile ./lib/drupalvm \ + --except Metrics/LineLength,Security/Eval,Style/MutableConstant,Metrics/BlockLength,Metrics/MethodLength,Style/ConditionalAssignment,Style/IfUnlessModifier,Style/CaseLikeIf + + molecule: + name: Molecule + runs-on: ubuntu-latest + strategy: + matrix: + include: + # Defaults. + - distro: ubuntu1804 + playbook: converge.yml + - distro: debian10 + playbook: converge.yml + - distro: centos8 + playbook: converge.yml + + # TODO: Add PHP 7.4 test. + # local_config: tests/ubuntu1804-php74.config.yml + # test_extras: false + # - distro: ubuntu1804 + # playbook: TODO + + # TODO: Add Postgresql test. + # local_config: tests/ubuntu1804-postgresql.config.yml + # config_dir: /var/www/drupalvm/config + # test_extras: false + # - distro: ubunt1804 + # playbook: TODO + + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies. + run: pip3 install ansible molecule[docker] docker + + # See: https://github.com/geerlingguy/ansible-role-mysql/issues/422 + - name: Disable AppArmor on Debian. + run: | + set -x + sudo apt-get install apparmor-profiles + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + if: ${{ startsWith(matrix.distro, 'debian') }} + + - name: Copy test scaffold files into place. + run: | + cp example.drupal.make.yml drupal.make.yml + cp example.drupal.composer.json drupal.composer.json + + - name: Run Molecule tests. + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + MOLECULE_DISTRO: ${{ matrix.distro }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3cf269a63..000000000 --- a/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- -language: php -php: 7.4 -services: docker - -branches: - only: - - master - -env: - global: - - CONFIG: tests/config.yml - MAKEFILE: example.drupal.make.yml - COMPOSERFILE: example.drupal.composer.json - HOSTNAME: drupalvm.test - MACHINE_NAME: drupalvm - IP: 192.168.88.88 - DRUPALVM_DIR: /var/www/drupalvm - DRUSH_BIN: drush - TEST_INSTALLED_EXTRAS: true - CONTAINER_ID: dvm-test - - matrix: - # Defaults - Ubuntu 18.04. - - type: defaults - distro: ubuntu1804 - # Defaults - Debian 10. - - type: debian - distro: debian10 - # Defaults - CentOS 8. - - type: centos - distro: centos8 - local_config: tests/centos-8.config.yml - - # PHP 7.3 - Ubuntu 18.04. - - type: defaults - distro: ubuntu1804 - local_config: tests/ubuntu-18-php73.config.yml - DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/bin/drush" - TEST_INSTALLED_EXTRAS: false - - # PostgreSQL - Ubuntu 18.04. - - type: postgresql - distro: ubuntu1804 - local_config: tests/ubuntu-18-postgresql.config.yml - DRUSH_BIN: "${DRUPALVM_DIR}/drupal/vendor/bin/drush" - config_dir: /var/www/drupalvm/config - TEST_INSTALLED_EXTRAS: false - -before_install: - # Install lint tools. - - gem install rubocop - -script: - # Vagrantfile syntax check. - - 'rubocop ./Vagrantfile ./lib/drupalvm --except Metrics/LineLength,Security/Eval,Style/MutableConstant,Metrics/BlockLength,Metrics/MethodLength,Style/ConditionalAssignment,Style/IfUnlessModifier,Style/CaseLikeIf' - - # Run tests. - - composer run-tests diff --git a/.yamllint b/.yamllint new file mode 100644 index 000000000..8fc434d23 --- /dev/null +++ b/.yamllint @@ -0,0 +1,18 @@ +--- +extends: default + +rules: + line-length: + max: 200 + level: warning + truthy: + allowed-values: ['true', 'false', 'yes', 'no'] + braces: + min-spaces-inside: 1 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + +ignore: | + */stale.yml + provisioning/roles/ diff --git a/README.md b/README.md index 8f61a9691..8384fe300 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Drupal VM Logo](https://raw.githubusercontent.com/geerlingguy/drupal-vm/master/docs/images/drupal-vm-logo.png) -[![Build Status](https://travis-ci.com/geerlingguy/drupal-vm.svg?branch=master)](https://travis-ci.com/geerlingguy/drupal-vm) [![Documentation Status](https://readthedocs.org/projects/drupal-vm/badge/?version=latest)](http://docs.drupalvm.com) [![Packagist](https://img.shields.io/packagist/v/geerlingguy/drupal-vm.svg)](https://packagist.org/packages/geerlingguy/drupal-vm) [![Docker Automated build](https://img.shields.io/docker/automated/geerlingguy/drupal-vm.svg?maxAge=2592000)](https://hub.docker.com/r/geerlingguy/drupal-vm/) [![](https://images.microbadger.com/badges/image/geerlingguy/drupal-vm.svg)](https://microbadger.com/images/geerlingguy/drupal-vm "Get your own image badge on microbadger.com") [![irc://irc.freenode.net/drupal-vm](https://img.shields.io/badge/irc.freenode.net-%23drupal--vm-brightgreen.svg)](https://riot.im/app/#/room/#drupal-vm:matrix.org) +[![CI](https://github.com/geerlingguy/drupal-vm/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/drupal-vm/actions?query=workflow%3ACI) [![Documentation Status](https://readthedocs.org/projects/drupal-vm/badge/?version=latest)](http://docs.drupalvm.com) [![Packagist](https://img.shields.io/packagist/v/geerlingguy/drupal-vm.svg)](https://packagist.org/packages/geerlingguy/drupal-vm) [![Docker Automated build](https://img.shields.io/docker/automated/geerlingguy/drupal-vm.svg?maxAge=2592000)](https://hub.docker.com/r/geerlingguy/drupal-vm/) [![](https://images.microbadger.com/badges/image/geerlingguy/drupal-vm.svg)](https://microbadger.com/images/geerlingguy/drupal-vm "Get your own image badge on microbadger.com") [![irc://irc.freenode.net/drupal-vm](https://img.shields.io/badge/irc.freenode.net-%23drupal--vm-brightgreen.svg)](https://riot.im/app/#/room/#drupal-vm:matrix.org) [Drupal VM](https://www.drupalvm.com/) is a VM for Drupal, built with Ansible. @@ -168,14 +168,13 @@ Drupal VM runs on almost any modern computer that can run VirtualBox and Vagrant ## Tests -To run basic integration tests using Docker: +To run basic integration tests using Docker and Molecule: 1. [Install Docker](https://docs.docker.com/engine/installation/). + 2. Install Molecule: `pip3 install ansible molecule[docker]` 2. In this project directory, run: `composer run-tests` -> Note: If you're on a Mac, you need to use [Docker's Edge release](https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac), at least until [this issue](https://github.com/docker/for-mac/issues/77) is resolved. - -The project's automated tests are run via Travis CI, and the more comprehensive test suite covers multiple Linux distributions and many different Drupal VM use cases and deployment techniques. +The project's automated tests are run via GitHub Actions, and the more comprehensive test suite covers multiple Linux distributions and many different Drupal VM use cases and deployment techniques. ## License diff --git a/composer.json b/composer.json index fae792f0a..f0a4ca336 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "process-timeout": 1800 }, "scripts": { - "run-tests": "./tests/run-tests.sh", + "run-tests": "molecule test", "docker-bake": "./provisioning/docker/bake.sh", "docker-save-image": "./provisioning/docker/save-image.sh", "docker-load-image": "./provisioning/docker/load-image.sh" diff --git a/default.config.yml b/default.config.yml index ba940f8fd..a82589518 100644 --- a/default.config.yml +++ b/default.config.yml @@ -95,7 +95,7 @@ drupal_major_version: 9 drupal_domain: "{{ vagrant_hostname }}" drupal_site_name: "Drupal" drupal_install_profile: standard -drupal_enable_modules: [ 'devel' ] +drupal_enable_modules: ['devel'] drupal_account_name: admin drupal_account_pass: admin @@ -285,7 +285,7 @@ composer_global_packages: [] # reference the directory where your `config.yml` is. pre_provision_scripts: [] post_provision_scripts: [] - # - "{{ playbook_dir }}/../examples/scripts/configure-solr.sh" +# - "{{ playbook_dir }}/../examples/scripts/configure-solr.sh" # MySQL Configuration. mysql_root_password: root diff --git a/example.docker-compose.yml b/example.docker-compose.yml index d11a14a43..75b0c34d6 100644 --- a/example.docker-compose.yml +++ b/example.docker-compose.yml @@ -1,3 +1,4 @@ +--- version: "3" services: diff --git a/mkdocs.yml b/mkdocs.yml index 1f2a3da0f..ba65b03f6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,3 +1,4 @@ +--- site_name: Drupal VM Documentation repo_url: https://github.com/geerlingguy/drupal-vm @@ -9,69 +10,69 @@ extra_javascript: markdown_extensions: - toc: - permalink: True + permalink: true pages: - Home: 'index.md' - Getting Started: - - Installation: - - 'macOS': 'getting-started/installation-macos.md' - - 'Windows': 'getting-started/installation-windows.md' - - 'Linux': 'getting-started/installation-linux.md' - - 'Configuring Drupal VM': 'getting-started/configure-drupalvm.md' - - 'Syncing Folders': 'getting-started/syncing-folders.md' + - Installation: + - 'macOS': 'getting-started/installation-macos.md' + - 'Windows': 'getting-started/installation-windows.md' + - 'Linux': 'getting-started/installation-linux.md' + - 'Configuring Drupal VM': 'getting-started/configure-drupalvm.md' + - 'Syncing Folders': 'getting-started/syncing-folders.md' - Building your codebase: - - 'Using a local Drupal codebase': 'deployment/local-codebase.md' - - 'Using a composer package': 'deployment/composer-package.md' - - 'Using composer.json': 'deployment/composer.md' - - 'Using a Drush Make file': 'deployment/drush-make.md' - - 'Drupal VM as a Composer Dependency': 'deployment/composer-dependency.md' - - 'Deploying Drupal via Git': 'deployment/git.md' + - 'Using a local Drupal codebase': 'deployment/local-codebase.md' + - 'Using a composer package': 'deployment/composer-package.md' + - 'Using composer.json': 'deployment/composer.md' + - 'Using a Drush Make file': 'deployment/drush-make.md' + - 'Drupal VM as a Composer Dependency': 'deployment/composer-dependency.md' + - 'Deploying Drupal via Git': 'deployment/git.md' - Basic configurations: - - 'Using different base OSes': 'configurations/base-os.md' - - 'Using a different PHP version': 'configurations/php.md' - - Webservers: - - 'Apache': 'configurations/webservers-apache.md' - - 'Nginx': 'configurations/webservers-nginx.md' - - Databases: - - 'Connect to the MySQL Database': 'configurations/databases-mysql.md' - - 'Use MariaDB instead of MySQL': 'configurations/databases-mariadb.md' - - 'Use PostgreSQL instead of MySQL': 'configurations/databases-postgresql.md' + - 'Using different base OSes': 'configurations/base-os.md' + - 'Using a different PHP version': 'configurations/php.md' + - Webservers: + - 'Apache': 'configurations/webservers-apache.md' + - 'Nginx': 'configurations/webservers-nginx.md' + - Databases: + - 'Connect to the MySQL Database': 'configurations/databases-mysql.md' + - 'Use MariaDB instead of MySQL': 'configurations/databases-mariadb.md' + - 'Use PostgreSQL instead of MySQL': 'configurations/databases-postgresql.md' - Installed extras: - - 'adminer (Database UI)': 'extras/adminer.md' - - 'blackfire (Profiling tool)': 'extras/blackfire.md' - - 'drupalconsole (Drupal CLI)': 'extras/drupal-console.md' - - 'drush (Drupal CLI)': 'extras/drush.md' - - 'elasticsearch (Search engine)': 'extras/elasticsearch.md' - - 'java': 'extras/java.md' - - 'mailhog (Mail catcher)': 'extras/mailhog.md' - - 'memcached (In-memory cache)': 'extras/memcached.md' - - 'newrelic (Performance monitoring)': 'extras/newrelic.md' - - 'nodejs': 'extras/nodejs.md' - - 'pimpmylog (Log viewer)': 'extras/pimpmylog.md' - - 'redis (In-memory database)': 'extras/redis.md' - - 'ruby': 'extras/ruby.md' - - 'selenium (BDD with Behat)': 'extras/selenium.md' - - 'solr (Search engine)': 'extras/solr.md' - - 'tideways (Profiling tool)': 'extras/tideways.md' - - 'upload-progress': 'extras/upload-progress.md' - - 'varnish (Caching reverse proxy)': 'extras/varnish.md' - - 'xdebug (Debugging tool)': 'extras/xdebug.md' - - 'xhprof (Profiling tool)': 'extras/xhprof.md' + - 'adminer (Database UI)': 'extras/adminer.md' + - 'blackfire (Profiling tool)': 'extras/blackfire.md' + - 'drupalconsole (Drupal CLI)': 'extras/drupal-console.md' + - 'drush (Drupal CLI)': 'extras/drush.md' + - 'elasticsearch (Search engine)': 'extras/elasticsearch.md' + - 'java': 'extras/java.md' + - 'mailhog (Mail catcher)': 'extras/mailhog.md' + - 'memcached (In-memory cache)': 'extras/memcached.md' + - 'newrelic (Performance monitoring)': 'extras/newrelic.md' + - 'nodejs': 'extras/nodejs.md' + - 'pimpmylog (Log viewer)': 'extras/pimpmylog.md' + - 'redis (In-memory database)': 'extras/redis.md' + - 'ruby': 'extras/ruby.md' + - 'selenium (BDD with Behat)': 'extras/selenium.md' + - 'solr (Search engine)': 'extras/solr.md' + - 'tideways (Profiling tool)': 'extras/tideways.md' + - 'upload-progress': 'extras/upload-progress.md' + - 'varnish (Caching reverse proxy)': 'extras/varnish.md' + - 'xdebug (Debugging tool)': 'extras/xdebug.md' + - 'xhprof (Profiling tool)': 'extras/xhprof.md' - Extending Drupal VM: - - 'Adding Vagrant plugins Vagrantfile.local': 'extending/vagrantfile.md' - - 'Passing on CLI arguments to ansible': 'extending/ansible-args.md' - - 'Pre- and Post-Provision Scripts': 'extending/scripts.md' + - 'Adding Vagrant plugins Vagrantfile.local': 'extending/vagrantfile.md' + - 'Passing on CLI arguments to ansible': 'extending/ansible-args.md' + - 'Pre- and Post-Provision Scripts': 'extending/scripts.md' - Other Information: - - 'Networking Notes': 'other/networking.md' - - 'Vagrant LXC provider': 'other/vagrant-lxc.md' - - 'Improving Performance': 'other/performance.md' - - 'Docker': 'other/docker.md' - - 'Custom Vagrant Base Box': 'other/custom-base-box.md' - - 'BigPipe with Drupal VM': 'other/bigpipe.md' - - 'Drupal multisite': 'deployment/multisite.md' - - 'Drupal 6 Notes': 'other/drupal-6.md' - - 'Drupal VM Management Tools': 'other/management-tools.md' - - 'Emulating Acquia Cloud environment': 'other/acquia.md' - - 'Deploying to a production environment': 'other/production.md' - - 'Wordpress or other applications': 'other/wordpress-other-applications.md' + - 'Networking Notes': 'other/networking.md' + - 'Vagrant LXC provider': 'other/vagrant-lxc.md' + - 'Improving Performance': 'other/performance.md' + - 'Docker': 'other/docker.md' + - 'Custom Vagrant Base Box': 'other/custom-base-box.md' + - 'BigPipe with Drupal VM': 'other/bigpipe.md' + - 'Drupal multisite': 'deployment/multisite.md' + - 'Drupal 6 Notes': 'other/drupal-6.md' + - 'Drupal VM Management Tools': 'other/management-tools.md' + - 'Emulating Acquia Cloud environment': 'other/acquia.md' + - 'Deploying to a production environment': 'other/production.md' + - 'Wordpress or other applications': 'other/wordpress-other-applications.md' diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 000000000..d4f2679e2 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,37 @@ +--- +- name: Converge + hosts: all + become: true + + tasks: + - name: Update apt cache. + apt: + update_cache: true + cache_valid_time: 1200 + when: ansible_os_family == 'Debian' + + - name: Install test dependencies (RedHat). + package: + name: logrotate + state: present + when: ansible_os_family == 'RedHat' + + - name: Configure override vars (all). + set_fact: + # Update the composer_home_path for global installs. + composer_home_path: "/root/.composer" + + # Don't run the 'disable firewall' tasks in tests. + firewall_disable_firewalld: false + firewall_disable_ufw: false + + # Added to prevent test failures in CI. + firewall_enable_ipv6: false + hostname_configure: false + + - name: Configure test vars (RedHat). + set_fact: + postfix_inet_protocols: ipv4 + when: ansible_os_family == 'RedHat' + +- import_playbook: ../../provisioning/playbook.yml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 000000000..04169a846 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,17 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1804}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true + pre_build_image: true +provisioner: + name: ansible + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} diff --git a/tests/ubuntu-18-php74.config.yml b/molecule/default/ubuntu1804-php74.config.yml similarity index 100% rename from tests/ubuntu-18-php74.config.yml rename to molecule/default/ubuntu1804-php74.config.yml diff --git a/tests/ubuntu-18-postgresql.config.yml b/molecule/default/ubuntu1804-postgresql.config.yml similarity index 100% rename from tests/ubuntu-18-postgresql.config.yml rename to molecule/default/ubuntu1804-postgresql.config.yml diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 000000000..732e1f964 --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,51 @@ +--- +- name: Verify + hosts: all + become: true + + vars: + drupal_vm_hostname: drupalvm.test + drupal_composer_install_dir: /var/www/drupalvm/drupal + + tasks: + - name: Validate web services are up and running. + uri: + url: http://localhost{{ item.port | default('') }} + headers: + Host: "{{ item.host_prefix }}{{ drupal_vm_hostname }}" + return_content: true + register: response + failed_when: item.expected_content not in response.content + with_items: + - name: Drupal + host_prefix: "" + expected_content: "Welcome to Drupal" + - name: Dashboard + host_prefix: "dashboard." + expected_content: "Vagrant + Ansible" + - name: Adminer + host_prefix: "adminer." + expected_content: "<title>Login - Adminer" + - name: Pimp My Log + host_prefix: "pimpmylog." + expected_content: "<title>Pimp my Log" + - name: MailHog + host_prefix: "" + port: ":8025" + expected_content: "<title>MailHog" + + - name: Validate Varnish is up and running. + uri: + url: http://localhost:81 + headers: + Host: "{{ drupal_vm_hostname }}" + register: varnish_response + failed_when: "'varnish' not in varnish_response.via" + + - name: Validate Drush is working with Drupal. + command: > + vendor/bin/drush status + chdir={{ drupal_composer_install_dir }} + register: drush_result + changed_when: false + failed_when: "'Drupal bootstrap : Successful' not in drush_result.stdout" diff --git a/provisioning/playbook.yml b/provisioning/playbook.yml index 1578c44b2..e32621f13 100644 --- a/provisioning/playbook.yml +++ b/provisioning/playbook.yml @@ -38,7 +38,7 @@ - { role: geerlingguy.firewall, when: firewall_enabled } - { role: geerlingguy.git } - { role: geerlingguy.postfix } - - { role: geerlingguy.apache, when: drupalvm_webserver == 'apache', tags: ['webserver']} + - { role: geerlingguy.apache, when: drupalvm_webserver == 'apache', tags: ['webserver'] } - { role: geerlingguy.apache-php-fpm, when: drupalvm_webserver == 'apache', tags: ['webserver'] } - { role: geerlingguy.nginx, when: drupalvm_webserver == 'nginx', tags: ['webserver'] } - { role: geerlingguy.php-versions, when: php_version != '', tags: ['php', 'xdebug', 'database'] } diff --git a/provisioning/requirements.yml b/provisioning/requirements.yml index d67687141..7f64ded79 100644 --- a/provisioning/requirements.yml +++ b/provisioning/requirements.yml @@ -19,11 +19,11 @@ roles: - name: geerlingguy.daemonize version: 1.2.1 - name: geerlingguy.drupal - version: 4.1.0 + version: 4.2.0 - name: geerlingguy.drupal-console version: 1.1.1 - name: geerlingguy.drush - version: 3.2.0 + version: 3.3.0 - name: geerlingguy.elasticsearch version: 4.2.0 - name: geerlingguy.firewall diff --git a/provisioning/roles/geerlingguy.drupal/.ansible-lint b/provisioning/roles/geerlingguy.drupal/.ansible-lint index a7564ce11..7ae7eb59b 100644 --- a/provisioning/roles/geerlingguy.drupal/.ansible-lint +++ b/provisioning/roles/geerlingguy.drupal/.ansible-lint @@ -1,3 +1,4 @@ skip_list: - '204' - '503' + - '106' diff --git a/provisioning/roles/geerlingguy.drupal/.github/workflows/ci.yml b/provisioning/roles/geerlingguy.drupal/.github/workflows/ci.yml new file mode 100644 index 000000000..57c082f82 --- /dev/null +++ b/provisioning/roles/geerlingguy.drupal/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +--- +name: CI +'on': + pull_request: + push: + branches: + - master + schedule: + - cron: "30 5 * * 1" + +defaults: + run: + working-directory: 'geerlingguy.drupal' + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + with: + path: 'geerlingguy.drupal' + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies. + run: pip3 install yamllint ansible-lint + + - name: Lint code. + run: | + yamllint . + ansible-lint + + molecule: + name: Molecule + runs-on: ubuntu-latest + strategy: + matrix: + include: + - distro: centos8 + playbook: converge.yml + - distro: ubuntu1804 + playbook: converge.yml + - distro: centos8 + playbook: deploy.yml + + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + with: + path: 'geerlingguy.drupal' + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies. + run: pip3 install ansible molecule[docker] docker + + - name: Run Molecule tests. + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + MOLECULE_DISTRO: ${{ matrix.distro }} + MOLECULE_PLAYBOOK: ${{ matrix.playbook }} diff --git a/provisioning/roles/geerlingguy.drupal/.github/workflows/release.yml b/provisioning/roles/geerlingguy.drupal/.github/workflows/release.yml new file mode 100644 index 000000000..fec1983e9 --- /dev/null +++ b/provisioning/roles/geerlingguy.drupal/.github/workflows/release.yml @@ -0,0 +1,38 @@ +--- +# This workflow requires a GALAXY_API_KEY secret present in the GitHub +# repository or organization. +# +# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy +# See: https://github.com/ansible/galaxy/issues/46 + +name: Release +'on': + push: + tags: + - '*' + +defaults: + run: + working-directory: 'geerlingguy.drupal' + +jobs: + + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + with: + path: 'geerlingguy.drupal' + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install Ansible. + run: pip3 install ansible-base + + - name: Trigger a new import on Galaxy. + run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) diff --git a/provisioning/roles/geerlingguy.drupal/.travis.yml b/provisioning/roles/geerlingguy.drupal/.travis.yml deleted file mode 100644 index 97f9381cb..000000000 --- a/provisioning/roles/geerlingguy.drupal/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -language: python -services: docker - -env: - global: - - ROLE_NAME: drupal - matrix: - - MOLECULE_DISTRO: centos8 - - MOLECULE_DISTRO: ubuntu1804 - # See: https://github.com/geerlingguy/ansible-role-drupal/issues/77 - # - MOLECULE_DISTRO: debian10 - - MOLECULE_DISTRO: centos8 - MOLECULE_PLAYBOOK: playbook-deploy.yml - -install: - # Install test dependencies. - - pip install molecule yamllint ansible-lint docker - -before_script: - # Use actual Ansible Galaxy role name for the project directory. - - cd ../ - - mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME - - cd geerlingguy.$ROLE_NAME - -script: - # Run tests. - - molecule test - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/provisioning/roles/geerlingguy.drupal/.yamllint b/provisioning/roles/geerlingguy.drupal/.yamllint index db22c42ea..a8dc58bd7 100644 --- a/provisioning/roles/geerlingguy.drupal/.yamllint +++ b/provisioning/roles/geerlingguy.drupal/.yamllint @@ -1,6 +1,11 @@ --- extends: default + rules: line-length: max: 160 level: warning + +ignore: | + .github/stale.yml + .travis.yml diff --git a/provisioning/roles/geerlingguy.drupal/README.md b/provisioning/roles/geerlingguy.drupal/README.md index 526632abf..91d909a61 100644 --- a/provisioning/roles/geerlingguy.drupal/README.md +++ b/provisioning/roles/geerlingguy.drupal/README.md @@ -1,6 +1,6 @@ # Ansible Role: Drupal -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-drupal.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-drupal) +[![CI](https://github.com/geerlingguy/ansible-role-drupal/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-drupal/actions?query=workflow%3ACI) Builds and installs [Drupal](https://drupal.org/), an open source content management platform. diff --git a/provisioning/roles/geerlingguy.drupal/molecule/default/playbook-deploy.yml b/provisioning/roles/geerlingguy.drupal/molecule/default/deploy.yml similarity index 81% rename from provisioning/roles/geerlingguy.drupal/molecule/default/playbook-deploy.yml rename to provisioning/roles/geerlingguy.drupal/molecule/default/deploy.yml index 1004dd8cc..3be18bfc9 100644 --- a/provisioning/roles/geerlingguy.drupal/molecule/default/playbook-deploy.yml +++ b/provisioning/roles/geerlingguy.drupal/molecule/default/deploy.yml @@ -7,11 +7,11 @@ - test-vars.yml vars: - # Deploy from the Drupal VM Prod example project. + # Deploy from the Drupal for Kubernetes example project. drupal_deploy: true - drupal_deploy_repo: "https://github.com/geerlingguy/drupalvm-live.git" + drupal_deploy_repo: "https://github.com/geerlingguy/drupal-for-kubernetes.git" drupal_deploy_dir: /var/www/drupal - drupal_domain: "prod.drupalvm.com" + drupal_domain: "test.pidramble.com" # Disable Composer-based codebase setup. drupal_build_composer_project: false diff --git a/provisioning/roles/geerlingguy.drupal/molecule/default/molecule.yml b/provisioning/roles/geerlingguy.drupal/molecule/default/molecule.yml index 2da47dd1f..74907107f 100644 --- a/provisioning/roles/geerlingguy.drupal/molecule/default/molecule.yml +++ b/provisioning/roles/geerlingguy.drupal/molecule/default/molecule.yml @@ -3,10 +3,6 @@ dependency: name: galaxy driver: name: docker -lint: | - set -e - yamllint . - ansible-lint platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" diff --git a/provisioning/roles/geerlingguy.drupal/tasks/build-composer-project.yml b/provisioning/roles/geerlingguy.drupal/tasks/build-composer-project.yml index 6baed300c..46dd36b2a 100644 --- a/provisioning/roles/geerlingguy.drupal/tasks/build-composer-project.yml +++ b/provisioning/roles/geerlingguy.drupal/tasks/build-composer-project.yml @@ -33,13 +33,25 @@ become: false when: not drupal_site_exists +# Use manual composer require tasks until Ansible 2.10.4 is released. - name: Install dependencies with composer require (this may take a while). - composer: - command: require - arguments: "{{ item }}" - working_dir: "{{ drupal_composer_install_dir }}" + command: "{{ composer_path }} require {{ item }} -d {{ drupal_composer_install_dir }}" + register: composer_require_result + changed_when: "'Nothing to install' not in composer_require_result.stderr" with_items: "{{ drupal_composer_dependencies|default([]) }}" become: false environment: COMPOSER_PROCESS_TIMEOUT: 1200 COMPOSER_MEMORY_LIMIT: '-1' + +# Switch back to this task after Ansible 2.10.4 is released. +# - name: Install dependencies with composer require (this may take a while). +# composer: +# command: require +# arguments: "{{ item }}" +# working_dir: "{{ drupal_composer_install_dir }}" +# with_items: "{{ drupal_composer_dependencies | default([]) }}" +# become: false +# environment: +# COMPOSER_PROCESS_TIMEOUT: 1200 +# COMPOSER_MEMORY_LIMIT: '-1' diff --git a/provisioning/roles/geerlingguy.drupal/tasks/build-composer.yml b/provisioning/roles/geerlingguy.drupal/tasks/build-composer.yml index a06e57260..ccf8d4797 100644 --- a/provisioning/roles/geerlingguy.drupal/tasks/build-composer.yml +++ b/provisioning/roles/geerlingguy.drupal/tasks/build-composer.yml @@ -13,6 +13,7 @@ copy: src: "{{ drupal_composer_path }}" dest: "/tmp/drupalvm-composer.json" + mode: 0644 when: drupal_composer_path and not drupal_site_exists become: false @@ -28,13 +29,25 @@ when: not drupal_site_exists become: false +# Use manual composer require tasks until Ansible 2.10.4 is released. - name: Install dependencies with composer require (this may take a while). - composer: - command: require - arguments: "{{ item }}" - working_dir: "{{ drupal_composer_install_dir }}" + command: "{{ composer_path }} require {{ item }} -d {{ drupal_composer_install_dir }}" + register: composer_require_result + changed_when: "'Nothing to install' not in composer_require_result.stderr" with_items: "{{ drupal_composer_dependencies|default([]) }}" become: false environment: COMPOSER_PROCESS_TIMEOUT: 1200 COMPOSER_MEMORY_LIMIT: '-1' + +# Switch back to this task after Ansible 2.10.4 is released. +# - name: Install dependencies with composer require (this may take a while). +# composer: +# command: require +# arguments: "{{ item }}" +# working_dir: "{{ drupal_composer_install_dir }}" +# with_items: "{{ drupal_composer_dependencies | default([]) }}" +# become: false +# environment: +# COMPOSER_PROCESS_TIMEOUT: 1200 +# COMPOSER_MEMORY_LIMIT: '-1' diff --git a/provisioning/roles/geerlingguy.drupal/tasks/build-makefile.yml b/provisioning/roles/geerlingguy.drupal/tasks/build-makefile.yml index 2cf132c8a..d905470dc 100644 --- a/provisioning/roles/geerlingguy.drupal/tasks/build-makefile.yml +++ b/provisioning/roles/geerlingguy.drupal/tasks/build-makefile.yml @@ -3,6 +3,7 @@ copy: src: "{{ drush_makefile_path }}" dest: /tmp/drupal.make.yml + mode: 0644 when: not drupal_site_exists - name: Ensure drupal_core_path directory exists. diff --git a/provisioning/roles/geerlingguy.drupal/tasks/deploy.yml b/provisioning/roles/geerlingguy.drupal/tasks/deploy.yml index b036acd15..93ba6a693 100644 --- a/provisioning/roles/geerlingguy.drupal/tasks/deploy.yml +++ b/provisioning/roles/geerlingguy.drupal/tasks/deploy.yml @@ -25,13 +25,25 @@ stat: "path={{ drupal_deploy_dir }}/composer.json" register: drupal_deploy_composer_file +# Use manual composer require tasks until Ansible 2.10.4 is released. - name: Run composer install if composer.json is present. - composer: - command: install - working_dir: "{{ drupal_deploy_dir }}" - no_dev: "{{ drupal_composer_no_dev }}" + command: "composer install -d {{ drupal_deploy_dir }}{% if drupal_composer_no_dev %} --no-dev{% endif %}" + register: composer_install_result + changed_when: "'Nothing to install' not in composer_install_result.stderr" when: - drupal_deploy_composer_file.stat.exists - drupal_deploy_composer_install become: "{{ drupal_core_owner_become }}" become_user: "{{ drupal_core_owner }}" + +# Switch back to this task after Ansible 2.10.4 is released. +# - name: Run composer install if composer.json is present. +# composer: +# command: install +# working_dir: "{{ drupal_deploy_dir }}" +# no_dev: "{{ drupal_composer_no_dev }}" +# when: +# - drupal_deploy_composer_file.stat.exists +# - drupal_deploy_composer_install +# become: "{{ drupal_core_owner_become }}" +# become_user: "{{ drupal_core_owner }}" diff --git a/provisioning/roles/geerlingguy.drush/.github/workflows/ci.yml b/provisioning/roles/geerlingguy.drush/.github/workflows/ci.yml new file mode 100644 index 000000000..8cabc649b --- /dev/null +++ b/provisioning/roles/geerlingguy.drush/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +--- +name: CI +'on': + pull_request: + push: + branches: + - master + schedule: + - cron: "0 4 * * 1" + +defaults: + run: + working-directory: 'geerlingguy.drush' + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + with: + path: 'geerlingguy.drush' + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies. + run: pip3 install yamllint ansible-lint + + - name: Lint code. + run: | + yamllint . + ansible-lint + + molecule: + name: Molecule + runs-on: ubuntu-latest + strategy: + matrix: + include: + - distro: centos7 + playbook: converge.yml + - distro: ubuntu1804 + playbook: converge.yml + - distro: debian9 + playbook: converge.yml + - distro: centos7 + playbook: composer.yml + - distro: centos7 + playbook: source.yml + + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + with: + path: 'geerlingguy.drush' + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies. + run: pip3 install ansible molecule[docker] docker + + - name: Run Molecule tests. + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + MOLECULE_DISTRO: ${{ matrix.distro }} + MOLECULE_PLAYBOOK: ${{ matrix.playbook }} diff --git a/provisioning/roles/geerlingguy.drush/.github/workflows/release.yml b/provisioning/roles/geerlingguy.drush/.github/workflows/release.yml new file mode 100644 index 000000000..611bd55ef --- /dev/null +++ b/provisioning/roles/geerlingguy.drush/.github/workflows/release.yml @@ -0,0 +1,38 @@ +--- +# This workflow requires a GALAXY_API_KEY secret present in the GitHub +# repository or organization. +# +# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy +# See: https://github.com/ansible/galaxy/issues/46 + +name: Release +'on': + push: + tags: + - '*' + +defaults: + run: + working-directory: 'geerlingguy.drush' + +jobs: + + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v2 + with: + path: 'geerlingguy.drush' + + - name: Set up Python 3. + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install Ansible. + run: pip3 install ansible-base + + - name: Trigger a new import on Galaxy. + run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) diff --git a/provisioning/roles/geerlingguy.drush/README.md b/provisioning/roles/geerlingguy.drush/README.md index a0b2e0f93..9f8ccf9c5 100644 --- a/provisioning/roles/geerlingguy.drush/README.md +++ b/provisioning/roles/geerlingguy.drush/README.md @@ -1,6 +1,6 @@ # Ansible Role: Drush -[![Build Status](https://travis-ci.com/geerlingguy/ansible-role-drush.svg?branch=master)](https://travis-ci.com/geerlingguy/ansible-role-drush) +[![CI](https://github.com/geerlingguy/ansible-role-drush/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-drush/actions?query=workflow%3ACI) Installs [Drush](http://www.drush.org), a command line shell and scripting interface for Drupal, on any Linux or UNIX system. diff --git a/provisioning/roles/geerlingguy.drush/molecule/default/playbook-composer.yml b/provisioning/roles/geerlingguy.drush/molecule/default/composer.yml similarity index 100% rename from provisioning/roles/geerlingguy.drush/molecule/default/playbook-composer.yml rename to provisioning/roles/geerlingguy.drush/molecule/default/composer.yml diff --git a/provisioning/roles/geerlingguy.drush/molecule/default/molecule.yml b/provisioning/roles/geerlingguy.drush/molecule/default/molecule.yml index 2da47dd1f..74907107f 100644 --- a/provisioning/roles/geerlingguy.drush/molecule/default/molecule.yml +++ b/provisioning/roles/geerlingguy.drush/molecule/default/molecule.yml @@ -3,10 +3,6 @@ dependency: name: galaxy driver: name: docker -lint: | - set -e - yamllint . - ansible-lint platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" diff --git a/provisioning/roles/geerlingguy.drush/molecule/default/playbook-source.yml b/provisioning/roles/geerlingguy.drush/molecule/default/source.yml similarity index 100% rename from provisioning/roles/geerlingguy.drush/molecule/default/playbook-source.yml rename to provisioning/roles/geerlingguy.drush/molecule/default/source.yml diff --git a/provisioning/roles/geerlingguy.drush/tasks/install-drush-composer.yml b/provisioning/roles/geerlingguy.drush/tasks/install-drush-composer.yml index 7338c599c..fadd11e0c 100644 --- a/provisioning/roles/geerlingguy.drush/tasks/install-drush-composer.yml +++ b/provisioning/roles/geerlingguy.drush/tasks/install-drush-composer.yml @@ -1,21 +1,37 @@ --- +# Use manual composer tasks until Ansible 2.10.4 is released. - name: Ensure Drush is installed globally via Composer. - composer: - command: require - global_command: true - arguments: "drush/drush:{{ drush_composer_version }}" + command: "{{ composer_path }} global require drush/drush:{{ drush_composer_version }}" register: drush_composer_require + changed_when: "'Nothing to install' not in drush_composer_require.stderr" - name: Update global Drush install if configured. - composer: - command: update - global_command: true - arguments: "drush/drush --with-dependencies" + command: "{{ composer_path }} global update drush/drush --with-dependencies" + changed_when: "'Nothing to install' not in drush_composer_require.stderr" + register: tasky when: - drush_composer_update - not drush_composer_require.changed tags: ['skip_ansible_lint'] +# Switch back to these tasks after Ansible 2.10.4 is released. +# - name: Ensure Drush is installed globally via Composer. +# composer: +# command: require +# global_command: true +# arguments: "drush/drush:{{ drush_composer_version }}" +# register: drush_composer_require +# +# - name: Update global Drush install if configured. +# composer: +# command: update +# global_command: true +# arguments: "drush/drush --with-dependencies" +# when: +# - drush_composer_update +# - not drush_composer_require.changed +# tags: ['skip_ansible_lint'] + - name: Ensure globally-installed Drush is symlinked into bin dir. file: # noqa 208 src: "{{ drush_composer_global_bin_path }}/drush" diff --git a/provisioning/templates/drush.yml b/provisioning/templates/drush.yml index e04ccc67d..4ad3f737e 100644 --- a/provisioning/templates/drush.yml +++ b/provisioning/templates/drush.yml @@ -1,3 +1,4 @@ +--- drush: paths: alias-path: diff --git a/tests/centos-8.config.yml b/tests/centos-8.config.yml deleted file mode 100644 index c5b40e548..000000000 --- a/tests/centos-8.config.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -postfix_inet_protocols: ipv4 diff --git a/tests/config.yml b/tests/config.yml deleted file mode 100644 index 442f4f19c..000000000 --- a/tests/config.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# Update the composer_home_path for global installs. -composer_home_path: "/{{ drupalvm_user }}/.composer" - -# Don't run the 'disable firewall' tasks in tests. -firewall_disable_firewalld: false -firewall_disable_ufw: false - -# Added to prevent test failures in CI. -firewall_enable_ipv6: false diff --git a/tests/run-tests.sh b/tests/run-tests.sh deleted file mode 100755 index d95513c34..000000000 --- a/tests/run-tests.sh +++ /dev/null @@ -1,185 +0,0 @@ -#!/bin/bash -# -# A script to run Drupal VM functional tests. - -# Set defaults if they're not set upstream. -CONFIG="${CONFIG:-tests/config.yml}" -MAKEFILE="${MAKEFILE:-example.drupal.make.yml}" -COMPOSERFILE="${COMPOSERFILE:-example.drupal.composer.json}" -HOSTNAME="${HOSTNAME:-drupalvm.test}" -MACHINE_NAME="${MACHINE_NAME:-drupalvm}" -IP="${IP:-192.168.88.88}" -DRUPALVM_DIR="${DRUPALVM_DIR:-/var/www/drupalvm}" -DRUSH_BIN="${DRUSH_BIN:-drush}" -ANSIBLE_PYTHON_INTERPRETER="${ANSIBLE_PYTHON_INTERPRETER:-/usr/bin/python3}" -TEST_INSTALLED_EXTRAS="${TEST_INSTALLED_EXTRAS:-true}" -CONTAINER_ID="${CONTAINER_ID:-dvm-test}" -type="${type:-tests/defaults}" -distro="${distro:-ubuntu1804}" -tag="${tag:-latest}" -cleanup="${cleanup:-true}" - -## Set up vars for Docker setup. -# CentOS 8 -if [ $distro = 'centos8' ]; then - init="/usr/lib/systemd/systemd" - opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" -# Ubuntu 18.04 -elif [ $distro = 'ubuntu1804' ]; then - init="/lib/systemd/systemd" - opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" -# Debian 10 -elif [ $distro = 'debian10' ]; then - init="/lib/systemd/systemd" - opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" -fi - -# Set OS-specific options. -if [[ "$OSTYPE" == "darwin"* ]]; then - volume_opts='rw,cached' -else - volume_opts='rw' -fi - -# Use correct xargs command depending if it's GNU or BSD. -if xargs --version 2>&1 | grep -s GNU >/dev/null; then - xargs_command='xargs -r' -else - xargs_command='xargs' -fi - -# Exit on any individual command failure. -set -e - -# Pretty colors. -red='\033[0;31m' -green='\033[0;32m' -neutral='\033[0m' - -# Remove test container if it already exists. -printf "\n"${green}"Removing any existing test containers..."${neutral}"\n" -docker ps -aq --filter name=$CONTAINER_ID | $xargs_command docker rm -f -v -printf ${green}"...done!"${neutral}"\n" - -# Run the container. -printf "\n"${green}"Starting Docker container: geerlingguy/docker-$distro-ansible."${neutral}"\n" -docker run --name=$CONTAINER_ID -d \ - --add-host "$HOSTNAME drupalvm":127.0.0.1 \ - -v $PWD:/var/www/drupalvm/:$volume_opts \ - $opts \ - geerlingguy/docker-$distro-ansible:$tag \ - $init - -# Set up directories. -docker exec $CONTAINER_ID mkdir -p /var/www/drupalvm/drupal -[[ ! -z "$config_dir" ]] && docker exec $CONTAINER_ID mkdir -p $config_dir || true - -# Copy configuration 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 -[[ ! -z "$DRUPALVM_ENV" ]] && docker exec $CONTAINER_ID bash -c "cp $DRUPALVM_DIR/tests/$DRUPALVM_ENV.config.yml ${config_dir:-$DRUPALVM_DIR}/$DRUPALVM_ENV.config.yml" || true - -# Override configuration variables with local config. -[[ ! -z "$local_config" ]] && docker exec $CONTAINER_ID bash -c "cp $DRUPALVM_DIR/$local_config ${config_dir:-$DRUPALVM_DIR}/local.config.yml" || true - -# Check playbook syntax. -printf "\n"${green}"Checking playbook syntax..."${neutral}"\n" -docker exec --tty $CONTAINER_ID env TERM=xterm ansible-playbook $DRUPALVM_DIR/provisioning/playbook.yml --syntax-check - -# Run the setup playbook. -printf "\n"${green}"Running the setup playbook..."${neutral}"\n" -docker exec --tty $CONTAINER_ID env TERM=xterm \ - ansible-playbook /var/www/drupalvm/tests/test-setup.yml \ - -e "ansible_python_interpreter=$ANSIBLE_PYTHON_INTERPRETER"; - -# Run the Drupal VM playbook. -printf "\n"${green}"Running the Drupal VM playbook..."${neutral}"\n" -if [ ! -z "${config_dir}" ]; then - # Run with config_dir specified. - docker exec $CONTAINER_ID env TERM=xterm ANSIBLE_FORCE_COLOR=true DRUPALVM_ENV=$DRUPALVM_ENV \ - ansible-playbook $DRUPALVM_DIR/provisioning/playbook.yml \ - -e "config_dir=$config_dir" -e "ansible_python_interpreter=$ANSIBLE_PYTHON_INTERPRETER"; -else - # Run without config_dir specified. - docker exec $CONTAINER_ID env TERM=xterm ANSIBLE_FORCE_COLOR=true DRUPALVM_ENV=$DRUPALVM_ENV \ - ansible-playbook $DRUPALVM_DIR/provisioning/playbook.yml \ - -e "ansible_python_interpreter=$ANSIBLE_PYTHON_INTERPRETER"; -fi - -# Drupal. -printf "\n"${green}"Running functional tests..."${neutral}"\n" -docker exec $CONTAINER_ID curl -sSi --header Host:$HOSTNAME localhost \ - | tee /tmp/dvm-test \ - | grep -q '<title>Welcome to Drupal' \ - && (echo 'Drupal install pass' && exit 0) \ - || (echo 'Drupal install fail' && cat /tmp/dvm-test && exit 1) - -# Adminer. -if [ $TEST_INSTALLED_EXTRAS = true ]; then - docker exec $CONTAINER_ID curl -sSi --header Host:adminer.$HOSTNAME localhost \ - | tee /tmp/dvm-test \ - | grep -q '<title>Login - Adminer' \ - && (echo 'Adminer install pass' && exit 0) \ - || (echo 'Adminer install fail' && cat /tmp/dvm-test && exit 1) -fi - -# Pimp My Log. -if [ $TEST_INSTALLED_EXTRAS = true ]; then - docker exec $CONTAINER_ID curl -sSi --header Host:pimpmylog.$HOSTNAME localhost \ - | tee /tmp/dvm-test \ - | grep -q '<title>Pimp my Log' \ - && (echo 'Pimp my Log install pass' && exit 0) \ - || (echo 'Pimp my Log install fail' && cat /tmp/dvm-test && exit 1) -fi - -# MailHog. -if [ $TEST_INSTALLED_EXTRAS = true ]; then - docker exec $CONTAINER_ID curl -sSi localhost:8025 \ - | tee /tmp/dvm-test \ - | grep -q '<title>MailHog' \ - && (echo 'MailHog install pass' && exit 0) \ - || (echo 'MailHog install fail' && cat /tmp/dvm-test && exit 1) -fi - -# Varnish. -if [ $TEST_INSTALLED_EXTRAS = true ]; then - docker exec $CONTAINER_ID curl -sSI --header Host:$HOSTNAME localhost:81 \ - | tee /tmp/dvm-test \ - | grep -q 'Via: .* varnish' \ - && (echo 'Varnish install pass' && exit 0) \ - || (echo 'Varnish install fail' && cat /tmp/dvm-test && exit 1) -fi - -# Dashboard. -docker exec $CONTAINER_ID curl -sSi --header Host:$IP localhost \ - | tee /tmp/dvm-test \ - | grep -q "<li>$IP $HOSTNAME</li>" \ - && (echo 'Dashboard install pass' && exit 0) \ - || (echo 'Dashboard install fail' && cat /tmp/dvm-test && exit 1) - -# Drush - see https://github.com/drush-ops/drush/issues/3336. This test would -# also test generated global Drush aliases, but it's currently not working due -# to $reasons. -# docker exec $CONTAINER_ID $DRUSH_BIN @$MACHINE_NAME.$HOSTNAME status \ -# | tee /tmp/dvm-test \ -# | grep -q 'Drupal bootstrap.*Successful' \ -# && (echo 'Drush install pass' && exit 0) \ -# || (echo 'Drush install fail' && cat /tmp/dvm-test && exit 1) - -# Drush. -docker exec $CONTAINER_ID bash -c "cd $DRUPALVM_DIR/drupal && $DRUSH_BIN status" \ - | tee /tmp/dvm-test \ - | grep -q 'Drush' \ - && (echo 'Drush install pass' && exit 0) \ - || (echo 'Drush install fail' && cat /tmp/dvm-test && exit 1) - -# Remove test container. -if [ $cleanup = true ]; then - printf "\n"${green}"Cleaning up..."${neutral}"\n" - docker rm -f $CONTAINER_ID - printf ${green}"...done!"${neutral}"\n\n" -else - printf "\n"${green}"Skipping cleanup for container id: ${CONTAINER_ID}!"${neutral}"\n" - printf ${green}"Done!"${neutral}"\n\n" -fi diff --git a/tests/test-setup.yml b/tests/test-setup.yml deleted file mode 100644 index 9ae3c099f..000000000 --- a/tests/test-setup.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- hosts: all - become: yes - - tasks: - - name: Update apt cache. - apt: update_cache=yes - when: ansible_os_family == 'Debian' - - - name: Install test dependencies (RedHat). - package: name=logrotate state=present - when: ansible_os_family == 'RedHat'