diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-05-17 18:18:03 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-05-25 14:59:38 +0200 |
| commit | 6b7e906bb1dbb3bd49f58b79b00ea928ade236ba (patch) | |
| tree | c67d1af43b9c80aa5ace62c040f8165fff843da4 /dashboard/app/reporting.go | |
| parent | ed3c42cc79baba7bc8e90ff1f7d56103509d4d9d (diff) | |
dashboard: send per-label notifications
If the label is not user-set and the config specifies a message for it,
send a bug notification.
If the label is related to bug origin testing, attach the list of tested
trees.
Diffstat (limited to 'dashboard/app/reporting.go')
| -rw-r--r-- | dashboard/app/reporting.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index 0e9133df4..d0b61bbf1 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -185,6 +185,7 @@ func reportingPollNotifications(c context.Context, typ string) []*dashapi.BugNot return notifs } +// nolint: gocyclo func handleReportNotif(c context.Context, typ string, bug *Bug) (*dashapi.BugNotification, error) { reporting, bugReporting, _, _, err := currentReporting(bug) if err != nil || reporting == nil { @@ -227,9 +228,43 @@ func handleReportNotif(c context.Context, typ string, bug *Bug) (*dashapi.BugNot commits := strings.Join(bug.Commits, "\n") return createNotification(c, dashapi.BugNotifBadCommit, true, commits, bug, reporting, bugReporting) } + for _, label := range bug.Labels { + if label.SetBy != "" { + continue + } + str := label.String() + if reporting.Labels[str] == "" { + continue + } + if stringInList(bugReporting.GetLabels(), str) { + continue + } + return createLabelNotification(c, label, bug, reporting, bugReporting) + } return nil, nil } +func createLabelNotification(c context.Context, label BugLabel, bug *Bug, reporting *Reporting, + bugReporting *BugReporting) (*dashapi.BugNotification, error) { + labelStr := label.String() + notif, err := createNotification(c, dashapi.BugNotifLabel, true, reporting.Labels[labelStr], + bug, reporting, bugReporting) + if err != nil { + return nil, err + } + notif.Label = labelStr + // For some labels also attach job results. + if label.Label == OriginLabel { + var err error + notif.TreeJobs, err = treeTestJobs(c, bug) + if err != nil { + log.Errorf(c, "failed to extract jobs for %s: %v", bug.keyHash(), err) + return nil, fmt.Errorf("failed to fetch jobs: %w", err) + } + } + return notif, nil +} + func bugObsoletionReason(bug *Bug) dashapi.BugStatusReason { if bug.HeadReproLevel == ReproLevelNone && bug.ReproLevel != ReproLevelNone { return dashapi.InvalidatedByRevokedRepro @@ -1036,6 +1071,9 @@ func incomingCommandCmd(c context.Context, now time.Time, cmd *dashapi.BugUpdate if cmd.StatusReason != "" { bug.StatusReason = cmd.StatusReason } + if cmd.Label != "" { + bugReporting.AddLabel(cmd.Label) + } return true, "", nil } |
