diff options
-rw-r--r-- | notification.rb | 11 | ||||
-rw-r--r-- | nyabuild.rb | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/notification.rb b/notification.rb index 169fbf5..56d25a8 100644 --- a/notification.rb +++ b/notification.rb @@ -37,7 +37,7 @@ class Notification } end - def publish(project, jobid, results) + def publish(project, jobid, results, elapsed) prefix = "[NyaCI] [#{project}/#{jobid}]" results.sort_by! { |id, result| id } @@ -45,7 +45,7 @@ class Notification if failed == 0 subject = prefix + " success" body = <<~EOM - All test cases passed successfully: + All test cases passed successfully in #{elapsed} seconds: #{results.map { |id, res| "- #{id}" }.join("\n")} @@ -54,7 +54,7 @@ class Notification else subject = prefix + " #{failed}/#{results.size} failed" body = <<~EOM - The following test cases failed: + The following test cases failed in #{elapsed} seconds: #{results.select { |id, res| !res } .map { |id, res| "- #{id}" }.join("\n")} @@ -77,12 +77,13 @@ class Notification @webhook = webhook end - def publish(project, jobid, results) + def publish(project, jobid, results, elapsed) failed = results.count { |id, result| !result } link = NyaConfig.webroot + "/" + project + "/" + jobid result = failed == 0 ? "passed" : "failed" - ary = ["nyaci build <#{link}|#{project}/#{jobid}> #{result}."] + ary = ["nyaci build <#{link}|#{project}/#{jobid}> #{result} " \ + "in #{elapsed} seconds."] if failed != 0 ary << "failed builds:" results.select { |id, r| !r }.map { |id, r| id }.sort.each { |i| diff --git a/nyabuild.rb b/nyabuild.rb index 0428c1d..436976b 100644 --- a/nyabuild.rb +++ b/nyabuild.rb @@ -125,6 +125,7 @@ class NyaBuild def run patterns = @project.matrix.dup + beg = Time.now NyaConfig.parallelism.times.map { |x| Thread.start { while ary = patterns.pop @@ -132,8 +133,9 @@ class NyaBuild end } }.map(&:join) + elapsed = Time.now - beg - NyaConfig.notification.publish(@project_id, @jobid, @results) + NyaConfig.notification.publish(@project_id, @jobid, @results, elapsed) end def do_pattern(ary) |