Travis integration

From MoodleDocs
Revision as of 00:42, 23 October 2015 by Andrew Nicols (talk | contribs) (Initial docs for Travis-CI integration)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Moodle is regularly tested against a matrix of Databases, PHP Versions, and operating systems, however many developers do not have the resources available to run on many of these combinations before pushing an issue for integration as they are time-consuming to both set up and to run.

There are many Continuous Integration tools available to developers, and Travis-CI is just one of those available freely to the Open Source community.

Since version 3.0, Moodle includes a Travis configuration file in its repository. This configuration file configures and controls a Travis build across a matrix of testing environments. This allows developers pushing patches to Moodle to have their code unit tested before it reaches integration. The hope is that the availability of this integration should reduce the number of unit test failures seen during Integration.

Note: Moodle HQ uses the Jenkins CI platform internally and this should be seen as the canonical CI server for Moodle. The Travis integration provided is to provide early warning to developers of any issues with their code.


Travis-CI is freely available and is usually configured to run automatically when pushing code, but it must be configured before first use.

For the purpose of this documentation, it is assumed that you are pushing to a public Moodle repository on GitHub. Other integrations are supported, but the free service available from Travis is only available to public repositories.


  1. [Sign in to Travis CI] using your GitHub account
  2. Once you’re signed in, and the initial synchronisation of your GitHub repositories has completed, go to your [profile page]
  3. Enable Travis CI for your clone of the Moodle repository moodle-travis-enable.png
  4. Click on the cog icon to configure the Integration
  5. Ensure that "Build only if .travis.yml is present" is enabled moodle-travis-settings.png

Additional setup

As part of the setup process for Travis, we install a number of Composer dependencies. Since Composer uses GitHub, it is extremely easy to have your account rate-limited by GitHub. This can slow the build down.

In order to increase the rate at which you are limited, you must identify your Composer install to GitHub using a GitHub personal token.

  1. Generate a Github Personal Access Token
    1. Log in to your GitHub account
    2. From the top-right, open the user menu and select "Settings"
    3. From the menu on the left, choose "Personal Access Tokens"
    4. At the top-right, choose "Generate new token" (you will be asked for your GitHub password to access this page)
    5. Enter a title for your token (e.g. travis-moodle)
    6. Untick all of the scopes except for "public_repo" github-pat.png
    7. Click Generate token
    8. Copy the token generated into your clipboard
  2. Hop on over to
  3. Open the configuration for your Moodle Integration with Travis
  4. Under environment variables, add a new variable. The name should be "GITHUB_APITOKEN". Paste your token into the value, and click the Add button
  5. Ensure that "Display value in build log" remains off. moodle-travis-env.png

This will add your GitHub Personal Access token to the composer configuration during the build process. This can increase the speed of the build dramatically.