-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kbn/optimizer][ci-stats] ship metrics separate from build (#90482)
Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
c306a44
commit a0ce7b5
Showing
33 changed files
with
518 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
*/ | ||
|
||
export * from './ci_stats_reporter'; | ||
export * from './ship_ci_stats_cli'; |
48 changes: 48 additions & 0 deletions
48
packages/kbn-dev-utils/src/ci_stats_reporter/ship_ci_stats_cli.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import Path from 'path'; | ||
import Fs from 'fs'; | ||
|
||
import { CiStatsReporter } from './ci_stats_reporter'; | ||
import { run, createFlagError } from '../run'; | ||
|
||
export function shipCiStatsCli() { | ||
run( | ||
async ({ log, flags }) => { | ||
let metricPaths = flags.metrics; | ||
if (typeof metricPaths === 'string') { | ||
metricPaths = [metricPaths]; | ||
} else if (!Array.isArray(metricPaths) || !metricPaths.every((p) => typeof p === 'string')) { | ||
throw createFlagError('expected --metrics to be a string'); | ||
} | ||
|
||
const reporter = CiStatsReporter.fromEnv(log); | ||
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); | ||
} | ||
}, | ||
{ | ||
description: 'ship ci-stats which have been written to files', | ||
usage: `node scripts/ship_ci_stats`, | ||
log: { | ||
defaultLevel: 'debug', | ||
}, | ||
flags: { | ||
string: ['metrics'], | ||
help: ` | ||
--metrics [path] A path to a JSON file that includes metrics which should be sent. Multiple instances supported | ||
`, | ||
}, | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 34 additions & 1 deletion
35
packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.