Skip to content

Commit

Permalink
Merge pull request #3127 from input-output-hk/anviking/improve-bors-s…
Browse files Browse the repository at this point in the history
…tats

Add --markdown-output and unclassified failures count to scripts/bors-stats.rb
  • Loading branch information
rvl authored Feb 11, 2022
2 parents c9109cf + 428f50b commit bf27d43
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions scripts/bors-stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BorsStats < Thor
:long_desc => "`--group #1 #2 #3` will replace #2 and #3 with #1."

desc "list", "list all failures"
method_option :markdown_output, :type => :boolean, :required => false, :desc => "Create markdown links to issues"
def list()
comments = fetch_comments_with_options options

Expand All @@ -74,17 +75,28 @@ def list()
nSucc = comments[:filtered].filter { |x| x.succeeded }.length
nFailed = nTot - nSucc

# this logic could be moved to the `breakdown` function.
nFailedNoCause = comments[:filtered].filter { |c| (not c.succeeded) and c.causes.empty? }.length

puts ""
puts "succeeded: " + (bold nSucc.to_s) + " failed: " + (bold nFailed.to_s) + " (" + (bold (failure_rate(nFailed, nTot))) + ") total: " + (bold nTot.to_s)
puts "Excluding " + nExcluded.to_s + " #expected or #duplicate failures"
puts "Unclassified: " + (bold nFailedNoCause.to_s) + " (" + (bold (failure_rate(nFailedNoCause, nFailed))) + " of all failures)"
puts ""
puts "Broken down by tags/issues:"
breakdown(comments[:filtered],tm).each do |k,v|
t = k[:tag]
n = k[:n]
title = tm.dig t, "title"
title = title.nil? ? "" : title
puts (bold(n.to_s) + " times (" + bold(failure_rate(n, nTot)) + ") " + yellow(t) + " " + bold(title))

tag_str =
if options[:markdown_output] and is_issue? t
then "[" + t + "](https://github.com/input-output-hk/cardano-wallet/issues/" + t.delete_prefix("#") + ")"
else yellow t
end

puts (bold(n.to_s) + " times (" + bold(failure_rate(n, nTot)) + ") " + tag_str + " " + bold(title))
end
end

Expand Down Expand Up @@ -146,7 +158,7 @@ def try_fetch_system(comment)
# build.
BorsComment = Struct.new(:url, :bodyText, :links, :createdAt, :tags, :succeeded) do
def causes
self.tags.filter {|x| x.start_with? "#" }
self.tags.filter {|x| x != "hydra" and x != "buildkite" } # HACK; works for now
end

def pretty(showDetails = :auto)
Expand Down Expand Up @@ -664,6 +676,16 @@ def rewrite_tags(comments, title_map)
end
end

##
# >>> is_issue? "#0"
# true
#
## >>> is_issue? "0"
# false
def is_issue? t
true if t.start_with? "#" and Integer(t.delete_prefix "#") rescue false
end

######################################################################
# ANSI color code helpers

Expand Down

0 comments on commit bf27d43

Please sign in to comment.