From 7bf02617c77435bf33ac42100239314d30247e7a Mon Sep 17 00:00:00 2001 From: Kamran Farhadi Date: Mon, 9 Jan 2023 15:39:10 -0500 Subject: [PATCH] Fix bug with reporting duration of rerun workflows --- report_github_metrics.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/report_github_metrics.rb b/report_github_metrics.rb index 8771be7..d93bcc6 100644 --- a/report_github_metrics.rb +++ b/report_github_metrics.rb @@ -4,9 +4,9 @@ require 'date' require 'json' -def collect_metrics(jobs, tags) +def collect_metrics(workflow, jobs, tags) jobs.map{|job| collect_job_metrics(job, tags)}.compact + \ - collect_workflow_metrics(jobs, tags) + collect_workflow_metrics(workflow, jobs, tags) end def collect_job_metrics(job, tags) @@ -18,8 +18,8 @@ def collect_job_metrics(job, tags) ] end -def collect_workflow_metrics(jobs, tags) - start = jobs.min_by{|job| job["started_at"]}["started_at"] +def collect_workflow_metrics(workflow, jobs, tags) + start = workflow["run_started_at"] finish = jobs.max_by{|job| job["completed_at"]}["completed_at"] status = if jobs.any?{|job| job["conclusion"] == "cancelled"} "cancelled" @@ -93,7 +93,7 @@ def collect_duration_data(github_client, repo, run) if TAGGED_BRANCHES != [] tags += ["branch:#{TAGGED_BRANCHES.include?(branch) ? branch : "other" }"] end - collect_metrics(jobs, tags) + collect_metrics(workflow, jobs, tags) end def parse_array_input(arg)