Showing posts with label continuous integration. Show all posts
Showing posts with label continuous integration. Show all posts

Sunday, June 24, 2007

CruiseControl.rb and RCov Are SO Good Together

I spent a bit of time this morning getting CruiseControl.rb and RCov working together for a new client's fairly LARGE Ruby on Rails (70+ models, 40+ controllers) project. If you are not familiar with CruiseControl.rb, it is the Ruby based continuous integration tool from ThoughtWorks. RCov, on the other hand, is a very well known code coverage tool for Ruby. The implementation was incredibly simple, but finding the information on how to get the two working together required a perusal of the CruiseControl.rb code itself.

First of all, you will need to install the rails_rcov plugin. This useful plugin allows you to really easily run RCov using rake, and is essential to simple RCov integration with your CruiseControl.rb builds. You can install rails_rcov like this:


./script/plugin install http://svn.codahale.com/rails_rcov


Use the "-x" option if you want to use an svn:external link to the latest version of the plugin. I personally don't like to do that...I want control over when the software I am using gets updated, thanks.

Once the plugin is installed into your project you have some useful rake tasks like this one:


# sort by coverage
rake test:units:rcov RCOV_PARAMS="--sort=coverage"


Now you are ready for the final bit, which is adding a "cruise.rake" task to the "lib/tasks" directory of your Ruby on Rails project. The task should have something like this, which was lifted verbatim from the CruiseControl.rb build of CruiseControl.rb itself (that all sounds kinda twisted, but it is cool):


desc 'Continuous build target'
task :cruise do
out = ENV['CC_BUILD_ARTIFACTS']
mkdir_p out unless File.directory? out if out

ENV['SHOW_ONLY'] = 'models,lib,helpers'
Rake::Task["test:units:rcov"].invoke
mv 'coverage/units', "#{out}/unit test coverage" if out

ENV['SHOW_ONLY'] = 'controllers'
Rake::Task["test:functionals:rcov"].invoke
mv 'coverage/functionals', "#{out}/functional test coverage" if out

Rake::Task["test:integration"].invoke
end


That's it. Now you have incredible code coverage goodness right within your build. You can even browse the source within the browser window of the CruiseControl.rb dashboard and see which lines of code were covered by your tests, and which were not...

So if you have a Ruby on Rails project, with a project team of greater than 1 developer, you had better start using CruiseControl.rb. It is too easy, and the payoff of doing continuous integration is huge!

Tuesday, March 13, 2007

CruiseControl.rb: Continuous Integration Is About To Get Beautiful

At last, Ruby has a real Continuous Integration system, not just some crazy hacked-together solution. Nothing against crazy, hacked-together solutions, but your CI system is not the place for such madness. From those wonderful folks at Thoughtworks, we now have CruiseControl.rb, to join the CruiseControl and CruiseControl.NET offerings for Java and .NET projects respectively.

I have been a constant user of CruiseControl.NET for all of the MS-platform projects for the last couple of years, and having a powerful, flexible system has been great. However, having to pay heavily of the angle-bracket tax to create the XML for the NAnt build scripts, CC.NET config files, and pretty much everything else has been a real pain. The pleasure has been the real-time integration with the CCTray notification program (shows up red in your system tray, and pops up a balloon notification when a build has been broken).

Now, a pure Ruby solution has been created. Although a very young offering, the incredible simplicity of Ruby allows a far easier extensibility than the other CruiseControl options. Here are a few of the interesting features:


  • All CruiseControl.rb config files are Ruby, for nice DSL-ish syntax

  • Uses Rake by default for builds, but can support NAnt, Ant, MSBuild or anything other build tool. In other words you CAN use CruiseControl.rb as your CI systems for any target language or environment, not just for Ruby or Ruby on Rails projects.

  • Build messages can be sent via IM using Jabber

  • The same CCTray system tray application can monitor CruiseControl.rb servers as well as CruiseControl.NET servers.



CruiseControl.rb looks to have the core features required for a decent, even an amazing CI system. However, being such a new tool it still lacks some really cool and useful add-on things like integration with Fitnesse, Simian code analysis, and the other neat add-ons that can easily integrate with CruiseControl.NET. Given that the CruiseControl.rb is pure Ruby, and the prolific nature of the Ruby open source community, I would not be surprised if those gaps are filled very quickly.

Rock on, Thoughtworks!