From 894900d6b0f0d225f6ad23a239937167561dad83 Mon Sep 17 00:00:00 2001 From: Rosemarie O'Riorden Date: Mon, 30 Nov 2026 16:00:18 -0500 Subject: [PATCH] report: Name the workflow in the subjects of reports. Reports of the different workflows of a patch had the same subject, so a list of subjects, like the archive of the reports list, did not tell which workflow failed. The workflow now follows the status, as in "|fail| 'ovn-kubernetes' pw2052 [ovs-dev] ...". Reports without a workflow, like when no workflow ran, keep the old subject. Signed-off-by: Rosemarie O'Riorden --- internal/pipeline/annotations_test.go | 2 +- internal/pipeline/pipeline_test.go | 8 ++++---- internal/pipeline/reports.go | 1 + internal/report/report.go | 10 +++++++++- internal/report/report_test.go | 19 +++++++++++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/internal/pipeline/annotations_test.go b/internal/pipeline/annotations_test.go index 48eb8670..921dad2b 100644 --- a/internal/pipeline/annotations_test.go +++ b/internal/pipeline/annotations_test.go @@ -50,7 +50,7 @@ func TestWarningAnnotationMakesWarning(t *testing.T) { e.gh.annotationCalls) } last := string(e.mail.sent[len(e.mail.sent)-2].Data) - if !strings.Contains(last, "|warning| pw6001") || + if !strings.Contains(last, "|warning| 'Checkpatch' pw6001") || !strings.Contains(last, "WARNING: Line is 80 characters long") { t.Errorf("report:\n%s", last) } diff --git a/internal/pipeline/pipeline_test.go b/internal/pipeline/pipeline_test.go index eb2d860a..25c7102a 100644 --- a/internal/pipeline/pipeline_test.go +++ b/internal/pipeline/pipeline_test.go @@ -38,7 +38,7 @@ func TestFullFlow(t *testing.T) { // Apply results are reported for each patch. subjects := e.mail.subjects() if len(subjects) != 2 || !strings.HasPrefix(subjects[0], - "|success| pw701 [lorem-dev,1/2]") { + "|success| 'apply-robot' pw701 [lorem-dev,1/2]") { t.Fatalf("subjects = %q", subjects) } @@ -75,7 +75,7 @@ func TestFullFlow(t *testing.T) { t.Fatalf("subjects = %q", subjects) } last := string(e.mail.sent[len(e.mail.sent)-2].Data) - if !strings.Contains(last, "|fail| pw702") || strings.Contains(last, "Cc:") || + if !strings.Contains(last, "|fail| 'Test' pw702") || strings.Contains(last, "Cc:") || !strings.Contains(last, "lorem-job: failed at step \"make check\"") || !strings.Contains(last, "\r\nipsum error\r\n") { t.Errorf("failure report:\n%s", last) @@ -130,7 +130,7 @@ func TestApplyFailure(t *testing.T) { } var failMail string for _, m := range e.mail.sent { - if strings.Contains(string(m.Data), "|fail| pw802") { + if strings.Contains(string(m.Data), "|fail| 'apply-robot' pw802") { failMail = string(m.Data) } } @@ -788,7 +788,7 @@ func TestRecheckFromArchive(t *testing.T) { if len(e.mail.sent) != sent+1 { t.Fatalf("sent = %d, want %d", len(e.mail.sent), sent+1) } - if !strings.Contains(string(e.mail.sent[sent].Data), "|success| pw10001") { + if !strings.Contains(string(e.mail.sent[sent].Data), "|success| 'Build' pw10001") { t.Errorf("recheck report:\n%s", e.mail.sent[sent].Data) } // The same comment does not trigger another recheck. diff --git a/internal/pipeline/reports.go b/internal/pipeline/reports.go index 13041782..312af269 100644 --- a/internal/pipeline/reports.go +++ b/internal/pipeline/reports.go @@ -464,6 +464,7 @@ func (p *Pipeline) sendReport(ctx context.Context, s *state.Series, pt *state.Pa Label: label, Result: result, Description: p.description(r, result), + Workflow: r.Workflow, PatchID: pt.ID, PatchName: pt.Name, PatchMsgID: pt.MsgID, diff --git a/internal/report/report.go b/internal/report/report.go index 1ff0a1eb..1f010127 100644 --- a/internal/report/report.go +++ b/internal/report/report.go @@ -73,6 +73,9 @@ type Input struct { Label string Result string Description string + // Workflow, when set, goes in the subject so that reports of + // different workflows can be told apart in a list of subjects. + Workflow string PatchID int PatchName string @@ -114,7 +117,12 @@ func Compose(in Input) (*Email, error) { subjectPrefix = SubjectPrefix patchURL = strings.TrimPrefix(strings.TrimPrefix(patchURL, "https://"), "http://") } - subject := fmt.Sprintf("%s|%s| pw%d %s", subjectPrefix, status, in.PatchID, in.PatchName) + workflow := "" + if in.Workflow != "" { + workflow = "'" + in.Workflow + "' " + } + subject := fmt.Sprintf("%s|%s| %spw%d %s", subjectPrefix, status, workflow, + in.PatchID, in.PatchName) var h strings.Builder header := func(k, v string) { fmt.Fprintf(&h, "%s: %s\r\n", k, v) } diff --git a/internal/report/report_test.go b/internal/report/report_test.go index 00d9d566..fce16a2b 100644 --- a/internal/report/report_test.go +++ b/internal/report/report_test.go @@ -73,6 +73,25 @@ func TestComposeOVS(t *testing.T) { } } +func TestComposeWorkflowInSubject(t *testing.T) { + in := baseInput() + in.Workflow = "Build and Test" + e, err := Compose(in) + if err != nil { + t.Fatal(err) + } + head, _ := split(t, e) + want := "Subject: |fail| 'Build and Test' pw2052 [lorem-dev,v2,1/3] ipsum: Dolor sit.\r\n" + if !strings.Contains(head, want) { + t.Errorf("headers missing %q:\n%s", want, head) + } + parsed, err := Parse("|fail| 'Build and Test' pw2052 x", "Test-Label: l\nTest-Status: fail\n", + nil, "pw.example.org", false) + if err != nil || parsed.PatchID != 2052 { + t.Errorf("Parse = %+v, %v; want patch 2052", parsed, err) + } +} + func TestComposeDPDKFieldsWithinFirstLines(t *testing.T) { in := baseInput() in.Style = StyleDPDK