From a4298938f84382588db3101dcf611d89f6f0f1e9 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 8 Sep 2020 08:23:26 -0700 Subject: [PATCH] fix: handle citgm failures better (#497) --- bin/ncu-ci | 9 ++++-- lib/ci/build-types/citgm_build.js | 29 +++++++++++++++----- lib/ci/build-types/citgm_comparison_build.js | 21 +++++++++++++- lib/ci/build-types/test_build.js | 2 +- 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/bin/ncu-ci b/bin/ncu-ci index 2a530602..168e7ed9 100755 --- a/bin/ncu-ci +++ b/bin/ncu-ci @@ -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(); } diff --git a/lib/ci/build-types/citgm_build.js b/lib/ci/build-types/citgm_build.js index 6ce4edb2..3764b195 100644 --- a/lib/ci/build-types/citgm_build.js +++ b/lib/ci/build-types/citgm_build.js @@ -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; @@ -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; } @@ -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; diff --git a/lib/ci/build-types/citgm_comparison_build.js b/lib/ci/build-types/citgm_comparison_build.js index f192cab1..159f85d1 100644 --- a/lib/ci/build-types/citgm_comparison_build.js +++ b/lib/ci/build-types/citgm_comparison_build.js @@ -18,6 +18,7 @@ class CITGMComparisonBuild { this.cli = cli; this.builds = { baseBuild, comparisonBuild }; this.results = {}; + this.failures = { baseBuild: [], comparisonBuild: [] }; } async getResults() { @@ -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); + return; + } + const { failures: baseFailures } = baseBuild.results; const { failures: comparisonFailures } = comparisonBuild.results; @@ -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(); diff --git a/lib/ci/build-types/test_build.js b/lib/ci/build-types/test_build.js index 62ed3197..3e357fb1 100644 --- a/lib/ci/build-types/test_build.js +++ b/lib/ci/build-types/test_build.js @@ -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;