Skip to content

Commit

Permalink
sort the names of the apps (#57)
Browse files Browse the repository at this point in the history
without this, the comments bounce around for large MRs
  • Loading branch information
djeebus authored Aug 30, 2023
1 parent f1228c3 commit 69e0ef5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/vcs_clients/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"regexp"
"sort"
"strings"
"sync"

Expand All @@ -15,7 +16,7 @@ const (
appFormat = `<details><summary>
## ArgoCD Application Checks:` + "`%s` %s" +
`
`
</summary>
%s
</details>
Expand Down Expand Up @@ -77,18 +78,25 @@ func (m *Message) buildComment(ctx context.Context) string {
_, span := otel.Tracer("Kubechecks").Start(ctx, "buildComment")
defer span.End()

var names []string
for _, name := range m.Apps {
names = append(names, name)
}
sort.Strings(names)

var sb strings.Builder
fmt.Fprintf(&sb, "# Kubechecks Report\n")
// m.Msg = fmt.Sprintf("%s \n\n---\n\n%s", m.Msg, msg)
for app, msg := range m.Apps {
for _, name := range names {
msg := m.Apps[name]
appEmoji := pkg.PassEmoji()

// Test the message for failures, since we'll be showing this at the top
if summaryEmojiRegex.MatchString(msg) {
appEmoji = pkg.FailedEmoji()
}

fmt.Fprintf(&sb, appFormat, app, appEmoji, msg)
fmt.Fprintf(&sb, appFormat, name, appEmoji, msg)
}
return sb.String()
}

0 comments on commit 69e0ef5

Please sign in to comment.