Continuous Integration Solutions
Run automated unit and integration tests with Terminus and Drupal SimpleTest.
This section provides information on how to use Terminus and Drupal SimpleTest to run automated integration tests.
Continuous Integration (CI) is a method of running automated unit and integration tests to apply quality control. Pantheon doesn't provide or host tools for continuous integration, but many tools and techniques are compatible with Pantheon. Contact support if you have a particular use case or technique that you'd like to highlight.
Refer to our Build Tools guide for more information on the workflow for using build tools like GitHub and CircleCI with Composer for Drupal and WordPress sites.
Terminus Command-Line Interface
Terminus is a Symfony/Console-based command-line interface (CLI) in the Pantheon core API. Most operations available through the Pantheon Dashboard can be performed with Terminus, including:
- Site creation
- Multidev environment creation and removal
- Content cloning
- Code pushes
Drupal SimpleTest
SimpleTest is a testing framework based on the SimpleTest PHP library that is included with Drupal core. You should consider including SimpleTests of your module functionality if you are creating a custom web application.
SiteTest is a contrib module for Drupal that runs tests directly against your sites code instead of a base Drupal clone of your site. This module is recommended for use on SimpleTest on Pantheon.
The Drush test-run command was dropped in Drush 7 and 8. Refer to this GitHub issue for more information.
Run Tests on Pantheon
Replace $SITE_NAME
and $ENV_NAME
in the examples below with the your site and environment information.
Enable
site_test
:terminus drush $SITE_NAME.$ENV_NAME -- en site_test -y
This command also enables
simpletest
as a dependency ofsite_test
.Clear the cache immediately before running tests to avoid failures. Repeat this step each time you run tests.
terminus drush $SITE_NAME.$ENV_NAME -- cc all
Get the absolute path before you run the script. You may need to strip out warnings by ending the command with
2>/dev/null
.terminus drush $SITE_NAME.$ENV_NAME -- eval "echo DRUPAL_ROOT"
The full command should look similar to this:
export TERMINUS_HIDE_UPDATE_MESSAGE=1 terminus drush $SITE_NAME.$ENV_NAME -- exec php `terminus drush $SITE_NAME.$ENV_NAME -- eval "echo DRUPAL_ROOT" 2>/dev/null`/scripts/run-tests.sh --url http://$ENV_NAME-$SITE_NAME.pantheonsite.io OptionalTestGroup
In the above command the
--url
option is required to be passed as Multidevs do not respond tolocalhost
.A full CircleCI command might look similar to this:
- run: name: Test simpletest command: | if [ "${CIRCLE_BRANCH}" != "master" ]; then export TERMINUS_HIDE_UPDATE_MESSAGE=1 terminus drush $SITE_NAME.$ENV_NAME -- en site_test -y # If you don't clear the cache immediately before running tests # we get the html gibberish instead of a passing test. terminus drush $SITE_NAME.$ENV_NAME -- cc all # NOTE: Use the latest version of Terminus to avoid warning messages in the output, which will break the test. # in order to exclude the notice in shell output of the # embedded command to find the absolute path. terminus drush $SITE_NAME.$ENV_NAME -- exec php `terminus drush $SITE_NAME.$ENV_NAME -- eval "echo DRUPAL_ROOT" 2>/dev/null`/scripts/run-tests.sh --url http://$ENV_NAME-$SITE_NAME.pantheonsite.io OptionalTestGroup fi
Integration Bot
We recommend creating a bot user account to handle the tasks or jobs by an external continuous integration service rather a standard user account.
- Add the bot to select projects
- Manage separate SSH Keys for CI
Known Limitations
Pantheon does not provide or offer customer support for:
- Webhooks
- Git hooks
- Running Jenkins or other Continuous Integration software on our servers. You'll need to self-host or use a hosted CI solution. Compare solutions here.
- Shell access
- PHPUnit Unit Testing PHP Framework: You can still write tests and include them in your code, but you'll need to run them on a CI server, not Pantheon.