Skip to content

Commit 94a7193

Browse files
joyeecheungpriyank-p
authored andcommitted
ci: tweak patterns, improve markdown output
New format is in nodejs/reliability#14 Added a few more patterns and linkify the machine names as well as console of example stacks
1 parent 4fe9b35 commit 94a7193

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

lib/ci/ci_failure_parser.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,17 @@ const FAILURE_FILTERS = [{
152152
}
153153
}, {
154154
filter(ctx, text) {
155-
const pattern =
156-
/Changes not staged for commit:[\s\S]+no changes added to commit/mg;
157-
const matches = text.match(pattern);
158-
if (!matches) {
159-
return null;
160-
}
161-
return new GitFailure(ctx, matches[0]);
155+
const patterns = [{
156+
pattern:
157+
/Changes not staged for commit:[\s\S]+no changes added to commit/mg,
158+
context: { index: 0, contextBefore: 0, contextAfter: 0 }
159+
}, {
160+
pattern:
161+
// eslint-disable-next-line max-len
162+
/error: Your local changes to the following files[\s\S]+Failed to merge in the changes./g,
163+
context: { index: 0, contextBefore: 0, contextAfter: 0 }
164+
}];
165+
return failureMatcher(GitFailure, patterns, ctx, text);
162166
}
163167
}, {
164168
filter(ctx, text) {
@@ -174,6 +178,9 @@ const FAILURE_FILTERS = [{
174178
}, {
175179
filter(ctx, text) {
176180
const patterns = [{
181+
pattern: /bash: line /g,
182+
context: { index: 0, contextBefore: 0, contextAfter: 1 }
183+
}, {
177184
pattern: /ERROR: .+/g,
178185
// Pick the last one
179186
context: { index: -1, contextBefore: 0, contextAfter: 5 }
@@ -197,9 +204,6 @@ const FAILURE_FILTERS = [{
197204
}, {
198205
filter(ctx, text) {
199206
const patterns = [{
200-
pattern: /bash: line /g,
201-
context: { index: 0, contextBefore: 0, contextAfter: 1 }
202-
}, {
203207
pattern: /FATAL: .+/g,
204208
context: { index: -1, contextBefore: 0, contextAfter: 5 }
205209
}, {

lib/ci/ci_result_parser.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ const FAILURE = 'FAILURE';
2929
const ABORTED = 'ABORTED';
3030
const UNSTABLE = 'UNSTABLE';
3131

32-
const SEP_LENGTH = 120;
33-
3432
const TEST_PHASE = 'Binary Tests';
3533
// com.tikal.jenkins.plugins.multijob.MultiJobBuild
3634
const BUILD_FIELDS = 'builtOn,buildNumber,jobName,result,url';
@@ -247,7 +245,7 @@ class TestBuild extends Job {
247245

248246
displayHeader() {
249247
const { cli, result, change } = this;
250-
cli.separator('Summary', SEP_LENGTH);
248+
cli.separator('Summary');
251249
cli.table('Result', resultName(result));
252250
cli.table('URL', this.jobUrl);
253251
cli.table('Source', this.sourceURL);
@@ -259,7 +257,7 @@ class TestBuild extends Job {
259257
displayFailure(failure) {
260258
const { cli } = this;
261259
const { url, reason } = failure;
262-
cli.separator(getNodeName(url), SEP_LENGTH);
260+
cli.separator(getNodeName(url));
263261
cli.table('URL', url);
264262
if (failure.type) {
265263
cli.table('Type', failure.type);
@@ -284,7 +282,7 @@ class TestBuild extends Job {
284282
for (const failure of failures) {
285283
this.displayFailure(failure);
286284
}
287-
cli.separator('Other builds', SEP_LENGTH);
285+
cli.separator('Other builds');
288286
for (const aborted of builds.aborted) {
289287
cli.table('Aborted', getUrl(aborted.url));
290288
}
@@ -336,7 +334,14 @@ function getHighlight(f) {
336334
.replace(
337335
/'JNLP4-connect connection from .+?'/, 'JNLP4-connect connection from ...'
338336
)
339-
.replace(/FATAL: Could not checkout \w+/, 'FATAL: Could not checkout ...');
337+
.replace(/FATAL: Could not checkout \w+/, 'FATAL: Could not checkout ...')
338+
.replace(
339+
/error: pathspec .+ did not match any file\(s\) known to git/,
340+
'error: pathspec ... did not match any file(s) known to git')
341+
.replace(
342+
/failed: no workspace for .+/,
343+
'failed: no workspace for ...'
344+
);
340345
}
341346

342347
function markdownRow(...args) {
@@ -347,6 +352,10 @@ function markdownRow(...args) {
347352
return result + '|\n';
348353
}
349354

355+
function getMachineUrl(name) {
356+
return `[${name}](https://${CI_DOMAIN}/computer/${name}/)`;
357+
}
358+
350359
class FailureAggregator {
351360
constructor(cli, failures) {
352361
this.cli = cli;
@@ -392,29 +401,48 @@ class FailureAggregator {
392401
aggregates = this.aggregates = this.aggregate();
393402
}
394403

395-
let output = '';
404+
const last = parseJobFromURL(this.failures[0].upstream);
405+
const first = parseJobFromURL(
406+
this.failures[this.failures.length - 1].upstream
407+
);
408+
const jobName = CI_TYPES.get(first.type).jobName;
409+
let output = 'Failures in ';
410+
output += `[${jobName}/${first.jobid}](${first.link}) to `;
411+
output += `[${jobName}/${last.jobid}](${last.link}) `;
412+
output += `that failed more than 2 PRs\n`;
413+
const todo = [];
396414
for (const type of Object.keys(aggregates)) {
397415
output += `\n### ${FAILURE_TYPES_NAME[type]}\n\n`;
398416
for (const item of aggregates[type]) {
399417
const { reason, type, prs, failures, machines } = item;
400418
if (prs.length < 2) { continue; }
401-
output += markdownRow('Reason', `\`${reason}\``);
419+
todo.push(reason);
420+
output += markdownRow('Reason', `<code>${reason}</code>`);
402421
output += markdownRow('-', ':-');
403422
output += markdownRow('Type', type);
404423
const source = prs.map(f => f.source);
405424
output += markdownRow(
406425
'Failed PR', `${source.length} (${source.join(', ')})`
407426
);
408-
output += markdownRow('Appeared', machines.join(', '));
427+
output += markdownRow(
428+
'Appeared', machines.map(getMachineUrl).join(', ')
429+
);
409430
if (prs.length > 1) {
410431
output += markdownRow('First CI', `${prs[0].upstream}`);
411432
}
412433
output += markdownRow('Last CI', `${prs[prs.length - 1].upstream}`);
413-
output += '\n' + fold('Example', failures[0].reason) + '\n';
414-
output += '\n-------\n\n';
434+
output += '\n';
435+
output += fold(
436+
`<a href="${failures[0].url}">Example</a>`,
437+
failures[0].reason
438+
);
439+
output += '\n\n-------\n\n';
415440
}
416441
}
417-
return output;
442+
443+
output += '### Progress\n\n';
444+
output += todo.map(i => `- \`${i}\``).join('\n');
445+
return output + '\n';
418446
}
419447

420448
display() {
@@ -440,7 +468,7 @@ class FailureAggregator {
440468
cli.table('First CI', `${prs[0].upstream}`);
441469
}
442470
cli.table('Last CI', `${prs[prs.length - 1].upstream}`);
443-
cli.log('\n' + chalk.bold('Example:') + '\n');
471+
cli.log('\n' + chalk.bold('Example: ') + `${failures[0].url}\n`);
444472
const example = failures[0].reason;
445473
cli.log(example.length > 512 ? example.slice(0, 512) + '...' : example);
446474
cli.separator();
@@ -802,7 +830,7 @@ class BenchmarkRun extends Job {
802830
display() {
803831
const { cli, results, significantResults } = this;
804832
cli.log(results);
805-
cli.separator('significant results', SEP_LENGTH);
833+
cli.separator('significant results');
806834
cli.log(significantResults);
807835
}
808836

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{
1+
[{
22
"url": "https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel72-s390x/3915/console",
33
"builtOn": "test-linuxonecc-rhel72-s390x-3",
44
"reason": "Changes not staged for commit:\n19:15:57 # (use \"git add <file>...\" to update what will be committed)\n19:15:57 # (use \"git checkout -- <file>...\" to discard changes in working directory)\n19:15:57 #\n19:15:57 #\tmodified: deps/v8/third_party/jinja2/LICENSE\n19:15:57 #\n19:15:57 # Untracked files:\n19:15:57 # (use \"git add <file>...\" to include in what will be committed)\n19:15:57 #\n19:15:57 #\tbuild/\n19:15:57 no changes added to commit",
55
"highlight": 0,
66
"type": "GIT_FAILURE"
7-
}
7+
}]

0 commit comments

Comments
 (0)