This guide describes how to use build tools such as GitHub and CircleCI with Composer to implement a collaborative, team-based Continuous Integration workflow using Pull Requests for Drupal 8 sites on Pantheon. While this guide demonstrates Drupal 8, the same workflow can be applied to WordPress and Drupal 7 sites.
GitHub is an online service that provides cloud storage Git repositories that may be cloned and used locally, or edited directly through their web-based management interface. These features are very useful to teams collaborating on a project together.
CircleCI provides hosted services to run automated tests for a project, and GitHub provides an integration to run these tests to whenever a change is submitted. The process of testing each set of changed files prior to merging them into the main branch is called continuous integration.
Composer is a PHP dependency manager that provides an alternative, more modern way to manage the external code used by a project. For example, Composer may be used to install the plugins, modules and themes used by a Drupal or WordPress site.
Master Composer concepts with help from our experts. Pantheon delivers custom workshops to help development teams master the platform and improve internal DevOps.
Only files unique to the project are tracked as part of the project's main "source" repository on GitHub, which requires an abstraction layer to compile dependencies and deploy an entire "artifact" to the site repository on Pantheon. The abstraction layer is facilitated by CircleCI in the Pantheon maintained examples, but the principles are the same for other continuous integration service providers.
Composer is used to fetch dependencies declared by the project as part of a CircleCI build step. This ensures that the final composed build results are installed on Pantheon:
One advantage of managing code this way is that it keeps the change sets (differences) for pull requests as small as possible. If a pull request upgrades several dependencies, only the dependency metadata file will change; the actual code changes in the upgraded dependencies themselves are not shown.
GitHub pull requests (PRs) are a formalized way of reviewing and merging a proposed set of changes to the source repository. When one member of a development team makes changes to a project, all of the files modified to produce the feature are committed to a separate branch, and that branch becomes the basis for the pull request. GitHub allows other team members to review all of the differences between the new files and their original versions, before merging the PR to accept changes.
Install the most recent release of Terminus:
Add an SSH key within your User Dashboard to enable passwordless access and avoid authentication prompts. Otherwise, provide your Pantheon Dashboard credentials when prompted.
Generate a Machine Token, then authenticate Terminus:
$HOME/.terminus/plugins directory if it does not already exist:
Install the Terminus Composer Plugin:
Install the Terminus Drupal Console Plugin:
Install the Terminus Build Tools Plugin:
The Terminus Build Tools Plugin does not support private repositories.
If you are redirected to the CircleCI homepage, you have already authorized the service for your GitHub account. Nice! Way to be ahead of the game.
Pantheon's support team cannot troubleshoot issues with third-party services like GitHub or CircleCI.
If you need help configuring external systems, consider joining the Pantheon Power Users community on Slack.
The Build Tools plugin will prompt you to create access tokens for both GitHub and CircleCI, which are stored as environment variables. The GitHub token needs the repo (required) and delete-repo (optional) scopes. You may optionally generate these tokens ahead of time and manually export them to the local variables
export GITHUB_TOKEN=yourGitHubToken export CIRCLE_TOKEN=yourCircleCIToken
If you need to replace a token, navigate to your project settings page in CircleCI.