Skip to content

Commit

Permalink
feat: enable parsing citgm-nobuild jobs (nodejs#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored Jul 22, 2020
1 parent a77848e commit d4b189b
Show file tree
Hide file tree
Showing 9 changed files with 632 additions and 14 deletions.
17 changes: 14 additions & 3 deletions bin/ncu-ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ const {
JobParser,
parseJobFromURL,
CI_TYPES_KEYS: {
PR, COMMIT, BENCHMARK, CITGM, DAILY_MASTER
PR,
COMMIT,
BENCHMARK,
CITGM,
CITGM_NOBUILD,
DAILY_MASTER
}
} = require('../lib/ci/ci_type_parser');

Expand Down Expand Up @@ -164,6 +169,10 @@ const argv = yargs
default: false,
describe: 'Write the results as markdown to clipboard'
})
.option('nobuild', {
describe: 'If running cigtm, whether or not the CITGM job is citgm-nobuild',
type: 'boolean'
})
.option('json <path>', {
type: 'string',
describe: 'Write the results as json to <path>'
Expand Down Expand Up @@ -231,7 +240,8 @@ class CICommand {
build = new CommitBuild(cli, request, job.jobid);
break;
case CITGM:
build = new CITGMBuild(cli, request, job.jobid);
case CITGM_NOBUILD:
build = new CITGMBuild(cli, request, job);
break;
case BENCHMARK:
build = new BenchmarkRun(cli, request, job.jobid);
Expand Down Expand Up @@ -353,7 +363,8 @@ class JobCommand extends CICommand {
async initialize() {
this.queue.push({
type: commandToType[this.command],
jobid: this.argv.jobid
jobid: this.argv.jobid,
noBuild: this.argv.nobuild || false
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions docs/ncu-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Commands:
Options:
--version Show version number [boolean]
--copy Write the results as markdown to clipboard [default: false]
--nobuild If running cigtm, whether or not the CITGM job is
citgm-nobuild [boolean]
--json <path> Write the results as json to <path> [string]
--markdown <path> Write the results as markdown to <path> [string]
--help Show help [boolean]
Expand Down
33 changes: 25 additions & 8 deletions lib/ci/ci_result_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,18 +760,21 @@ class PRBuild extends TestBuild {
}

class CITGMBuild extends TestBuild {
constructor(cli, request, id) {
const path = `job/citgm-smoker/${id}/`;
constructor(cli, request, job) {
const { jobid, noBuild } = job;
const path = noBuild
? `job/citgm-smoker-nobuild/${jobid}/`
: `job/citgm-smoker/${jobid}/`;

const tree = CITGM_MAIN_TREE;

super(cli, request, path, tree);

this.id = id;
this.id = jobid;
this.noBuild = noBuild;
}

async getResults() {
const { id } = this;

let headerData;
try {
headerData = await this.getBuildData('Summary');
Expand All @@ -789,7 +792,7 @@ class CITGMBuild extends TestBuild {
// they do summary data, so we need to update the endpoint
// and issue a second API call in order to fetch result data.
this.tree = CITGM_REPORT_TREE;
this.path = `job/citgm-smoker/${this.id}/testReport/`;
this.updatePath(true);

let resultData;
try {
Expand All @@ -804,7 +807,7 @@ class CITGMBuild extends TestBuild {
this.results = this.parseResults(resultData);

// Update id again so that it correctly displays in Summary output.
this.path = `job/citgm-smoker/${id}/`;
this.updatePath(false);

return { result };
}
Expand Down Expand Up @@ -833,6 +836,19 @@ class CITGMBuild extends TestBuild {
return results;
}

updatePath(testReport) {
const { id, noBuild } = this;
if (testReport) {
this.path = noBuild
? `job/citgm-smoker-nobuild/${id}/testReport/`
: `job/citgm-smoker/${id}/testReport/`;
} else {
this.path = noBuild
? `job/citgm-smoker-nobuild/${id}/`
: `job/citgm-smoker/${id}/`;
}
}

displayBuilds() {
const { cli, results } = this;
const { failed, skipped, passed, total } = results.statistics;
Expand Down Expand Up @@ -894,7 +910,8 @@ class CITGMBuild extends TestBuild {
output += `### [${failure}](${data.url})\n\n`;

const failures = data.modules.map(f => `* ${f.name}`);
output += `${failures.join('\n')}\n\n`;
const items = failures.length > 0 ? `${failures.join('\n')}` : 'None.';
output += `${items}\n\n`;
}
return output;
}
Expand Down
21 changes: 19 additions & 2 deletions lib/ci/ci_type_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const CI_DOMAIN = 'ci.nodejs.org';

// constants
const CITGM = 'CITGM';
const CITGM_NOBUILD = 'CITGM_NOBUILD';
const PR = 'PR';
const COMMIT = 'COMMIT';
const BENCHMARK = 'BENCHMARK';
Expand Down Expand Up @@ -41,6 +42,12 @@ const CI_TYPES = new Map([
pattern: /job\/citgm-smoker\/(\d+)/,
type: JOB_CI
}],
[CITGM_NOBUILD, {
name: 'CITGM',
jobName: 'citgm-smoker-nobuild',
pattern: /job\/citgm-smoker-nobuild\/(\d+)/,
type: JOB_CI | LITE_CI
}],
[PR, {
name: 'Full PR',
jobName: 'node-test-pull-request',
Expand Down Expand Up @@ -218,8 +225,18 @@ module.exports = {
CI_DOMAIN,
CI_TYPES,
CI_TYPES_KEYS: {
CITGM, PR, COMMIT, BENCHMARK, LIBUV, V8, NOINTL,
LINTER, LITE_PR, LITE_COMMIT, DAILY_MASTER
CITGM,
CITGM_NOBUILD,
PR,
COMMIT,
BENCHMARK,
LIBUV,
V8,
NOINTL,
LINTER,
LITE_PR,
LITE_COMMIT,
DAILY_MASTER
},
CI_PROVIDERS,
isFullCI,
Expand Down
Loading

0 comments on commit d4b189b

Please sign in to comment.