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)

Comments

Leave a response

  1. Jordan ArentsenJanuary 10, 2007 @ 11:53 PM

    Thanks a lot Yurii. I’m definitely going to try this out in the future.

  2. shngnJanuary 11, 2007 @ 01:17 PM

    A quicker way to force a rebuild is to just delete /home/cerberus/.cerberus/work/FooBar/status.log. That way it won’t have to checkout everything again.

  3. Andrey KhavryuchenkoJanuary 11, 2007 @ 02:49 PM

    Yes, lovely thingie

  4. antonio_eggberg@yahoo.seJanuary 11, 2007 @ 04:34 PM

    Why Cerberus? Why not ZentTest? Have you tried that?

    http://www.zenspider.com/ZSS/Products/ZenTest/

    It has autotest as far as I can tell. Note I have not used it.. I am just getting/setting my development env. and trying to figure out whats the easiest solution on a day to day basis rather then setup..

    I would like to hear your view. I don’t know wheather rcov will work with ZenTest..

    Regards.

  5. Yurii RashkovskiiJanuary 11, 2007 @ 04:42 PM

    Antonio,

    You could take a look at http://www.robbyonrails.com/articles/2007/01/10/the-zen-of-auto-rspec

    Actually, it seems that Cerberus and autorspec seems to serve different needs. Cerberus makes you sure you haven’t broke your code in repository and autorspec helps you to monitor how your local code changes affect tests.

  6. antonio_eggberg@yahoo.seJanuary 11, 2007 @ 05:10 PM

    Thank you for the answer.. I read that post and I read your post so I was a bit confused. Now its clear. On another point I like your productive developer post.. Any more tips that you have in your bag and would like to share :=)

    Thanks!

  7. Yurii RashkovskiiJanuary 11, 2007 @ 05:15 PM

    Antonio,

    Yes, I’m going to post more various tips on my blog, including Rails-specific.

    Stay tuned! :)

  8. Anatol PomozovJanuary 12, 2007 @ 07:25 AM

    Hi, All.

    First I would like to admit that Yuri have written great blog article about Cerberus.

    About rebuilding:

    To rebuild cerberus project you could also run build command with—force flag.

    something like this

    cerberus—force build MyNewCoolProject

    it would run tests even sources are unchanged. It would be helpful when you change environment like installing new gems.

    If you remove status.log file cerberus would think that you just setup project. (Remember that status.log contains results of previous build).

    And as was mentioned before you could just remove full work directory – cerberus would automatically checkout project again. It would be helpful if you change sources in your cerberus/work directory and would like to be sure that cerberus contains clean sources.

    Also take into account that if you have subversion repository on your own server it would be preferable for you to run cerberus from subversion hook. http://svnbook.red-bean.com/en/1.1/ch05s02.html#svn-ch-5-sect-2.1

    Also I am very glad that people interesting in Cerberus. I made this software for myself (and my customers) because I did not find anything that would help me keep my project’s tests in a good shape. Now I see that it helps to others also.

  9. Yurii RashkovskiiJanuary 12, 2007 @ 07:32 AM

    Anatol,

    Thank you for creating Cerberus! And thank you for your tip about --force, I have missed this option for some reason.

    Software which is written for own needs is always pretty nice!

  10. Alex PashinJanuary 19, 2007 @ 03:57 AM

    Check our Parabuild. The whole installation is a single command:

    sudo sh parabuild_3_1_0_linux.sh -q

    —AP

  11. Jonathan TronJanuary 26, 2007 @ 12:25 PM

    Anatol,

    I really liked the idea of running Cerberus from subversion hook, but I found no simple way to run it asynchronously, I mean launch the Cerberus build process and don’t wait for it to finish to allow the commit.

    I understand such an approach can have implication on Cerberus way to handle build, for example : what if the previous Cerberus build command is not finished when another commit occurs ? But do you think anytime we would see Cerberus fork a new process for build or run as a daemon allowing us to just tell it to build and immediately return to process the commit ?

  12. Wilfred BeasleyDecember 20, 2007 @ 02:48 PM

    disannuller trikeria testamentary gemmiform tumuli outmalaprop muffin unemancipable Cadron Creek Christian Curriculum http://www.magickalmayhem.com

  13. fatihDecember 24, 2007 @ 07:18 PM

    sfgawf

Comment