Skip to content

Commit

Permalink
Merge pull request #317 from Suban05/189
Browse files Browse the repository at this point in the history
#189 add `average_build_mttr` into QoS
  • Loading branch information
yegor256 authored Aug 29, 2024
2 parents ba94507 + 3b9bfac commit 78f5a44
Show file tree
Hide file tree
Showing 2 changed files with 344 additions and 157 deletions.
14 changes: 13 additions & 1 deletion judges/quality-of-service/quality-of-service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,27 @@
total = 0
success = 0
duration = 0
ttrs = []
failed = {}
Fbe.unmask_repos.each do |repo|
Fbe.octo.repository_workflow_runs(repo, created: ">#{f.since.utc.iso8601[0..9]}")[:workflow_runs].each do |json|
workflow_id = json[:workflow_id]
run_duration = (Fbe.octo.workflow_run_usage(repo, json[:id])[:run_duration_ms] || 0) / 1000
completed = json[:run_started_at] + run_duration
if json[:conclusion] == 'failure' && failed[workflow_id].nil?
failed[workflow_id] = completed
elsif json[:conclusion] == 'success' && failed[workflow_id]
ttrs << (completed - failed[workflow_id]).to_i
failed.delete(workflow_id)
end
total += 1
success += json[:conclusion] == 'success' ? 1 : 0
duration += (Fbe.octo.workflow_run_usage(repo, json[:id])[:run_duration_ms] || 0) / 1000
duration += run_duration
end
end
f.average_build_success_rate = total.zero? ? 0 : success.to_f / total
f.average_build_duration = total.zero? ? 0 : duration.to_f / total
f.average_build_mttr = ttrs.any? ? ttrs.sum / ttrs.size : 0

# Release intervals:
dates = []
Expand Down
Loading

0 comments on commit 78f5a44

Please sign in to comment.