Skip to content

One-line installers for implementing Continuous Integration in Drupal 8

License

Notifications You must be signed in to change notification settings

fjgarlin/drupal9ci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
Apr 9, 2021
Apr 16, 2021
Mar 11, 2020
Aug 17, 2019
Nov 27, 2017
Apr 13, 2021
Apr 13, 2021
Nov 27, 2017
Apr 15, 2021
Apr 9, 2021
Apr 9, 2021
Apr 9, 2021
Apr 9, 2021

Repository files navigation

Drupal 9 CI

CircleCI

This repository provides the foundation to implement Continuous Integration in a Drupal 9 project using any of the following CI providers:

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 9 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 at build time into web/sites/default.

Installation

Each CI tool has its own installer, which extracts the required files to run the jobs. It also adds a demo module with tests.

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

Demo repository | Deep dive article

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

curl -L https://github.com/lullabot/drupal9ci/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 consider creating your own image based out of it.

Demo repository | Deep dive article

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

curl -L https://github.com/lullabot/drupal9ci/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

Demo repository | Deep dive article

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

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

Review, commit, and push the resulting changes. After doing that, navigate to the project's homepage at GitLab and open the CI / CD >> Pipelines section. You should see a running pipeline like the following one:

GitLab pipeline

Demo repository

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

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

Review, commit, and push the resulting changes. After doing that, navigate to the repository's homepage at GitHub and open the Actions tab. You should see a running workflow like the following one:

GitLab pipeline

Setting up the Behat and Cypress jobs for all platforms

The Behat and Cypress jobs require a running Drupal 9 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

Travis

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.

CircleCI

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.

Alternative

Alternatively, upload a sanitized database dump somewhere and set up the DB_DUMP_URL environment variable so the job can download it.

For example: Travis CI db env var 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.

About

One-line installers for implementing Continuous Integration in Drupal 8

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 84.4%
  • Dockerfile 15.6%