Skip to content

Instantly share code, notes, and snippets.

@timharding
Created September 30, 2009 20:54
Show Gist options
  • Save timharding/198442 to your computer and use it in GitHub Desktop.
Save timharding/198442 to your computer and use it in GitHub Desktop.
namespace :metrics do
namespace :check do
desc 'Fails the build if the metrics thresholds are not met'
task :thresholds => :'metrics:all' do
report_file_name = ""
if ENV['CC_BUILD_ARTIFACTS'] != nil
report_file_name = ENV['CC_BUILD_ARTIFACTS'] + '/report.yml'
else
report_file_name = RAILS_ROOT + '/tmp/metric_fu/report.yml'
end
puts "Checking thresholds from '#{report_file_name}'..."
metrics = YAML::load(File.open(report_file_name))
rcov_score = metrics[:rcov][:global_percent_run]
puts "Rcov score is #{rcov_score} of type #{rcov_score.class}"
if rcov_score < 100
puts "Score too low failing build"
raise 'Rcov score too low'
else
puts 'Complete c0 coverage. Hooray!'
end
puts 'Checked thresholds.'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment