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

Function buildOutputStagesMarkdown

action/github/summary.go:28–77  ·  view source on GitHub ↗
(w *world.World, sb *strings.Builder)

Source from the content-addressed store, hash-verified

26}
27
28func buildOutputStagesMarkdown(w *world.World, sb *strings.Builder) {
29 if w.IsRollout && w.Rollout != nil {
30 rollout := w.Rollout
31
32 if len(rollout.Stages) == 0 {
33 sb.WriteString("\n### Rollout Stages\n\n")
34 sb.WriteString("_No stages to display. The rollout may not have any stages._\n\n")
35 return
36 }
37
38 allStages := []string{}
39 for _, stage := range rollout.Stages {
40 allStages = append(allStages, stage.Environment)
41 }
42
43 // Create a map of stage environment to Stage object for quick lookup
44 stageMap := make(map[string]*v1pb.Stage)
45 for _, stage := range rollout.Stages {
46 stageMap[stage.Environment] = stage
47 }
48
49 // Build the markdown table
50 sb.WriteString("\n### Rollout Stages\n\n")
51 sb.WriteString("| Stage | Status |\n")
52 sb.WriteString("|-------|--------|\n")
53
54 // Output all stages with their status
55 for _, stageEnv := range allStages {
56 stageName := extractStageName(stageEnv)
57
58 // Determine status
59 var status string
60 if stage, exists := stageMap[stageEnv]; exists {
61 // Stage exists in rollout, get its aggregated status
62 status = getAggregatedStageStatus(stage)
63 } else {
64 // Stage is only in pendingStages, mark as pending
65 status = "⏳ Pending"
66 }
67
68 sb.WriteString("| ")
69 sb.WriteString(stageName)
70 sb.WriteString(" | ")
71 sb.WriteString(status)
72 sb.WriteString(" |\n")
73 }
74
75 sb.WriteString("\n")
76 }
77}
78
79// getAggregatedStageStatus determines the overall status of a stage based on its tasks
80func getAggregatedStageStatus(stage *v1pb.Stage) string {

Callers 1

BuildSummaryMarkdownFunction · 0.85

Calls 2

extractStageNameFunction · 0.85
getAggregatedStageStatusFunction · 0.85

Tested by

no test coverage detected