Skip to content

Commit f028e4b

Browse files
authored
feat(bitbucket): show in-progress builds in Slack status (#28)
1 parent 94f758f commit f028e4b

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

pkg/slack/pr_data.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,19 +358,25 @@ func branchOwnerAndRepo(ctx workflow.Context, url string, branch map[string]any)
358358
return owner, repo, true
359359
}
360360

361+
const (
362+
buildSuccessful = "large_green_circle"
363+
buildInProgress = "large_yellow_circle"
364+
buildFailed = "red_circle"
365+
)
366+
361367
func states(ctx workflow.Context, url string) string {
362368
if isBitbucketPR(url) {
363369
prStatus := data.ReadBitbucketBuilds(ctx, url)
364370
keys := slices.Sorted(maps.Keys(prStatus.Builds))
365371
var summary []string
366372
for _, k := range keys {
367373
switch s := prStatus.Builds[k].State; s {
368-
case "INPROGRESS":
369-
// Don't show in-progress builds in summary.
370374
case "SUCCESSFUL":
371-
summary = append(summary, "large_green_circle")
375+
summary = append(summary, buildSuccessful)
376+
case "INPROGRESS":
377+
summary = append(summary, buildInProgress)
372378
default: // "FAILED", "STOPPED".
373-
summary = append(summary, "red_circle")
379+
summary = append(summary, buildFailed)
374380
}
375381
}
376382

pkg/slack/pr_data_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ func TestStates(t *testing.T) {
473473
"builds": map[string]any{
474474
"build1": map[string]any{"state": "SUCCESSFUL"},
475475
"build2": map[string]any{"state": "FAILED"},
476+
"build3": map[string]any{"state": "INPROGRESS"},
476477
},
477478
}
478479
data, err := json.Marshal(builds)
@@ -497,7 +498,7 @@ func TestStates(t *testing.T) {
497498
{
498499
name: "bitbucket_builds",
499500
url: "https://bitbucket.org/workspace/repo/pull-requests/67890",
500-
want: ", builds: :large_green_circle: :red_circle:",
501+
want: ", builds: :large_green_circle: :red_circle: :large_yellow_circle:",
501502
},
502503
}
503504

0 commit comments

Comments
 (0)