Skip to content

Commit

Permalink
#195: calculate total number of CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegorov committed Sep 21, 2024
1 parent a31f9b7 commit 7b7a23e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions judges/quantity-of-deliverables/count-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ expected:
- /fb/f[total_pulls_submitted != 0]
- /fb/f[total_releases_published != 0]
- /fb/f[total_reviews_submitted = 0]
- /fb/f[total_builds_ran != 0]
6 changes: 6 additions & 0 deletions judges/quantity-of-deliverables/quantity-of-deliverables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@
end
end
end

# Total number of CI builds executed in all repositories from since
f.total_builds_ran =
Fbe.unmask_repos.sum do |repo|
Fbe.octo.repository_workflow_runs(repo, created: ">#{f.since.utc.iso8601[0..9]}")[:total_count]
end
end
47 changes: 47 additions & 0 deletions test/judges/test-quantity-of-deliverables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def test_counts_commits
body: [{ id: 1, draft: false, published_at: Time.parse('2024-08-01 21:00:00 UTC') }]
)
stub_github('https://api.github.com/repos/foo/foo/pulls?per_page=100&state=all', body: [])
stub_github(
'https://api.github.com/repos/foo/foo/actions/runs?created=%3E2024-07-15&per_page=100',
body: { total_count: 0, workflow_runs: [] }
)
fb = Factbase.new
Time.stub(:now, Time.parse('2024-08-12 21:00:00 UTC')) do
load_it('quantity-of-deliverables', fb)
Expand Down Expand Up @@ -139,6 +143,10 @@ def test_processes_empty_repository
body: [{ id: 1, draft: false, published_at: Time.parse('2024-08-01 21:00:00 UTC') }]
)
stub_github('https://api.github.com/repos/foo/foo/pulls?per_page=100&state=all', body: [])
stub_github(
'https://api.github.com/repos/foo/foo/actions/runs?created=%3E2024-07-15&per_page=100',
body: { total_count: 0, workflow_runs: [] }
)
fb = Factbase.new
Time.stub(:now, Time.parse('2024-08-12 21:00:00 UTC')) do
load_it('quantity-of-deliverables', fb)
Expand Down Expand Up @@ -191,6 +199,10 @@ def test_quantity_of_deliverables_total_releases_published
]
)
stub_github('https://api.github.com/repos/foo/foo/pulls?per_page=100&state=all', body: [])
stub_github(
'https://api.github.com/repos/foo/foo/actions/runs?created=%3E2024-08-02&per_page=100',
body: { total_count: 0, workflow_runs: [] }
)
fb = Factbase.new
f = fb.insert
f.what = 'pmp'
Expand Down Expand Up @@ -370,6 +382,41 @@ def test_quantity_of_deliverables_total_reviews_submitted
}
]
)
stub_github(
'https://api.github.com/repos/foo/foo/actions/runs?created=%3E2024-08-02&per_page=100',
body: {
total_count: 3,
workflow_runs: [
{
id: 710,
display_title: 'some title',
run_number: 2615,
event: 'dynamic',
status: 'completed',
conclusion: 'success',
workflow_id: 141
},
{
id: 708,
display_title: 'some title',
run_number: 2612,
event: 'schedule',
status: 'completed',
conclusion: 'success',
workflow_id: 141
},
{
id: 705,
display_title: 'some title',
run_number: 2610,
event: 'push',
status: 'completed',
conclusion: 'failure',
workflow_id: 141
}
]
}
)
fb = Factbase.new
f = fb.insert
f.what = 'pmp'
Expand Down

0 comments on commit 7b7a23e

Please sign in to comment.