[Update: Please note that this approach has been replaced by a Dojo based solution available from http://www.ridgway.co.za/archive/2007/04/22/Dojo-Based-CruiseControl-Statistics-Graphs.aspx]
Lets face it, the new CruiseControl Statistics report is damn ugly and is not as useful as it could be. So I decided to remedy this by replacing the standard statistics xslt transform with one that generates both graphs and tables. The results are graphs in CruiseControl that look something like the images below. So what my new CruiseControl Statistics report gives you at the moment is as follows:
- Build Report Graph - the number of failed/successful builds per day and the last build of each day
- Build Duration Graph - the average and maximum build duration per day
- Test Summary Graph - the average number of tests that passed, failed or were ignored
- FxCop Summary Graph - the average number of warnings and errors per day
- Build Summary Statistics Table - a table containing the data that was used to generate the daily stats
- Build Detailed Statistics Table - contains the original detailed statistics data as would have been displayed in the old statistics report
Installation Instructions
I'll get on to the actual implementation in
another post, but for now here is how to get it working on your CruiseControl.Net build server:
- Download the latest stable release: CCNetStatisticsGraphs-1.3.zip . Updates are also present at the end of this post if you feel adventurous. [Note: I have a new version available that uses the Dojo library]
- Unzip the webdashboard folder over the current CruiseControl webdashboard folder (usually found at C:\Program Files\CruiseControl.NET)
- Open the dashboard.config file in the webdashboard folder and change the the projectStatisticsPlugin setting to point to the new StatisticsGraphs.xsl stylesheet, like this:
<projectStatisticsPlugin xslFileName="xsl\StatisticsGraphs.xsl" />
If it everything is in order you should see the following type of report when viewing your project statics:
Future improvements to this will largely depend on the interest generated by this post. If enough people find it useful I'll add new features. Of course if you extend it, please let me know about it. Some potential enhancements are:
- The ability to filter the report data
- Additional reports such as code coverage and complexity reports (based on whether or not the stats are present of course)
- Static table headers and sorting
Notes
Using PlotKit as the graph rendering engine unfortunately also results in the following issues in the graphs:
- Graphs where you would only expect integer values, display decimals. There does not seem to be any easy solution to this apart from modifying PlotKit code or ignoring the auto-scaled y-axis figures and writing one's own routine to determine the values and specify the y-axis tick values. [Integer y-axis values were implemented in version 1.4]
- There are problems with the labels being truncated on both the vertical and horizontal axis. One can alleviate the problem somewhat using different margins but at some point you run into trouble. The space required really needs to be determined dynamically (by the graphing engine). [Problem mostly removed in version 1.5]
- With the FxCop report it is difficult to predict whether or not the errors will be greater than warnings and vice-a-versa and hence you cannot use a filled line graph because it may cover up the one set of values. What would be nice is if you could have the one set of values peek through the other using alpha blending. Canvas does provide the ability to do this to some degree through the globalCompositeOperation property on the canvas, however this does not work in the IECanvas emulation layer.
Given the problems mentioned above I may very well switch to using another graphing approach or roll a modified version of Plotkit out.
Some of the suggested enhancements I have received are:
- Removal of outliers - Severe spikes completely mess up the scaling of the graphs. This one requires some thought because obviously it could also have the affect of making people believe that the graphs are incorrect when in fact the outliers have been removed.
- Horizontal scaling - Add in zero values to the graphs for missing days from the start of recorded builds. [Implemented in version 1.4]
- Removal of graphs if there no values - This one I had considered before and since someone else has asked for it, I'm going to implement it it. It's most obvious when you are not using FxCop and end up with a horrible empty grey block in your report. [Implemented in version 1.4]
Updates
- [Version 1.2 - 8 April 2007] - Fixed an issue caused by apostrophes in the generated statistics (new version 1.2 released) (reported by Grant Drake).
- [Version 1.3 - 8 April 2007] - Fixed an issue in the duration calculation where the duration had an int + string value which of course resulted in a string concatenation :) (reported by Grant Drake).
- [Version 1.4 - 9 April 2007] - Implemented the following features:
- Graphs are not displayed when there are no values for them
- The x-series values are now a timeline not just all the builds next to each other. So if there was a build on the 1st of a month and the next build was only on the 4th, zero values are filled in for the 2nd and 3rd of the month. This has a down side though because at the moment it is displaying weekends for which most projects will have no activity and if a project is worked on sporadically you have large gaps in the graph. I do believe however there is value in seeing the activity over time in this way and maybe it it worth having some sort of filtering option that allows one to remove weekends and/or days for which there are no statistics.
- The y-axis no longer displays values (I manually determined the y-ticks and added them to the graph).
Only download this release if you are curious about the new functionality. I will be writing a series of WatiN tests to ensure that everything is working as expected as the mini-project evolves. My biggest concern for this version is with locales specifically in relation to dates. To fill in missing days I've used JavaScript date functions and there is an assumption that the browser's locale is the same as that of the server. Unfortunately this is due to the fact that the CruiseControl month in the statistics xml file is a short name. Furthermore I cannot use the StartTime value because it is possible that the format of that information is not consistent: one of my example statistics files has StartTime values in both yyyy/MM/dd and dd/MM/yyyy format.
I found out on the 22 April 2007 that this version suffers from a daylight savings time bug that affected projects that started when daylight savings was in effect. I have fixed this release.
- [Version 1.5 - 10 April 2007] - Modified the PlotKit canvas to allow rendering of HTML labels (i.e. it won't escape your tags) and now draws the graph border and tick marks in the same colour as the axis label colour (I may remove this modification and simply create a new custom canvas). This has allowed me to reduce the font size of the x-axis labels and put the date on a separate line to the build label. Unfortunately it has also meant that I'm now distributing the uncompressed version of the PlotKit library (I may use a JavaScript compressor on them later). I found out on the 22 April 2007 that this version suffers from a daylight savings time bug that affected projects that started when daylight savings was in effect. I have fixed this release.
- [Version 2.1] - This is available from this post.