Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --skip-more-than to ncu-ci and show console URL for "Appeared on" #741

Merged
merged 2 commits into from
Oct 5, 2023
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
13 changes: 11 additions & 2 deletions bin/ncu-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ const args = yargs(hideBin(process.argv))
default: false,
type: 'boolean'
})
.option('skip-more-than', {
describe: 'Skip jobs that fail more than <limit> builds, when --stat is true, default to 10.',
type: 'number',
default: Infinity
})
.option('nobuild', {
describe: 'If running cigtm, whether or not jobid is citgm-nobuild.',
type: 'boolean',
Expand Down Expand Up @@ -325,15 +330,19 @@ class CICommand {
cli.separator('');

let build;
let { skipMoreThan } = argv;
if (argv.stats && argv.skipMoreThan === Infinity) {
skipMoreThan = 10;
}
switch (job.type) {
case 'health':
build = new HealthBuild(cli, request, job.ciType, job.builds);
break;
case PR:
build = new PRBuild(cli, request, job.jobid);
build = new PRBuild(cli, request, job.jobid, skipMoreThan);
break;
case COMMIT:
build = new CommitBuild(cli, request, job.jobid);
build = new CommitBuild(cli, request, job.jobid, skipMoreThan);
break;
case CITGM:
case CITGM_NOBUILD:
Expand Down
8 changes: 7 additions & 1 deletion lib/ci/build-types/commit_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
} = CIFailureParser;

export class CommitBuild extends TestBuild {
constructor(cli, request, id) {
constructor(cli, request, id, skipMoreThan) {
const path = `job/node-test-commit/${id}/`;
const tree = COMMIT_TREE;
super(cli, request, path, tree);
this.skipMoreThan = skipMoreThan;
}

getBuilds({ result, subBuilds }) {
Expand Down Expand Up @@ -89,6 +90,11 @@
return { result, builds, failures };
}

if (builds.failed.length > this.skipMoreThan) {
cli.log(`Failed ${builds.failed.length} builds (> ${this.skipMoreThan}), skipping`);
return { result, builds, failures: [] };
}

Check warning on line 96 in lib/ci/build-types/commit_build.js

View check run for this annotation

Codecov / codecov/patch

lib/ci/build-types/commit_build.js#L94-L96

Added lines #L94 - L96 were not covered by tests

cli.startSpinner(`Querying failures of ${path}`);
const promises = builds.failed.map(({ jobName, buildNumber, url }) => {
if (jobName.includes('fanned')) {
Expand Down
6 changes: 3 additions & 3 deletions lib/ci/build-types/pr_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const {
} = CIFailureParser;

export class PRBuild extends TestBuild {
constructor(cli, request, id) {
constructor(cli, request, id, skipMoreThan) {
const path = `job/node-test-pull-request/${id}/`;
const tree = PR_TREE;
super(cli, request, path, tree);

this.skipMoreThan = skipMoreThan;
this.commitBuild = null;
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export class PRBuild extends TestBuild {
result, subBuilds: allBuilds, changeSet, actions, timestamp
};
const commitBuildId = commitBuild.buildNumber;
this.commitBuild = new CommitBuild(cli, request, commitBuildId);
this.commitBuild = new CommitBuild(cli, request, commitBuildId, this.skipMoreThan);
const { builds, failures } = await this.commitBuild.getResults(buildData);

// Set up aliases for display
Expand Down
8 changes: 5 additions & 3 deletions lib/ci/failure_aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class FailureAggregator {
.sortBy((f) => parseJobFromURL(f.upstream).jobid)
.map((item) => ({ source: item.source, upstream: item.upstream }))
.value();
const machines = _.uniq(failures.map(f => f.builtOn));
const machines = _.uniqBy(
failures.map(f => ({ hostname: f.builtOn, url: f.url })),
'hostname');
data.push({
reason, type: failures[0].type, failures, prs, machines
});
Expand Down Expand Up @@ -91,7 +93,7 @@ export class FailureAggregator {
output += markdownRow('Reason', `<code>${reason}</code>`);
output += markdownRow('-', ':-');
output += markdownRow('Type', type);
const source = prs.map(f => f.source);
const source = prs.map(f => `[${f.source}](${f.upstream})`);
output += markdownRow(
'Failed PR', `${source.length} (${source.join(', ')})`
);
Expand Down Expand Up @@ -137,7 +139,7 @@ export class FailureAggregator {
return parsed ? `#${parsed.prid}` : f.source;
});
cli.table('Failed PR', `${source.length} (${source.join(', ')})`);
cli.table('Appeared', machines.join(', '));
cli.table('Appeared', machines.map(m => m.hostname).join(', '));
if (prs.length > 1) {
cli.table('First CI', `${prs[0].upstream}`);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
return `https://github.com/${owner}/${repo}/pull/${prid}`;
};

export function getMachineUrl(name) {
return `[${name}](https://ci.nodejs.org/computer/${name}/)`;
export function getMachineUrl(machine) {
return `[${machine.hostname}](${machine.url})`;

Check warning on line 110 in lib/links.js

View check run for this annotation

Codecov / codecov/patch

lib/links.js#L110

Added line #L110 was not covered by tests
};

const PR_URL_RE = /PR-URL: https:\/\/github.com\/.+/;
Expand Down
Loading