I just finished adding coverage reports to cc this morning. I figured there may possibly be a better way to do this, but for those of you who want to do this and can't find any other way, here's a quick way to do so.

To do this just open up your cruise control rake file. I am using rspec so it was necessary for me to create this. If you do not have this configure yet you can download my example file HERE. All you need to do to get the coverage reports working is add this to your :cruise task.

1
2
3
4
5

if Rake.application.lookup('spec:rcov')
  CruiseControl::invoke_rake_task 'spec:rcov'
  system("ln -nsf #{RAILS_ROOT}/coverage #{CRUISE_ROOT}/public/coverage")
end    

This will run the spec:rcov task and symlink the results into the cruise control public directory. Don't forget to set the CRUISE_ROOT directory somewhere. I added it to the top of my rake file. Now when you point you browser to your cruise control instance/coverage you will get your rcov reports. There is one last thing to do here. I just modified my cruise control instance and added a link to the report so that it's easy to get a hold of. I just created a link to /coverage inside the app/views/projects/_project.rhtml partial so that the link shows up right after the checkin comments. It will show up if there are no errors in the build. Otherwise it will display the error message. I will create a patch shortly and put it up for download.

2 Responses Follows

  1. Dan Manges says
    I think the more conventional way to do this is to place the coverage reports in the directory set in ENV['CC_BUILD_ARTIFACTS'] . The report will then automatically be linked from the page for the build.
  2. Aaron says
    Thanks Dan! That's a great idea.

Sorry, comments are closed for this article.