HOWTO: Continuous integration for PHP, pt. 4
This is the fourth article in my series about continuous integration for PHP. You might want to read the first, second and third article prior to this.
We're getting closer and closer to full test automation and continuous integration. The last article introduced you to how to write PHPUnit tests for SeleniumRC so that we can test website frontends through PHPUnit. After that we wrote our own phing build script that ran our backend as well as the frontend tests automatically, generated an code coverage report based on Xdebug as well as an comprehensive APIDoc based on PHPDoc comments.
The phing build script we used for this - test.xml - was executed manually by calling
phing -f test.xml
on the command line. Everything happened on the development virtual host.
The next logical step is to automate this and perform the additional tasks required to run continuous integration.
The first step is to do a manual svn checkout on the integration virtual host, so we have setup that is identical to the development virtual host.
Now, what the automation will have to do is a Subversion update of the integration virtual host in order to retrieve the latest copy. If the revision changes in that process (that is, if we indeed fetched newer files from Subversion) we again run the tests and generate the reports. If all tests succeed we can safely assume that we have a running system, and we can decide to create a tarball from it or update the staging system for our project manager / client to check it out. On the other hand, if a test fails we'd like to be notified by email.
This is exactly what a second phing build script will do.
New VM, first tests with Phing
I spent some time today to set up a new Virtual Machine. My current development system is based on Ubuntu Intrepid and starts acting up. I can't really isolate the issue, some network trouble is there.
Anyways... originally I just wanted to tap a bit into test automation [1, 2] but I ended up downloading the 32bit server version of Ubuntu Koala. With my crappy Tata Photon+ it took a while until the CD .iso file was there but after that it went smooth. The installation system is pretty straight forward and did a decent job of detecting my keyboard.
I chose the LAMP, OpenSSH, Samba packages and let it install.
After that it was just a matter of installing a few more php packages, along with PEAR. This enabled me to set up everything I needed to get a glimpse of what test automation is all about.
# install PHPUnit (make sure you catch the dependencies)
> pear channel-discover pear.phpunit.de
> pear install phpunit/PHPUnit
# install PhpDocumentor
> pear install PhpDocumentor
# install Phing (once more, cover the dependencies)
> pear channel-discover pear.phing.info
> pear install phing/phing
In case you're in doubt what all this means:
PHPUnit is the unittesting tool for PHP, a clone of JUnit basically...
PhpDocumentor generates a Html (.pdf, ...) API Doc out of your source code comments...
and finally Phing is a build tool written in and for PHP.
The whole setup tool me less than two hours after the .iso file was there, and that includes additional things like setting up a Samba share and configuring two VirtualHosts for Apache. Really cool and really really smooth.
Now with a short but to-the-point article on Linux.com I got a test scenario running. What joy! you simply enter 'phing' on the commandline and the tools clear up the build filesystem, fill the build again with the latest version of the software, run PhpDocumentor to generate the up-to-date APIDoc, then run all unittests and in case those succeed they generate a tarball with the whole system.
How cool is that?! Really impressive. Those who know me also know that it's hard to impress me
.
[Update: By now there is a much more in depth series of articles online here in my blog]


Xing Profile