Continuous Integration Goodness(TM) for Your Ruby Project
Posted by Nick Sieger Sat, 06 Jan 2007 15:42:00 GMT
As much as we’d like to think we live in a Ruby-glasses-colored world, the fact is there are plenty of neat toys out there that don’t know a bit about us. One that I’m currently enamoured with is Bamboo, Atlassian’s new continuous integration server. But, most commercial CI products are aiming for a wider market, and that means Java and Ant. Ant and JUnit predate Rake and Test::Unit by a few years, so I’m afraid they beat us to the punch, so that now the JUnit Ant task’s XML format is pretty much the first consideration for a continuous integration server to understand in order to display a test report for a build.
Where does that leave us Rubyists who want to play along with the bigs? Right here!. With support for not just RSpec, but Test::Unit too.
Right now, it’s packaged as a Rails plugin, because I’m lazy and I don’t need anything else right now. If you’re interested in a gem, please leave a comment. To install into your Rails app, the usual:
./script/plugin install http://svn.caldersphere.net/svn/main/ci_reporter
That’s it! Now all you have to do is have your CI server invoke an extra target before the main target that runs your tests.
For RSpec,
rake ci:setup_rspec spec
will leave one XML file per context in the spec/reports
directory (creating it if it doesn’t exist).
For Test::Unit,
rake ci:setup_testunit test
will leave one XML file per test case class in the test/reports
directory.
Most CI servers have configuration telling them where to look for test reports. Simply plug in one of these directories, and you’re set. Now sit back and watch your test or spec failures get tracked in your automated builds.
I’d love to see a gem (since I don’t do any real rails work).
Have you seen Cerberus?
Ah, that’s awesome.
I was thinking of doing this so I could use Hudson for doing continuous integration (check it out if you haven’t -- it’s awesome, and Free Software, too).
But, now someone did it for us!
Hey, There’s a small issue with it, the test unit reporter does not require ‘ci/reporter/core’ which causes errors.
@Chris: I haven’t checked out Cerberus yet, thanks for the link. I’ve been using Bamboo because we have a bunch of Java projects to build also.
Thanks for reporting the require issue. How did I miss that?!? Fixed now in svn.
Nick - thanks for the plug. Most appreciated!
While I have you, is there anything you think we could do to better support Ruby projects out of the box? I’m sure the team would love to hear about them.
We’re hardly Ruby experts here, but have dabbled quite a bit. I expect the features required by true Ruby houses would be far more useful coming from you than me :)
Thanks again, Mike
@Mike: Bamboo appears to work pretty well for Ruby right now. There are probably quite a few things (like what I did here) to make the integration tighter and track more items on Ruby and Rails projects (like the output of “rake stats” and possibly rcov coverage data). Detecting and adding a Rake builder would be a nice step.
There’s also potential for JRuby integration -- you could ship it and possibly have cross-platform, out-of-the-box Rake support, which would be pretty sweet.
Feel free to email me or come look for me in #jruby on freenode if you want to discuss further.
Nick,
You might also want to check our Parabuild. It will with any command line build tool and provides JUnit statistics.
junit can report whether a test has failed so that CruiseControl can pick that up and tag the build as failed.
@Chaskunz: All this does is generate an XML file after running your Ruby tests or specs. The files do flag test failures, but it’s up to the CI system to recognize that.
Rock on! Just integrated my rails plugins with Pulse. Sweet!