32
33
// BuildFailureMessage creates a Slack message for CI failure
35
>
// Header with alert emoji
36
>
headerBlock := SlackBlock{
37
>
Type: "section",
38
>
Text: &SlackText{
39
>
Type: "mrkdwn",
40
>
Text: ":rotating_light: *CI Failed on Main Branch* :rotating_light:",
41
>
},
42
>
}
43
>
44
>
// Workflow and commit info
45
>
commitURL := github.CommitURL("temporalio/temporal", report.Commit.SHA)
46
>
infoBlock := SlackBlock{
47
>
Type: "section",
48
>
Fields: []SlackText{
49
>
{
50
>
Type: "mrkdwn",
51
>
Text: fmt.Sprintf("*Workflow:*\n%s", report.Workflow.Name),
52
>
},
53
>
{
54
>
Type: "mrkdwn",
55
>
Text: fmt.Sprintf("*Branch:*\n`%s`", report.Workflow.HeadBranch),
56
>
},
57
>
{
58
>
Type: "mrkdwn",
59
>
Text: fmt.Sprintf("*Commit:*\n<%s|%s>", commitURL, report.Commit.ShortSHA),
60
>
},
61
>
{
62
>
Type: "mrkdwn",
63
>
Text: fmt.Sprintf("*Author:*\n%s", report.Commit.Author),
64
>
},
65
>
},
66
>
}
67
>
68
>
// Failure summary
69
>
summaryBlock := SlackBlock{
70
>
Type: "section",
71
>
Text: &SlackText{
72
>
Type: "mrkdwn",
73
>
Text: fmt.Sprintf("*Failed Jobs:* %d of %d total jobs",
74
>
len(report.FailedJobs), report.TotalJobs),
75
>
},
76
>
}
77
>
78
>
// List of failed jobs
79
>
var failedJobNames []string
80
>
for _, job := range report.FailedJobs {
81
>
failedJobNames = append(failedJobNames,
82
>
fmt.Sprintf("• <%s|%s>", job.URL, job.Name))
83
>
}
84
86
>
Type: "section",
87
>
Text: &SlackText{
88
>
Type: "mrkdwn",
89
>
Text: fmt.Sprintf("*Failed Jobs:*\n%s",
90
>
strings.Join(failedJobNames, "\n")),
91
>
},
92
>
}
93
>
94
>
// Link to workflow run
95
>
linkBlock := SlackBlock{
96
>
Type: "section",
97
>
Text: &SlackText{
98
>
Type: "mrkdwn",
99
>
Text: fmt.Sprintf("<%s|View Full Workflow Run>", report.Workflow.URL),
100
>
},
101
>
}
102
>
103
>
return &SlackMessage{
104
>
Text: fmt.Sprintf("CI Failed on Main: %s", report.Workflow.Name),
105
>
Blocks: []SlackBlock{
106
>
headerBlock,
107
>
infoBlock,
108
>
summaryBlock,
109
>
jobsBlock,
110
>
linkBlock,
111
>
},
112
>
}
113
}
114