Skip to content

Commit c9acc32

Browse files
Spencerspalger
authored andcommitted
[dev-utils/ship-ci-stats] fail when CI stats is down (#90678)
Co-authored-by: spalger <[email protected]>
1 parent 0e73f23 commit c9acc32

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class CiStatsReporter {
109109
},
110110
});
111111

112-
return;
112+
return true;
113113
} catch (error) {
114114
if (!error?.request) {
115115
// not an axios error, must be a usage error that we should notify user about

packages/kbn-dev-utils/src/ci_stats_reporter/ship_ci_stats_cli.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Path from 'path';
1010
import Fs from 'fs';
1111

1212
import { CiStatsReporter } from './ci_stats_reporter';
13-
import { run, createFlagError } from '../run';
13+
import { run, createFlagError, createFailError } from '../run';
1414

1515
export function shipCiStatsCli() {
1616
run(
@@ -23,12 +23,20 @@ export function shipCiStatsCli() {
2323
}
2424

2525
const reporter = CiStatsReporter.fromEnv(log);
26+
27+
if (!reporter.isEnabled()) {
28+
throw createFailError('unable to initilize the CI Stats reporter');
29+
}
30+
2631
for (const path of metricPaths) {
2732
// resolve path from CLI relative to CWD
2833
const abs = Path.resolve(path);
2934
const json = Fs.readFileSync(abs, 'utf8');
30-
await reporter.metrics(JSON.parse(json));
31-
log.success('shipped metrics from', path);
35+
if (await reporter.metrics(JSON.parse(json))) {
36+
log.success('shipped metrics from', path);
37+
} else {
38+
throw createFailError('failed to ship metrics');
39+
}
3240
}
3341
},
3442
{

0 commit comments

Comments
 (0)