Skip to content

Commit ff90692

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
add check_run start timestamps
1 parent 58d1498 commit ff90692

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

pkg/prx/graphql_complete.go

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,41 +1255,45 @@ func (c *Client) convertGraphQLToEventsComplete(ctx context.Context, data *graph
12551255
node := &data.HeadRef.Target.StatusCheckRollup.Contexts.Nodes[i]
12561256
switch node.TypeName {
12571257
case "CheckRun":
1258-
var timestamp time.Time
1259-
var outcome string
1258+
// Create separate events for started and completed states
1259+
// to provide visibility into test lifecycle
12601260

1261-
switch {
1262-
case node.CompletedAt != nil:
1263-
timestamp = *node.CompletedAt
1264-
outcome = strings.ToLower(node.Conclusion)
1265-
case node.StartedAt != nil:
1266-
timestamp = *node.StartedAt
1267-
outcome = strings.ToLower(node.Status)
1268-
default:
1269-
continue
1270-
}
1271-
1272-
event := Event{
1273-
Kind: "check_run",
1274-
Timestamp: timestamp,
1275-
Body: node.Name,
1276-
Outcome: outcome,
1277-
Bot: true, // Check runs are always from apps
1278-
}
1279-
1280-
// Build description
1261+
// Build description (shared across all events for this check run)
1262+
var description string
12811263
switch {
12821264
case node.Title != "" && node.Summary != "":
1283-
event.Description = fmt.Sprintf("%s: %s", node.Title, node.Summary)
1265+
description = fmt.Sprintf("%s: %s", node.Title, node.Summary)
12841266
case node.Title != "":
1285-
event.Description = node.Title
1267+
description = node.Title
12861268
case node.Summary != "":
1287-
event.Description = node.Summary
1269+
description = node.Summary
12881270
default:
12891271
// No description available
12901272
}
12911273

1292-
events = append(events, event)
1274+
// Create started event if timestamp exists
1275+
if node.StartedAt != nil {
1276+
events = append(events, Event{
1277+
Kind: "check_run",
1278+
Timestamp: *node.StartedAt,
1279+
Body: node.Name,
1280+
Outcome: strings.ToLower(node.Status),
1281+
Bot: true,
1282+
Description: description,
1283+
})
1284+
}
1285+
1286+
// Create completed event if timestamp exists
1287+
if node.CompletedAt != nil {
1288+
events = append(events, Event{
1289+
Kind: "check_run",
1290+
Timestamp: *node.CompletedAt,
1291+
Body: node.Name,
1292+
Outcome: strings.ToLower(node.Conclusion),
1293+
Bot: true,
1294+
Description: description,
1295+
})
1296+
}
12931297

12941298
case "StatusContext":
12951299
if node.CreatedAt == nil {

0 commit comments

Comments
 (0)