Simple continuous integration with PHP and subversion (or any other version control system)

Tags

php
svn

I work on a project in a subversion repository. Because knowing is half the battle, I wanted some kind of continuous integration on the project. Earlier I explained how you can use cijoe with github projects, but that was not an option. I wanted something simple, and came up with the following solution.

I already had a development server set up, and the test suite was written in PHPUnit. I wanted the test suite to be run regularly and notify me, if the tests did not pass. I solved it by a cron job updating the subversion repository and running the test suite, and a test listener informing me about the result.

The test listener

First I wrote the test listener. I basically just count whether there is any errors and failures. If there is, it notifies me via notifo.com, but you could also send an e-mail or anything similar.

To attach the listener to your test suite, I used the following XML-configuration:

Now I am able to run the test suite from the command line with the following command:

$ phpunit .

Putting it all together

I wrote a bash script to update the repository and run the test suite. It is really simple:

The script checks whether the repository has been updated. If it has, a local update is performed and the test suite is run. Now to make it continuous integration I just need to create a cronjob running the script on a regular basis.

Improvements

  • Make sure that new builds are run in order and does not interfere with previous builds.

Could it be more simple? What do you think of this approach?

Tilføj kommentar