Continuous Delivery - Part 2: Code metrics with metrical
leenaJuly 31, 2011
Metrical is for easier metric_fu setup. You can see the details on why and how here. Its an awesome tool which allows us to easily use metric_fu without adding any dependency to the project code.
The steps I followed for setting it up in our Jenkins server are:
- Install the gem. I installed it under our ruby 1.9.2 in RVM.
- Create a .metrics file under your projects directory with the settings. This is not mandatory, but I had to use this because some configurations do not seem to be working with ruby 1.9.2. I’ve mentioned those below along with the contents of the .metrics file
- Create a job in Jenkins server, mention the repository details and for build step give the shell command as rvm 1.9.2 -S metrical
- Configure the HTML Publisher plugin for showing the nice Graphs generated by metric_fu as part of the build report. The default report location is tmp/metric_fu/output under the project directory. You can change the same in .metrics file.
As I mentioned above, tools such as flay and flog, which comes as part of metric_fu, have issues working with ruby 1.9.2. And the same case with stats graph and syntax highlighting. The same case with rcov also. So I had to create a metrics file with the following contents and put in the project dir:
MetricFu::Configuration.run do |config|
config.code_dirs = ['app', 'lib']
config.syntax_highlighting = false
config.metrics = [:churn,:reek,:roodi,:hotspots,:rails_best_practices]
config.graphs = [:reek, :roodi, :rails_best_practices]
config.rcov[:test_files] = ['spec/**/* _spec.rb']
config.rcov[:rcov_opts] << "-Ispec" # Needed to find spec_helper
end
For test coverage I’ve used Simplecov which is easy to setup. It will generate the coverage report whenever you run the tests. This also generated html report which can be integrated easily into Jenkins. As mentioned here in the issue list, it does not generate the report when you are running with spork.
Continued..