-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_github_api.rb
More file actions
70 lines (57 loc) · 2.16 KB
/
check_github_api.rb
File metadata and controls
70 lines (57 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Check GitHub API for check suite information
pr_number = 23158
github_service = GithubService.new
# Get PR details
pr = github_service.all_pull_requests(state: 'open').find { |p| p.number == pr_number }
if pr
puts "PR ##{pr.number}: #{pr.title}"
puts "Head SHA: #{pr.head.sha}"
# Get combined status
puts "\n=== Combined Status ==="
begin
combined_status = github_service.commit_status(pr.head.sha)
if combined_status
puts "State: #{combined_status.state}"
puts "Total count: #{combined_status.total_count}"
puts "Statuses: #{combined_status.statuses.count}"
# Group statuses by state
by_state = combined_status.statuses.group_by(&:state)
by_state.each do |state, statuses|
puts " #{state}: #{statuses.count}"
end
end
rescue => e
puts "Error getting combined status: #{e.message}"
end
# Get check runs
puts "\n=== Check Runs ==="
begin
client = github_service.instance_variable_get(:@client)
check_runs = client.check_runs_for_ref("department-of-veterans-affairs/vets-api", pr.head.sha)
puts "Total count: #{check_runs.total_count}"
# Group by status
by_status = check_runs.check_runs.group_by(&:status)
by_status.each do |status, runs|
puts " #{status}: #{runs.count}"
end
# Group by conclusion
by_conclusion = check_runs.check_runs.group_by(&:conclusion)
by_conclusion.each do |conclusion, runs|
puts " #{conclusion || 'pending'}: #{runs.count}"
end
# Calculate totals
total = check_runs.total_count
successful = check_runs.check_runs.count { |r| r.conclusion == 'success' }
failed = check_runs.check_runs.count { |r| [ 'failure', 'cancelled', 'timed_out' ].include?(r.conclusion) }
pending = check_runs.check_runs.count { |r| r.status == 'in_progress' || r.status == 'queued' }
puts "\nSummary:"
puts "Total: #{total}"
puts "Successful: #{successful}"
puts "Failed: #{failed}"
puts "Pending: #{pending}"
# Should match "1 failing, 23 successful checks"
puts "\nExpected text: #{failed} failing, #{successful} successful checks"
rescue => e
puts "Error getting check runs: #{e.message}"
end
end