Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --markdown-output and unclassified failures count to scripts/bors-stats.rb #3127

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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