
If you have seen our latest community development meeting you may remember Andrew Nicols talking about Travis CI integration with Moodle. I really liked the idea as I saw its great potential for Moodle plugins development.
Let us say you are maintaining a plugin, ideally with some unit tests and behat tests attached. Apart from those, there are other things that can be automatically checked too - such as following the Moodle coding style. Travis allows you to continuously run all tests and checks in sandbox environments, with various PHP versions, Moodle versions, databases etc. For open source projects, using Travis is free. For projects hosted on Github, the overall setup is incredibly simple. So it seems to be a perfect option for most Moodle plugins. Finally, using Travis CI for Moodle plugins development is not a new kid on the block - there are traces back to discussions from 2012.
Technically, adding Travis support to your Moodle plugin is as simple as adding a configuration file .travis.yml
into the root
directory of your plugin and allowing Travis builds to be triggered on certain events, such as pushing commits to the plugin's
repository at Github. This configuration file contains all the information needed to set up and execute all wanted tests and checks.
Somehow, you must describe what PHP version, what database type (such as MySQL or PostgreSQL) and what Moodle version (branch) you
want to use as the testing environment and what tests should be executed. There are good tutorials on
all these steps.
Luckily, no need to re-invent the wheel. There is a great tool developed by Mark Nielsen called moodle-plugin-ci that does all the magic for you. The tool provides a template of the travis configuration file - perfectly documented - as well as excellent usage information.
I successfully used Mark's tool to add Travis CI support into my Poster module easily. In fact, I was able to do that just in couple of minutes while my kids were cleaning their teeth before going to bed! I just made a trivial modification of the default template so that my plugin was tested against all 8 combinations of MySQL / PostgreSQL and Moodle 2.7 / 2.8 / 2.9 / 3.0. I am sure there is more elegant way to define such matrix in the YML file - but hey, how long do you brush your teeth for?
When I came back to the home office after having read the next chapter of The Magic Faraway Tree, I was just thrilled. It did not take long to travis to run all the builds and I could just enjoy browsing the detailed build logs.

I'll be honest with you. This is awesome. I am big fan of test driven development and I've been dreaming about this "build passing" icon for my Moodle plugins for ages. And I am really happy that I can now start adding Travis CI support for my other software projects. Big thanks to Mark for his great contribution!
Continuous integration is a vital practice in Moodle development. Having it
adopted for plugins development is a good sign of the developers' responsibility and their focus on the code quality. Indeed, all
these automated builds are only as good as the actual tests executed behind the scene. But still. This is just awesome