[dev-utils/ship-ci-stats] fail when CI stats is down (#90678)

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer 2021-02-08 14:46:57 -08:00 committed by GitHub
parent 54863889d4
commit 3ef3e9324f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -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(
@ -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');
}
}
},
{