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: 8 additions & 6 deletions lib/ci/failure_aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ function formatTargetBranches(pr, markdown = false) {
if (!parsePRFromURL(pr.source)) {
return '';
}
const branches = pr.targetBranches
.filter(branch => branch !== 'main')
.map(branch => markdown
? branch.replace(/[&<>"'\\`*_[\]{}()!|~]/g, char => `&#${char.charCodeAt(0)};`)
: branch);
return branches.length ? ` (target: ${branches.join(', ')})` : '';
if (pr.targetBranches.length === 1 && pr.targetBranches[0] === 'main') {
return '';
}
const branches = markdown
? pr.targetBranches.map(branch =>
branch.replace(/[&<>"'\\`*_[\]{}()!|~]/g, char => `&#${char.charCodeAt(0)};`))
: pr.targetBranches;
return ` (target: ${branches.join(', ')})`;
}

export class FailureAggregator {
Expand Down
14 changes: 8 additions & 6 deletions test/unit/ci_failure_aggregator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Failure aggregation target branches', () => {
const markdown = aggregator.formatAsMarkdown();
assert.ok(markdown.includes('| Failed PR | 2 (' +
`[nodejs/node#2](${failures[3].upstream}) (target: v22.x), ` +
`[nodejs/node#1](${failures[0].upstream}) (target: v24.x)) |`));
`[nodejs/node#1](${failures[0].upstream}) (target: main, v24.x)) |`));
assert.ok(markdown.includes(`| First CI | ${failures[3].upstream} |`));
assert.ok(markdown.includes(`| Last CI | ${failures[0].upstream} |`));
assert.ok(markdown.includes('Health summary\n'));
Expand All @@ -55,7 +55,7 @@ describe('Failure aggregation target branches', () => {

aggregator.display();
assert.deepEqual(cli._calls.table.filter(([key]) => key === 'Failed PR'), [
['Failed PR', '2 (nodejs/node#2 (target: v22.x), nodejs/node#1 (target: v24.x))'],
['Failed PR', '2 (nodejs/node#2 (target: v22.x), nodejs/node#1 (target: main, v24.x))'],
['Failed PR', '1 (nodejs/node#3)']
]);
});
Expand All @@ -66,16 +66,18 @@ describe('Failure aggregation target branches', () => {
failure(1, 104), failure(1, 103, 'main'), failure(1, 102), failure(2, 101)
]);
const markdown = aggregator.formatAsMarkdown();
assert.equal(markdown.includes('target: unknown, main'), false);
assert.ok(markdown.includes('(target: unknown, main)'));
assert.ok(markdown.includes('(target: unknown)'));
aggregator.display();
assert.deepEqual(cli._calls.table.find(([key]) => key === 'Failed PR'),
['Failed PR', '2 (nodejs/node#2 (target: unknown), nodejs/node#1 (target: unknown))']);
['Failed PR', '2 (nodejs/node#2 (target: unknown), nodejs/node#1 (target: unknown, main))']);
});

it('hides main targets and abbreviates PR labels without changing CI links', () => {
it('hides sole main targets and abbreviates PR labels without changing CI links', () => {
const cli = new TestCLI();
const failures = [failure(1, 102, 'main'), failure(2, 101, 'main')];
const failures = [
failure(1, 102, 'main'), failure(2, 101, 'main'), failure(1, 100, 'main')
];
failures[1].source = 'https://github.com/nodejs-private/node-private/pull/2/';
const aggregator = new FailureAggregator(cli, [health, ...failures]);
const markdown = aggregator.formatAsMarkdown();
Expand Down
Loading