MCPcopy Index your code
hub / github.com/cli/cli / aggregateChecks

Function aggregateChecks

pkg/cmd/pr/checks/aggregate.go:36–93  ·  view source on GitHub ↗
(checkContexts []api.CheckContext, requiredChecks bool)

Source from the content-addressed store, hash-verified

34}
35
36func aggregateChecks(checkContexts []api.CheckContext, requiredChecks bool) (checks []check, counts checkCounts) {
37 for _, c := range eliminateDuplicates(checkContexts) {
38 if requiredChecks && !c.IsRequired {
39 continue
40 }
41
42 state := string(c.State)
43 if state == "" {
44 if c.Status == "COMPLETED" {
45 state = string(c.Conclusion)
46 } else {
47 state = c.Status
48 }
49 }
50
51 link := c.DetailsURL
52 if link == "" {
53 link = c.TargetURL
54 }
55
56 name := c.Name
57 if name == "" {
58 name = c.Context
59 }
60
61 item := check{
62 Name: name,
63 State: state,
64 StartedAt: c.StartedAt,
65 CompletedAt: c.CompletedAt,
66 Link: link,
67 Event: c.CheckSuite.WorkflowRun.Event,
68 Workflow: c.CheckSuite.WorkflowRun.Workflow.Name,
69 Description: c.Description,
70 }
71
72 switch state {
73 case "SUCCESS":
74 item.Bucket = "pass"
75 counts.Passed++
76 case "SKIPPED", "NEUTRAL":
77 item.Bucket = "skipping"
78 counts.Skipping++
79 case "ERROR", "FAILURE", "TIMED_OUT", "ACTION_REQUIRED":
80 item.Bucket = "fail"
81 counts.Failed++
82 case "CANCELLED":
83 item.Bucket = "cancel"
84 counts.Canceled++
85 default: // "EXPECTED", "REQUESTED", "WAITING", "QUEUED", "PENDING", "IN_PROGRESS", "STALE"
86 item.Bucket = "pending"
87 counts.Pending++
88 }
89
90 checks = append(checks, item)
91 }
92 return
93}

Callers 1

populateStatusChecksFunction · 0.85

Calls 1

eliminateDuplicatesFunction · 0.85

Tested by

no test coverage detected