Continuous Integration: Cerberus 13

Posted by yrashk

Jordan Arentsen said that he would like to read about Continuous Integration. With a great pleasure!

I would like to talk about Cerberus tool and how we apply it in particular. Cerberus is a great simple tool to perform rake tasks continuously on your project whenever it updates.

I will guide you through the setup.

  • First of all, make sure that your subversion client is at least at version 1.2. It will not work with earlier versions.
  • Setup an email alias for notifications, something like dev-foobar@foobar.com that will forward any email (except spam!) to your team.
  • Then, simply install Cerberus from a gem: gem install cerberus
  • Create a user for cerberus: adduser -m cerberus, passwd cerberus
  • Log in as a cerberus (or just use sudo -H -u cerberus as a prefix)
  • Assuming you have a project at file:///var/lib/svn/foobar/foobar/trunk just do
 
cerberus add file:///var/lib/svn/foobar/foobar/trunk  \
               APPLICATION_NAME=FooBar \
              RECIPIENTS=dev-foobar@foobar.com
 
  • Open /home/cerberus/.cerberus/config.yml and specify there such parameters:
 
publisher:
#  active: mail jabber rss campfire irc
  active: mail campfire # you may also use irc, jabber and rss,
                                     # which we are not using at the moment
  mail:
    sender: cerberus@foobar.com
    address: foobar.com
    port: 25
    domain: foobar.com
    #authentication: plain
    #user_name: someuser
    #password: somepassword
  campfire:
    url: http://cerberus@foobar.com:crbrs@foobar.campfirenow.com/room/58153
#  jabber:
#    jid: cerberus@gtalk.google.com
#    port: 5222
#    password: mypass
#    digest: false
#  irc:
#    nick: cerb
#    server: irc.freenode.net
#    channel: cerberus
#  rss:
#    file: /usr/www/rss.xml
builder:
  rake:
    task: db:migrate # we are also adding here 'spec spec_with_rcov ', since we use
                                # both RSpec and RCov
 
* Then, open /home/cerberus/.cerberus/config/FooBar.yml and edit it:
 
---
publisher:
  mail:
      recipients: dev-foobar@foobar.com
  # specify the rest publishers per project parameters here
scm: 
  type: svn
  url: file:///var/lib/svn/foobar/foobar/trunk
changeset_url: http://trac.foobar.com/changeset/  # If you have Trac (you should! :), integrate with it                                                                                  
 
  • You can override system-wide settings (/home/cerberus/.cerberus/config.yml) with project-wide settings (/home/cerberus/.cerberus/config/FooBar.yml), (I’d suggest to pay attention to at least builder: => rake:) (consider looking at a full list)
  • You can perform a test by typing cerberus build FooBar. It will email you about project setup.
* Now, add it to crontab to run it as frequently as you wish. It does not consumes much time if there was no fresh checkins in a repository, it only runs tests against your code if your repository was updated. We use to run Cerberus each 10 minutes:
 
*/10 * * * * cerberus buildall

  • You’re done!

Few more tips:

  • If you want Cerberus to rebuild FooBar from the scratch, simply rm -rf /home/cerberus/.cerberus/work/FooBar
  • I strongly recommend to generate RCov diagram each time Cerberus runs. Here is how you can integrate RCov with RSpec:

lib/tasks/rcov.task:


require 'rake'
require 'spec/rake/spectask'

Spec::Rake::SpecTask.new('spec_with_rcov') do |t|
    t.rcov = true
 end

  • To integrate it without RSpec, look here (not sure it is what you need exactly, however)
  • Then simply symlink generated coverage directory to some web-accessible (preferably httpauth protected)

I will try to talk more on a coverage analysis later. Now it’s too late (or too early, 4:45 AM)