Many 8.0.x contrib modules are being developed on Github, due to the flexibility it offers whilst 8.0.x is being developed.

As the complexity of 8.0.x has grown, needing to test modules using Continuous Integration (CI) is critical. Drupal.org offers CI for modules, but we need custom steps each build.

For example, to build commerce 2.x the following steps are required:

  1. drush si –db-url=mysql://root:@127.0.0.1/drupal –account-name=admin –account-pass=admin –[email protected] –site-name=“Commerce” –yes
  2. drush en -y composer_manager simpletest
  3. drush composer-manager-init
  4. cd core
  5. rm -rf vendor
  6. composer drupal-rebuild
  7. composer update –prefer-source -n –verbose
  8. cd ..
  9. drush en -y commerce commerce_product commerce_order
  10. php core/scripts/run-tests.sh –verbose –color –concurrency 4 –php which php –url http://localhost “commerce” | tee /tmp/test.txt; TEST_EXIT=${PIPESTATUS[0]}; echo $TEST_EXIT

As you can see, quite a few commands are needed. For the full command list, check out the .travis.yml file commerce uses.

Travis

So what exactly is Travis? Well, wikipedia says:

Travis CI is an open-source hosted, distributed continuous integration service used to build and test projects hosted at GitHub. Travis CI is configured by adding a file named .travis.yml, which is a YAML format text file, to the root directory of the GitHub repository.

Similar to Drupal.org, everytime a new Pull Request is added on Drupal.org, it is tested against Travis to make sure everything passes.

This is all fine and dandy, but what happens whenever 8.0.x updates? 8.0.x can update many times a day thanks to the tireless work of the contributors and core committers, and change records come in thick and fast with breaking changes often happening.

Travis doesn’t offer a feature to do new builds via API out of the box unfortunately, however there is a script called travis-cron which is a shell command to trigger rebuilding the latest build of a certain branch, so I use this to rebuild the 8.x-2.x branch of Drupal Commerce, as only merges are done on this branch.

To get this to work, I use an opensource tool called Huginn, which is very similar to IFTTT. IFTTT basically means “If this, than that”, so you can perform an action whenever something happens.

I use Huginn for this, because IFTTT doesn’t have Webhooks yet, and I also need to run a bash command anyway, so hosting on a small VPS ($5/month) is worthwhile.

The first thing we want to do is enable the RSS agent, which will allow us to know whenever core has updated. This can be found as a link on the Core Commits page, with the direct RSS link being here.

To create a new RSS agent in Huginn, click “Agents -> New Agent”

From here, you can add all the settings you need, such as the URL to parse, how often to check the RSS feed (I have mine set to every 5 minutes)

After this is done, we need to setup another Agent, that will react on whenever a feed item is added. Since we want to react on all feed changes, not just certain items, this is easy to do, just adding a ShellCommandAgent will do the trick. You can use “travis-cron” to do this, reacting on the “Drupal Core Updates” RSS item.

Now whenever core has updated, travis-ci will rebuild the branch you have chosen with travis-cron!