Skip to content

Commit 6b27ebf

Browse files
committed
Miscellaneous cleanup
1 parent b8f8c74 commit 6b27ebf

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

bin/ncu-ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class CICommand {
260260
if (this.json.length) {
261261
writeJson(argv.json, this.json);
262262
cli.separator('');
263-
cli.log(`Written JSON to ${argv.json}`);
263+
cli.log(`Wrote JSON to ${argv.json}`);
264264
} else {
265265
cli.error('No JSON generated');
266266
}

lib/ci/ci_result_parser.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const CAUSE_TREE = 'upstreamBuild,upstreamProject,shortDescription,_class';
6464
const RUN_TREE = `actions[causes[${CAUSE_TREE}]],builtOn`;
6565

6666
// hudson.tasks.test.MatrixTestResult
67-
6867
const RESULT_TREE = 'result[suites[cases[name,status]]]';
6968
const CITGM_REPORT_TREE =
7069
`failCount,skipCount,totalCount,childReports[child[url],${RESULT_TREE}]`;
@@ -761,9 +760,11 @@ class CITGMBuild extends TestBuild {
761760
}
762761

763762
async getResults() {
763+
const { id } = this;
764+
764765
let headerData;
765766
try {
766-
headerData = await this.getBuildData('Header');
767+
headerData = await this.getBuildData('Summary');
767768
} catch (err) {
768769
this.failures = [
769770
new NCUFailure({ url: this.apiUrl }, err.message)
@@ -777,43 +778,51 @@ class CITGMBuild extends TestBuild {
777778
// CITGM jobs store results in a different location than
778779
// they do summary data, so we need to update the endpoint
779780
// and issue a second API call in order to fetch result data.
780-
this.updateAPIVariables();
781+
this.tree = CITGM_REPORT_TREE;
782+
this.path = `job/citgm-smoker/${this.id}/testReport/`;
781783

782784
let resultData;
783785
try {
784-
resultData = await this.getBuildData('Report');
786+
resultData = await this.getBuildData('Results');
785787
} catch (err) {
786788
this.failures = [
787789
new NCUFailure({ url: this.apiUrl }, err.message)
788790
];
789791
return this.failures;
790792
}
791793

792-
const { childReports } = resultData;
794+
this.results = this.parseResults(resultData.childReports);
793795

794-
this.results = this.parseResults(childReports);
796+
// Update id again so that it correctly displays in Summary output.
797+
this.path = `job/citgm-smoker/${id}/`;
795798

796799
return { result };
797800
}
798801

802+
formatAsJson() {
803+
const { results } = this;
804+
805+
const result = results.all.map(item => Object.assign({
806+
source: this.sourceURL,
807+
upstream: this.jobUrl
808+
}, item));
809+
810+
return JSON.parse(JSON.stringify(result));
811+
}
812+
799813
parseResults(data) {
800-
const results = { passes: [], failures: [], skips: [], fixes: [] };
814+
const results = { all: [], failures: [] };
815+
801816
data.forEach(platform => {
802817
const cases = flatten(platform.result.suites[0].cases);
803818
const nodeName = getNodeName(platform.child.url);
804819

805-
const passedModules = cases.filter(c => c.status === 'PASSED');
806-
results.passes.push({ [nodeName]: passedModules });
820+
results.all.push({ [nodeName]: cases });
807821

808822
const failedModules = cases.filter(c => c.status === 'FAILED');
809823
results.failures.push({ [nodeName]: failedModules });
810-
811-
const skippedModules = cases.filter(c => c.status === 'SKIPPED');
812-
results.skips.push({ [nodeName]: skippedModules });
813-
814-
const fixedModules = cases.filter(c => c.status === 'FIXED');
815-
results.fixes.push({ [nodeName]: fixedModules });
816824
});
825+
817826
return results;
818827
}
819828

@@ -831,11 +840,6 @@ class CITGMBuild extends TestBuild {
831840
console.table(output);
832841
}
833842

834-
updateAPIVariables() {
835-
this.tree = CITGM_REPORT_TREE;
836-
this.path = `job/citgm-smoker/${this.id}/testReport/`;
837-
}
838-
839843
display() {
840844
this.displayHeader();
841845
this.displayBuilds();

0 commit comments

Comments
 (0)