MCPcopy Create free account
hub / github.com/bytebase/bytebase / getAggregatedStageStatus

Function getAggregatedStageStatus

action/github/summary.go:80–143  ·  view source on GitHub ↗

getAggregatedStageStatus determines the overall status of a stage based on its tasks

(stage *v1pb.Stage)

Source from the content-addressed store, hash-verified

78
79// getAggregatedStageStatus determines the overall status of a stage based on its tasks
80func getAggregatedStageStatus(stage *v1pb.Stage) string {
81 if stage == nil || len(stage.Tasks) == 0 {
82 return "⏳ Pending"
83 }
84
85 hasRunning := false
86 hasFailed := false
87 hasCanceled := false
88 hasSkipped := false
89 hasPending := false
90 hasNotStarted := false
91 allDone := true
92
93 for _, task := range stage.Tasks {
94 switch task.Status {
95 case v1pb.Task_RUNNING:
96 hasRunning = true
97 allDone = false
98 case v1pb.Task_FAILED:
99 hasFailed = true
100 allDone = false
101 case v1pb.Task_CANCELED:
102 hasCanceled = true
103 allDone = false
104 case v1pb.Task_SKIPPED:
105 hasSkipped = true
106 case v1pb.Task_PENDING:
107 hasPending = true
108 allDone = false
109 case v1pb.Task_NOT_STARTED, v1pb.Task_STATUS_UNSPECIFIED:
110 hasNotStarted = true
111 allDone = false
112 case v1pb.Task_DONE:
113 // Task is done
114 default:
115 allDone = false
116 }
117 }
118
119 // Determine overall stage status based on task statuses
120 if hasFailed {
121 return "❌ Failed"
122 }
123 if hasCanceled {
124 return "⛔ Canceled"
125 }
126 if hasRunning {
127 return "🔄 Running"
128 }
129 if hasPending {
130 return "⏳ Pending"
131 }
132 if hasNotStarted {
133 return "⏸️ Not Started"
134 }
135 if allDone && !hasSkipped {
136 return "✅ Done"
137 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected