Bamboo formatter for SimpleCov
Note: To learn more about SimpleCov, check out the main repo at https://github.com/colszowka/simplecov
SimpleCov-Bamboo is a result formatter for SimpleCov that helps one to integrate SimpleCov into the Atlassian Bamboo Continuous Integration Server.
The formatter creates a file called clover.xml in the coverage directory, which contains a minimal subset of the coverage information generated by clover. It also uses the default HTMLGenerator to generates the HTML Coverage Report to target/site/clover, which is the location expected by Bamboo.
Getting Started
-
Add the SimpleCov-Bamboo gem to test group your Gemfile:
gem 'simplecov-bamboo', :require => false, :group => "test"
-
Configure SimpleCov in your test helper:
SimpleCov.coverage_dir('target/coverage') # optional SimpleCov.formatter = SimpleCov::Formatter::BambooFormatter
-
Configure Bamboo to process Clover coverage information
See: https://confluence.atlassian.com/display/BAMBOO/Using+Bamboo+with+Clover
On the miscellaneous tab when configuring your build job (not the plan):
- Check 'Use Clover to collect Code Coverage for this build.'
- Select 'Clover is already integrated into this build and a clover.xml file will be produced'
- Enter your coverage directory into the 'Clover XML Location' field; for example: target/coverage
Results
After the next build, you can now browse your coverage information for the build:
- See the Clover tab of the Build Plan Details for coverage and loc trends for the porject; and for a link to the latest coverage report.
- You can also access the coverage report for a particular build result. Navigate to the build result and select the results for the job, where the coverage report was published. You may need to expand the Tree Navigation bar on the left of the page to select the job results. From the job results, select the Clover tab to view the coverage report.
Background
For code coverage reporting, Bamboo has native support for Clover (Java and Groovy) and NCover (.NET). Unfortunately, there is no native (or plugin support) for displaying Ruby coverage information.
I first looked at building a Bamboo plugin to support SimpleCov, but determined it would be much easier to just transform the SimpleCov output to be Clover-like.
There is actually on a very small amount of information that is processed by Bamboo directly in the clover.xml results file: total elements, covered elements, and non-comment lines of code (at the entire project level). So, I generate the minimal clover.xml file.
The second thing that Bamboo is expecting is an HTML coverage report to be published to target/site/clover, so I also invoke the HTMLFormatter and force it to produce it's output at that location.
Compatibility
I have tested this project with Bamboo 5.0, but it should likely work with earlier versions. Native Clover support has been in-place since Bamboo 2.4.
Credits
Code based on SimpleCov/SimpleCov-HTML by Christoph Olszowka. Modified by Daryl Robbins to generate the results expected by Bamboo.