Skip to content

Commit

Permalink
[7.x] [dev-utils/ship-ci-stats] fail when CI stats is down (#90678) (#…
Browse files Browse the repository at this point in the history
…90706)

Co-authored-by: spalger <spalger@users.noreply.github.com>

Co-authored-by: Spencer <email@spalger.com>
Co-authored-by: spalger <spalger@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 9, 2021
1 parent 8ddbaba commit 99299e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class CiStatsReporter {
},
});

return;
return true;
} catch (error) {
if (!error?.request) {
// not an axios error, must be a usage error that we should notify user about
Expand Down
14 changes: 11 additions & 3 deletions packages/kbn-dev-utils/src/ci_stats_reporter/ship_ci_stats_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Path from 'path';
import Fs from 'fs';

import { CiStatsReporter } from './ci_stats_reporter';
import { run, createFlagError } from '../run';
import { run, createFlagError, createFailError } from '../run';

export function shipCiStatsCli() {
run(
Expand All @@ -23,12 +23,20 @@ export function shipCiStatsCli() {
}

const reporter = CiStatsReporter.fromEnv(log);

if (!reporter.isEnabled()) {
throw createFailError('unable to initilize the CI Stats reporter');
}

for (const path of metricPaths) {
// resolve path from CLI relative to CWD
const abs = Path.resolve(path);
const json = Fs.readFileSync(abs, 'utf8');
await reporter.metrics(JSON.parse(json));
log.success('shipped metrics from', path);
if (await reporter.metrics(JSON.parse(json))) {
log.success('shipped metrics from', path);
} else {
throw createFailError('failed to ship metrics');
}
}
},
{
Expand Down

0 comments on commit 99299e0

Please sign in to comment.