Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pipeline/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions internal/pipeline/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
Expand Down
19 changes: 19 additions & 0 deletions internal/report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down