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

fix: handle citgm failures better #497

Merged
merged 1 commit into from
Sep 8, 2020
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
9 changes: 6 additions & 3 deletions bin/ncu-ci
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,13 @@ class CICommand {
await build.getResults();
build.display();

const json = build.formatAsJson();
if (json !== undefined) {
this.json = this.json.concat(json);
if (argv.json) {
const json = build.formatAsJson();
if (json !== undefined) {
this.json = this.json.concat(json);
}
}

if ((argv.copy || argv.markdown) && !argv.stats) {
this.markdown += build.formatAsMarkdown();
}
Expand Down
29 changes: 22 additions & 7 deletions lib/ci/build-types/citgm_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ class CITGMBuild extends TestBuild {

this.id = jobid;
this.noBuild = noBuild;
this.failures = [];
}

async getResults() {
const { apiUrl } = this;
const { apiUrl, cli } = this;

let headerData;
try {
headerData = await this.getBuildData('Summary');
} catch (err) {
this.failures = [
new NCUFailure({ url: this.apiUrl }, err.message)
];
cli.stopSpinner('Failed to download Summary data',
cli.SPINNER_STATUS.FAILED);
this.failures.push(new NCUFailure({ url: this.apiUrl }, err.message));
return this.failures;
}
const { result } = headerData;
Expand All @@ -55,9 +56,9 @@ class CITGMBuild extends TestBuild {
try {
resultData = await this.getBuildData('Results');
} catch (err) {
this.failures = [
new NCUFailure({ url: apiUrl }, err.message)
];
cli.stopSpinner('Failed to download Results data',
cli.SPINNER_STATUS.FAILED);
this.failures.push(new NCUFailure({ url: apiUrl }, err.message));
return this.failures;
}

Expand Down Expand Up @@ -110,6 +111,20 @@ class CITGMBuild extends TestBuild {
}
}

display() {
const { failures } = this;

if (failures.length) {
for (const failure of failures) {
this.displayFailure(failure);
}
return;
}

this.displayHeader();
this.displayBuilds();
}

displayBuilds() {
const { cli, results } = this;
const { failed, skipped, passed, total } = results.statistics;
Expand Down
21 changes: 20 additions & 1 deletion lib/ci/build-types/citgm_comparison_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CITGMComparisonBuild {
this.cli = cli;
this.builds = { baseBuild, comparisonBuild };
this.results = {};
this.failures = { baseBuild: [], comparisonBuild: [] };
}

async getResults() {
Expand All @@ -33,6 +34,14 @@ class CITGMComparisonBuild {
await baseBuild.getResults();
await comparisonBuild.getResults();

if (baseBuild.failures.length || comparisonBuild.failures.length) {
this.failures.baseBuild =
this.failures.baseBuild.concat(baseBuild.failures);
this.failures.comparisonBuild =
this.failures.comparisonBuild.concat(comparisonBuild.failures);
Comment on lines +38 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: not sure which one is better, but this one is shorter 😄

Suggested change
this.failures.baseBuild =
this.failures.baseBuild.concat(baseBuild.failures);
this.failures.comparisonBuild =
this.failures.comparisonBuild.concat(comparisonBuild.failures);
this.failures.baseBuild.push(...baseBuild.failures);
this.failures.comparisonBuild.push(...comparisonBuild.failures);

return;
}

const { failures: baseFailures } = baseBuild.results;
const { failures: comparisonFailures } = comparisonBuild.results;

Expand Down Expand Up @@ -70,7 +79,17 @@ class CITGMComparisonBuild {
}

display() {
const { builds } = this;
const { builds, failures } = this;

if (failures.baseBuild.length || failures.comparisonBuild.length) {
for (const failure of failures.baseBuild) {
builds.baseBuild.displayFailure(failure);
}
for (const failure of failures.comparisonBuild) {
builds.comparisonBuild.displayFailure(failure);
}
return;
}

// Display header for both CITGM runs.
builds.baseBuild.displayHeader();
Expand Down
2 changes: 1 addition & 1 deletion lib/ci/build-types/test_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TestBuild extends Job {
this.builtOn = builtOn;
}

setDailyBuildData({ result, changeSet, actions, timestamp, builtOn }) {
setDailyBuildData({ result, changeSet, timestamp, builtOn }) {
this.change = changeSet.items[0] || {};
this.date = new Date(timestamp);
this.result = result;
Expand Down