How to use atoum with Sismo?

Sismo is not a Continuous Integration Servers (like Jenkins for instance). Sismo gets your code, runs your tests and sends you notifications.

“Sismo has been optimized to run locally on your computer for your Git projects. Even if it can test remote repositories, Sismo is better used as a local post-commit hook. Whenever you commit changes locally, Sismo runs the tests and give you immediate feedback before you actually push your modifications to the remote repository. So, Sismo is a nice complement to your Continuous Integration Server.” - sismo.sensiolabs.org

I like it because:

  • it’s simple to install: only one file, sismo.php
  • it shows build history by projects in the web interface
  • it can track multiple branches
  • it can build remote repositories
  • it’s simple to config: ~/.sismo/config.php` (by default)
  • Git projects build are in ~/.sismo/data/... (by default)
.sismo
├── config.php
└── data
    └── build
    │   └── ...
    └── sismo.db
  • its web interface is great to get an overview of your repositories

Your project unit tested with atoum versioned with git

For this exemple, I’ll use the same project “Unit test with atoum installed with composer” which is located in ~/test-project with this files structure:

.
├── .git
│   └── ...
├── .gitignore
├── .gitmodules
├── bin
│   └── atoum -> ../vendor/mageekguy/atoum/bin/atoum
├── classes
│   └── helloWorld.php
├── composer.json
├── composer.lock
├── composer.phar
├── tests
│   └── units
│       └── testHelloWorld.php
└── vendor
    ├── autoload.php
    ├── composer
    │   └── ...
    └── mageekguy
        └── atoum
        ...

.gitignore

It’s very important to not ignore vendor/, at least vendor/mageekguy, because bin/atoum is a symbolic link to vendor/mageekguy/atoum/bin/atoum.

composer.lock
composer.phar

.gitmodules

Dependencies installed with composer are Git projects. It means that you need to map these dependencies / modules in .gitmodules file. We only have atoum here so let’s map it. Create this file if you don’t have it.

[submodule "vendor/mageekguy/atoum"]
    path = vendor/mageekguy/atoum
    url = git://github.com/mageekguy/atoum.git

Let’s install Sismo

Install sismo.php wherever in your web directory - for instance /var/www.

$ mkdir -p /var/www/sismo
$ wget -P !!:2 http://sismo.sensiolabs.org/get/sismo.php

Let’s configure this project in Sismo

We need to configure this project (title, slug and path - change the user name), select a branch (master) and the command (atoum of course) to launch afterwards. It also possible to set a notification, let’s say we use Growl. Edit ~/.sismo/config.php:

$projects = array();

$notifier = new Sismo\Notifier\GrowlNotifier('pa$$word');

$helloWorldProject = new Sismo\Project('Hello World');
$helloWorldProject->setRepository('/home/antoine/test-project');
$helloWorldProject->setBranch('master');
$helloWorldProject->setCommand('./bin/atoum -d ./tests');
$helloWorldProject->setSlug('hello-world-local');
$helloWorldProject->addNotifier($notifier);
$projects[] = $helloWorldProject;

return $projects;

Let’s run Sismo when you commit some changes

Create ~/test-project/.git/hooks/post-commit and add:

#!/bin/sh

php /var/www/sismo/sismo.php --quiet build hello-world-local `git log -1 HEAD --pretty="%H"` &
$ chmod a+x ~/test-project/.git/hooks/post-commit

Let’s build !

$ php /var/www/sismo/sismo.php build --verbose

Success: 'Sismo and atoum - success build in CLI'

If his build fails, Sismo will send notifications. Use the output command to see the latest build output of a project (slug):

$ php /var/www/sismo/sismo.php output hello-world-local

'Sismo and atoum - output of the last build in CLI'

Web interface

For exemple: http://127.0.0.1/sismo/sismo.php 'Sismo and atoum - web interface with the output of the last build'

Troubleshooting

If you get “Hmmm, looks like something went wrong - an error occured” like this screenshot: 'Sismo and atoum - Hmmm, looks like something went wrong - an error occured' Please check the right of your webserver for ~/.sismo/data/sismo.db which should be writable.

If your web server runs under a different user than the one you use on the CLI, you will need to set some environment variables in your apache virtual host configuration:

SetEnv SISMO_DATA_PATH "/path/to/sismo/data"
SetEnv SISMO_CONFIG_PATH "/path/to/sismo/config"

Conclusion

As you can see Sismo works like a charm with atoum ! There is no more excuse to not use atoum if you are a Sismo user ;) Thanks to Fabien Potencier (@fabpot) and Frédéric Hardy (@mageekguy) for their tools & frameworks !

Antoine Corcy

Developer / Copenhagen

Copenhagen, Denmark http://sbin.dk