Atlas › Test

TestBuildFailureMessage

Exact test identity: go.temporal.io/server/tools/ci-notify/TestBuildFailureMessage

Package
go.temporal.io/server/tools/ci-notify
Suite / test hierarchy
TestBuildFailureMessage
Test
TestBuildFailureMessage
Introduced at
slack.go ×2 Frontier kind: Joint frontier
Covered ranges
3
Covered lines
81
Covered files
2

Co-introduced tests

1 other test enter at the same concept.

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/ci-notify/slack.go 78 covered LOC · 2 ranges

Open complete file

32
33 // BuildFailureMessage creates a Slack message for CI failure
34 > func BuildFailureMessage(report *FailureReport) *SlackMessage { slack.go
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
85 > jobsBlock := SlackBlock{ slack.go
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
go.temporal.io/server/tools/common/github/url.go 3 covered LOC · 1 range

Open complete file

4
5 // CommitURL constructs a GitHub commit URL.
6 > func CommitURL(repo, sha string) string { url.go
7 > return fmt.Sprintf("https://github.com/%s/commit/%s", repo, sha)
8 > }
9
10 // RunURL constructs a GitHub Actions workflow run URL.