Thursday, November 3, 2011

Continuous Integration Part I

I'm setting up a suite of continuous integration tools for my current job. We are a PHP shop using Mercurial for version control. My catalogue of tools is as follows (so far):

  • Ant (automated build tool)
  • PHPUnit (unit testing)
  • Selenium (functional testing)


I haven't decided on a CI server, yet. I'm looking at Hudson, as it has an extension to support Mercurial. Eventually, I'm hoping we'll use a service, like SauceLabs' Sauce OnDemand to perform our functional tests, since I'd like to take advantage of their cross-browser tests. They use Selenium RC, so we'll want to get started using that, ourselves. As of version 3, PHPUnit has support for writing tests for Selenium. I don't know, yet, whether those would work with SauceLabs, nor do I know whether we'll use those or write our scripts the traditional way, as per the documentation on the Selenium site. Another thing to note is that Selenium RC (Selenium 1) is officially deprecated in favor of Selenium Webdriver (Selenium 2), but they're going to support Selenium RC, doing bug fixes and the like, as it has more features than Webdriver (at least for now).

To get Ant to work with Mercurial, I'm going to need ANT4HG.

I still need to ascertain what all, exactly, will go into my build process. I want it to represent a complete rebuild of our entire Web app from scratch, complete with a set of clean test data and the application code, as well as all tests. I'm suspicious, however, that there will be more to it than doing a clean check out (in hg terms, a clone) of our code base and grabbing a db schema from somewhere, but we'll see.

Tasks done so far:

  1. I've installed PHPUnit using Pear (which I had already installed through Macports when I installed php-5). 
  2. I have installed Ant (an Apache project) using Macports.
  3. Installed ANT4HG as follows:
To install ANT4HG, I downloaded the binary from the SourceForge downloads. I extracted the zip file and ended up with a jar file. I then moved the jar file to the ant lib directory. On my system, that is located here: /opt/local/share/java/apache-ant/lib. It should now be available for Ant to use.


OK, now for Selenium (deep breath). I need the Selenium standalone server. Eventually, I won't need this (I hope), since we'll rely on SauceLabs for this service. But for the purposes of setting up a test of our chosen tools - and also because we're not going to subscribe to a service, yet - I need to have it up and running locally. I'm following instructions I found here, with the exception that I put my selenium jar file in /opt/local/share/java/selenium instead of /usr/lib/selenium. (Either way, I needed to create the selenium directory.)

I then created a launch file so that Selenium would be launched on system startup. The file is copied from the instructions I used on Dan Straw's site. Since my "selenium" directory is in a different location than his, I had to modify my launch file to reflect the proper location. I also had to change the name of the jar file, as he mentions in his write-up. I loaded the plist file and started the service. Using "ps auxwww | grep -i selenium" I learned that it's up and running. Good.

Everything is installed, now, so I just need to get my feet wet and play with it. I'll save that for another post. In the meantime, I'll be looking this.

No comments:

Post a Comment