GithubHelp home page GithubHelp logo

lcatlett / drupal8ci Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lullabot/drupal9ci

0.0 2.0 0.0 1.87 MB

One-line installers for implementing Continuous Integration in Drupal 8

License: GNU General Public License v3.0

Dockerfile 17.71% Shell 82.29%

drupal8ci's Introduction

Drupal 8 CI

CircleCI

This repository provides the foundation to implement Continuous Integration in a Drupal 8 project using CircleCI, GitLab CI, or Travis CI against a GitHub or GitLab repository.

To install, simply run the respective installer and allow the CI provider that you chose to watch repository changes to start building on every pull request.

If you want to test an individual module instead of a Drupal project, see Andrew Berry's drupal_tests.

Here is a clip that shows how it works for CircleCI.

Requirements

The scripts assume that you have a Drupal 8 project created using drupal-project, which sets a well known foundation. If your project's directory structure differs from what drupal-project sets up, you will need to adjust the CI scripts.

It's also recommended to adjust your project to add a subset of the settings.php file into version control and rely on settings.local.php for setting the database connection. See this commit which contains these changes among other ones. The CI scripts have their own settings.local.php which is copied on build time into web/sites/default.

Installation

Each CI tool has its own installer, which extracts the required files to run the jobs, plus a set of sample PHPUnit and Behat tests.

Choose a CI tool from the list below and follow its installation steps.

CircleCI

Live demo | Deep dive article

Open a terminal and run the installer from the root of your project:

curl -L https://github.com/lullabot/drupal8ci/raw/master/setup-circleci.sh | bash

Sign up at CircleCI and allow access to your project's repository.

CircleCI watch

Happy CI-ing! :-D. From now every time you create a pull request, CircleCI will run the set of jobs and report their result like in the following screenshot:

CircleCI pull request

For an overview of the CircleCI features, have a look at this article from the Lullabot blog.

Using a custom Docker image

The CircleCI configuration file uses a custom Docker image that extends from the official Drupal image and it is hosted at Docker Hub. If this image does not fit your project's architecture, then have a look at its Dockerfile and consider creating your own image based out of it.

Setting up the update path

The Behat job requires a running Drupal 8 site. The repository contains the code, but for running tests in a realistic environment you need:

1. A recent copy of the production environment's database

If you have Drush site aliases, then at the CircleCI dashboard go to the project's permissions and add an SSH key. Next, add drush @my.alias sql-cli to the Behat job at .circleci/config.yml.

Alternatively, upload a sanitized database dump somewhere. For example the demo project uses a Dropbox URL via an environment variable which is set at the Circle CI web interface like in the following screenshot:

CircleCI database via environment variable

2. The production environment's files directory

If you have a site alias, then add drush rsync @my.alias @self to the Behat job. Alternatively, use Stage File Proxy module.

Travis CI

Live Demo | Deep dive article

Open a terminal and run the installer from the root of your project:

curl -L https://github.com/lullabot/drupal8ci/raw/master/setup-travis-ci.sh | bash

Sign up at Travis CI and allow access to your project's repository:

Travis watch

Happy CI-ing! :-D. From now on every pull request will trigger a build in Travis and its progress will be visible like in the following screenshot:

Travis pull request

For you to see the result of the individual jobs, you need to click at the Details link from the above screenshot:

Travis CI jobs

Setting up code coverage reports

Coveralls.io is a third party tool that can host and present PHPUnit code coverage reports in a neat way within a pull request. Here is how to set it up:

Register at https://coveralls.io using your GitHub account and then add your repository like in the following screenshot:

Coveralls add repository

Then take the chance to adjust a couple settings to get cleaner feedback in pull requests:

Coveralls settings

That's it! Here is a sample report which you can see by clicking at Details at the pull request's status message:

Coveralls report

Setting up the Behat job

The Behat job requires, in order to test the behavior of your project:

1. A recent copy of the production environment's database

If you have Drush site aliases, and your repository is private, then follow these instructions to add an SSH key. Next, set up a drush site alias. Finally, adjust the Behat job to run drush @my.alias sql-cli.

Alternatively, upload a sanitized database dump somewhere and set up the environment variable so the job can download it. For example the demo project uses a Dropbox URL via an environment variable referenced below:

Travis CI db env var

2. The production environment's files directory

If you have a site alias, then add drush rsync @my.alias @self to the Behat job. Alternatively, use Stage File Proxy module.

GitLab CI

Open a terminal and run the installer from the root of your project:

curl -L https://github.com/lullabot/drupal8ci/raw/master/setup-gitlab-ci.sh | bash

Follow the installation steps at the GitLab CI website for completing the setup.

Troubleshooting

Class "\Drupal\Tests\Listeners\DrupalStandardsListener" does not exist

If you get this error at the unit and kernel tests jobs, then it means that your project uses Drupal 8.5 or newer, which introduced a few changes at web/core/phpunit.xml.dist.

To fix this, overwrite .circleci/config/phpunit.xml with .circleci/config/phpunit-drupal-8.5.xml if you are using CircleCI, or with .travis/config/phpunit-drupal-8.5.xml if you are using Travis CI.

drupal8ci's People

Contributors

dakkusingh avatar deviantintegral avatar juampynr avatar lcatlett avatar q0rban avatar stuffandthings avatar visabhishek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.