Skip to content
Merged
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
14 changes: 12 additions & 2 deletions .github/workflows/regression-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,21 @@ jobs:
const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
const commitUrl = `${context.serverUrl}/${owner}/${repo}/commit/${sha}`;

// Comments are limited to 65536 characters; the artifact holds the full report.
// Comments are limited to 65536 characters; the artifact holds the full report. The table
// comes first, then one <details> block per failure: drop whole blocks that do not fit,
// as cutting one in the middle would leave its markup open.
const MAX_REPORT = 60000;
let report = fs.readFileSync(path, 'utf8');
if (report.length > MAX_REPORT) {
report = report.slice(0, MAX_REPORT) + `\n\n_Report truncated, see the full report in the [run](${runUrl})._\n`;
const [head, ...blocks] = report.split('<details>\n');
let kept = head;
let shown = 0;
for (const block of blocks) {
if (kept.length + block.length > MAX_REPORT) break;
kept += '<details>\n' + block;
shown++;
}
report = kept + `_${blocks.length - shown} more failure details omitted, see the full report in the [run](${runUrl})._\n`;
}

const body = `${MARKER}\nCommit: [\`${sha.slice(0, 9)}\`](${commitUrl}) | [Workflow run](${runUrl})\n\n${report}`;
Expand Down
16 changes: 14 additions & 2 deletions acceptance/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ var (

// " --- FAIL: TestAccept/foo (0.10s)"
resultLineRE = regexp.MustCompile(`^\s*--- (PASS|FAIL|SKIP): (\S+) `)

// The temp dir of a test, e.g. "/tmp/TestAcceptfoo123456"; the random suffix differs on every run.
tmpDirRE = regexp.MustCompile(`/TestAccept[^/\s]*`)
)

// parseTestOutput parses the output of a test binary run with -test.v into results by test name.
Expand Down Expand Up @@ -266,10 +269,19 @@ func renderDetails(b *strings.Builder, test string, columns []regrColumn) {
marks[i] = c.Title + " " + statusMark(c.status(test))
}
fmt.Fprintf(b, "<details>\n<summary>%s: %s</summary>\n\n", test, strings.Join(marks, " | "))
// A new test commonly fails the same way on main and on the release, which would print the
// same long diff twice.
firstWith := map[string]string{}
for _, c := range failed {
output := truncateLines(strings.Join(c.Results[test].Output, "\n"), regrDetailLines)
output := strings.TrimSpace(strings.Join(c.Results[test].Output, "\n"))
key := tmpDirRE.ReplaceAllString(output, "/TestAccept")
if first, ok := firstWith[key]; ok {
fmt.Fprintf(b, "**%s:** same output as %s\n\n", c.Title, first)
continue
}
firstWith[key] = c.Title
// The longer fence keeps backticks in the output from ending the block.
fmt.Fprintf(b, "**%s:**\n````\n%s\n````\n\n", c.Title, strings.TrimSpace(output))
fmt.Fprintf(b, "**%s:**\n````\n%s\n````\n\n", c.Title, truncateLines(output, regrDetailLines))
}
b.WriteString("</details>\n\n")
}
Expand Down
17 changes: 17 additions & 0 deletions acceptance/regression_unit_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package acceptance_test

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -66,3 +67,19 @@ func TestRenderRegressionReport(t *testing.T) {
assert.Contains(t, report, "**main (abc):**\n````\nmain failure\n````")
assert.Contains(t, report, "failing=1")
}

func TestRenderRegressionReportDedupesIdenticalFailures(t *testing.T) {
failure := func(tmp string) *testResult {
return &testResult{Status: statusFail, Output: []string{"Messages: output.txt vs /tmp/TestAcceptfoo" + tmp + "/002/output.txt", "diff"}}
}
test := "TestAccept/bundle/a"
columns := []regrColumn{
{Title: "branch", Results: map[string]*testResult{test: {Status: statusPass}}},
{Title: "main (abc)", Category: catRegression, Results: map[string]*testResult{test: failure("111")}},
{Title: "latest (v1)", Category: catUnreleased, Results: map[string]*testResult{test: failure("222")}},
}

report := renderRegressionReport("Selected 1", columns)
assert.Equal(t, 1, strings.Count(report, "\ndiff\n"))
assert.Contains(t, report, "**latest (v1):** same output as main (abc)")
}
Loading