Skip to content

Commit 2bb4cb9

Browse files
committed
Collapse test results in <details> if there are lots of them
Avoid long comment that you have to scroll past.
1 parent 810458f commit 2bb4cb9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tools/misc/build-results-comment.mjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import process from 'node:process';
55
const ARTIFACTS_DIR = process.env.ARTIFACTS_DIR || 'artifacts';
66
const OUTPUT_FILE = process.env.OUTPUT_FILE || 'comment-body.txt';
77
const WORKFLOW_RUN_URL = process.env.WORKFLOW_RUN_URL;
8+
const TOO_MANY_TESTS = 15; // more than this will be collapsed in <details>
89

910
function main() {
1011
const results = loadResults();
@@ -93,7 +94,10 @@ function buildCommentBody({ engines, testResults, errors }) {
9394
`were run on ${engines.length} ${engines.length === 1 ? "engine" : "engines"}.`;
9495
const link = WORKFLOW_RUN_URL ? `\n\n[View workflow run](${WORKFLOW_RUN_URL})` : '';
9596

96-
return `${summary}${link}${errorList}\n\n${table}`;
97+
const preamble = `${summary}${link}${errorList}\n\n`;
98+
if (sortedTests.length <= TOO_MANY_TESTS) return preamble + table;
99+
100+
return `${preamble}<details><summary>Test results</summary>\n\n${table}\n\n</details>`;
97101
}
98102

99103
function buildMarkdownTable(tests, engines, testResults) {

0 commit comments

Comments
 (0)