aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-07-23 15:37:19 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-07-23 15:37:19 +0900
commit14f517947a90146549947e49378bf44c6ab9c921 (patch)
tree44592995277785d44e6803866984502935482563
parentdd3b95e76c79c96c2749dc7948605fb1c21e7ad0 (diff)
downloadnyaci-14f517947a90146549947e49378bf44c6ab9c921.tar.gz
notification: report total elapsed time
-rw-r--r--notification.rb11
-rw-r--r--nyabuild.rb4
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)