Hudson and Silverstripe for automated testing

silverstripe continous integration

Hudson CI is a continuous integration server software that basically is a glorified build script. With it you can take control over the quality of you code and make sure that every commit you do get measured according to the laws of quality.

Disclaimer: This is currently under development / investigation from me, so I wouldn't go "hard-core-copy-and-pasta" and expect everything to work. But if you're stuck when setting up your own hudson / silverstripe, it might be helpful.

Requirements

Install hudson

sudo su
apt-get install sun-java6-jdk
apt-get install daemon
wget -O /tmp/key http://hudson-ci.org/debian/hudson-ci.org.key
sudo apt-key add /tmp/key
wget -O /tmp/hudson.deb http://hudson-ci.org/latest/debian/hudson.deb
dpkg --install /tmp/hudson.deb
apt-get update
apt-get install hudson

No you should be able to see hudson on http://{hostname}:8080

Install GIT plugin in hudson

Go here inside the hudson web adminstration: Manage Hudson => Manage Plugins => Available Install these plugins:

Create project in hudson

Create a new project and choose git as SCM, I've only set this up with a local path to the repository ( my hudson is located on the same place as my git origin remote)

Set up hudson users git

Use the email and user name configure in your github account

sudo su - hudson
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

Setup ssh keys and generate them as github want's it link

Now should be the time to clone your repository to the /tmp/ to check that the ssh all work fine and dandy

Try building the project

Try building the project so you can see that hudson can clone the repository correctly

Install PHPUnit

sudo su
apt-get install php-pear
pear upgrade
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit --alldeps

Install xdebug (for coverage reports)

apt-get install php5-dev
pecl install xdebug
echo zend_extension=\"`find /usr/lib -name 'xdebug.so'`\" > /etc/php5/conf.d/xdebug.ini

Check that phpunit works

phpunit --version

Add buildscript to Hudson

Execute shell

mkdir -p $WORKSPACE/logs
rm -rf $WORKSPACE/logs/*
mkdir -p $WORKSPACE/silverstripe-cache
rm -rf $WORKSPACE/silverstripe-cache/*
cd $WORKSPACE/
phpunit --coverage-clover ./logs/clover.xml . '' flush=all