Skip to content

Commit

Permalink
Fixup after nobuild PR
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jul 22, 2020
1 parent 18109a6 commit 91f107e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
21 changes: 4 additions & 17 deletions bin/ncu-ci
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,9 @@ class CICommand {
case CITGM:
case CITGM_NOBUILD:
if (job.jobid2) {
const ids = [job.jobid, job.jobid2];
build = new CITGMComparisonBuild(cli, request, ids);
build = new CITGMComparisonBuild(cli, request, job);
} else {
build = new CITGMBuild(cli, request, job.jobid);
build = new CITGMBuild(cli, request, job);
}
break;
case BENCHMARK:
Expand Down Expand Up @@ -375,21 +374,9 @@ class JobCommand extends CICommand {

queue.push({
type: commandToType[this.command],
<<<<<<< HEAD
<<<<<<< HEAD
jobid: this.argv.jobid,
noBuild: this.argv.nobuild || false
||||||| merged common ancestors
jobid: this.argv.jobid
=======
jobid: argv.jobid
>>>>>>> refactor: pull some builds into own files
||||||| merged common ancestors
jobid: argv.jobid
=======
jobid: argv.jobid,
jobid2: argv.jobid2
>>>>>>> feat: enable citgm run comparisons
jobid2: argv.jobid2,
noBuild: this.argv.nobuild || false
});
}
}
Expand Down
34 changes: 27 additions & 7 deletions lib/ci/build-types/citgm_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ const {
} = require('../ci_failure_parser');

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 { apiUrl, id } = this;
const { apiUrl } = this;

let headerData;
try {
Expand All @@ -45,7 +50,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/${id}/testReport/`;
this.updatePath(true);

let resultData;
try {
Expand All @@ -60,7 +65,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 @@ -93,6 +98,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 @@ -154,8 +172,10 @@ 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
14 changes: 10 additions & 4 deletions lib/ci/build-types/citgm_comparison_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ const { statusType } = require('../ci_utils');
const { CITGMBuild } = require('./citgm_build');

class CITGMComparisonBuild {
constructor(cli, request, ids) {
const baseBuild = new CITGMBuild(cli, request, ids[0]);
const comparisonBuild = new CITGMBuild(cli, request, ids[1]);
constructor(cli, request, job) {
const { jobid, jobid2, noBuild } = job;

const baseBuild = new CITGMBuild(cli, request, { jobid, noBuild });

// noBuild in a comparison build only applies to the base build.
const comparisonBuild = new CITGMBuild(cli, request, {
jobid: jobid2,
noBuild: false
});

this.cli = cli;
this.builds = { baseBuild, comparisonBuild };
this.results = {};
this.ids = ids;
}

async getResults() {
Expand Down
9 changes: 8 additions & 1 deletion test/unit/ci_result_parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ describe('Jenkins', () => {
jobCache.enable();

const cli = new TestCLI();
const comparisonBuild = new CITGMComparisonBuild(cli, {}, [2392, 2390]);

const job = {
jobid: 2392,
jobid2: 2390,
noBuild: false
};

const comparisonBuild = new CITGMComparisonBuild(cli, {}, job);
await comparisonBuild.getResults();

const expectedJson = fixtures.readJSON(...prefix, 'expected.json');
Expand Down

0 comments on commit 91f107e

Please sign in to comment.