mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[kbn/pm] add timings for more parts of bootstrap (#127157)
This commit is contained in:
parent
e3e5df6617
commit
daace920d7
4 changed files with 83 additions and 49 deletions
60
packages/kbn-pm/dist/index.js
vendored
60
packages/kbn-pm/dist/index.js
vendored
|
@ -8908,10 +8908,24 @@ const BootstrapCommand = {
|
|||
const kibanaProjectPath = ((_projects$get = projects.get('kibana')) === null || _projects$get === void 0 ? void 0 : _projects$get.path) || '';
|
||||
const runOffline = (options === null || options === void 0 ? void 0 : options.offline) === true;
|
||||
const reporter = _kbn_dev_utils_ci_stats_reporter__WEBPACK_IMPORTED_MODULE_1__["CiStatsReporter"].fromEnv(_utils_log__WEBPACK_IMPORTED_MODULE_2__["log"]);
|
||||
const timings = []; // Force install is set in case a flag is passed or
|
||||
const timings = [];
|
||||
|
||||
const time = async (id, body) => {
|
||||
const start = Date.now();
|
||||
|
||||
try {
|
||||
return await body();
|
||||
} finally {
|
||||
timings.push({
|
||||
id,
|
||||
ms: Date.now() - start
|
||||
});
|
||||
}
|
||||
}; // Force install is set in case a flag is passed or
|
||||
// if the `.yarn-integrity` file is not found which
|
||||
// will be indicated by the return of yarnIntegrityFileExists.
|
||||
|
||||
|
||||
const forceInstall = !!options && options['force-install'] === true || !(await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["yarnIntegrityFileExists"])(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(kibanaProjectPath, 'node_modules'))); // Ensure we have a `node_modules/.yarn-integrity` file as we depend on it
|
||||
// for bazel to know it has to re-install the node_modules after a reset or a clean
|
||||
|
||||
|
@ -8930,20 +8944,14 @@ const BootstrapCommand = {
|
|||
//
|
||||
|
||||
if (forceInstall) {
|
||||
const forceInstallStartTime = Date.now();
|
||||
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@nodejs//:yarn'], runOffline);
|
||||
timings.push({
|
||||
id: 'force install dependencies',
|
||||
ms: Date.now() - forceInstallStartTime
|
||||
await time('force install dependencies', async () => {
|
||||
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@nodejs//:yarn'], runOffline);
|
||||
});
|
||||
} // build packages
|
||||
|
||||
|
||||
const packageStartTime = Date.now();
|
||||
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['build', '//packages:build', '--show_result=1'], runOffline);
|
||||
timings.push({
|
||||
id: 'build packages',
|
||||
ms: Date.now() - packageStartTime
|
||||
await time('build packages', async () => {
|
||||
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['build', '//packages:build', '--show_result=1'], runOffline);
|
||||
}); // Install monorepo npm dependencies outside of the Bazel managed ones
|
||||
|
||||
for (const batch of batchedNonBazelProjects) {
|
||||
|
@ -8965,25 +8973,33 @@ const BootstrapCommand = {
|
|||
}
|
||||
}
|
||||
|
||||
await Object(_utils_sort_package_json__WEBPACK_IMPORTED_MODULE_7__["sortPackageJson"])(kbn);
|
||||
const yarnLock = await Object(_utils_yarn_lock__WEBPACK_IMPORTED_MODULE_6__["readYarnLock"])(kbn);
|
||||
await time('sort package json', async () => {
|
||||
await Object(_utils_sort_package_json__WEBPACK_IMPORTED_MODULE_7__["sortPackageJson"])(kbn);
|
||||
});
|
||||
const yarnLock = await time('read yarn.lock', async () => await Object(_utils_yarn_lock__WEBPACK_IMPORTED_MODULE_6__["readYarnLock"])(kbn));
|
||||
|
||||
if (options.validate) {
|
||||
await Object(_utils_validate_dependencies__WEBPACK_IMPORTED_MODULE_8__["validateDependencies"])(kbn, yarnLock);
|
||||
await time('validate dependencies', async () => {
|
||||
await Object(_utils_validate_dependencies__WEBPACK_IMPORTED_MODULE_8__["validateDependencies"])(kbn, yarnLock);
|
||||
});
|
||||
} // Assure all kbn projects with bin defined scripts
|
||||
// copy those scripts into the top level node_modules folder
|
||||
//
|
||||
// NOTE: We don't probably need this anymore, is actually not being used
|
||||
|
||||
|
||||
await Object(_utils_link_project_executables__WEBPACK_IMPORTED_MODULE_4__["linkProjectExecutables"])(projects, projectGraph); // Update vscode settings
|
||||
|
||||
await Object(_utils_child_process__WEBPACK_IMPORTED_MODULE_3__["spawnStreaming"])(process.execPath, ['scripts/update_vscode_config'], {
|
||||
cwd: kbn.getAbsolute(),
|
||||
env: process.env
|
||||
}, {
|
||||
prefix: '[vscode]',
|
||||
debug: false
|
||||
await time('link project executables', async () => {
|
||||
await Object(_utils_link_project_executables__WEBPACK_IMPORTED_MODULE_4__["linkProjectExecutables"])(projects, projectGraph);
|
||||
});
|
||||
await time('update vscode config', async () => {
|
||||
// Update vscode settings
|
||||
await Object(_utils_child_process__WEBPACK_IMPORTED_MODULE_3__["spawnStreaming"])(process.execPath, ['scripts/update_vscode_config'], {
|
||||
cwd: kbn.getAbsolute(),
|
||||
env: process.env
|
||||
}, {
|
||||
prefix: '[vscode]',
|
||||
debug: false
|
||||
});
|
||||
}); // send timings
|
||||
|
||||
await reporter.timings({
|
||||
|
|
|
@ -40,7 +40,19 @@ export const BootstrapCommand: ICommand = {
|
|||
const kibanaProjectPath = projects.get('kibana')?.path || '';
|
||||
const runOffline = options?.offline === true;
|
||||
const reporter = CiStatsReporter.fromEnv(log);
|
||||
const timings = [];
|
||||
|
||||
const timings: Array<{ id: string; ms: number }> = [];
|
||||
const time = async <T>(id: string, body: () => Promise<T>): Promise<T> => {
|
||||
const start = Date.now();
|
||||
try {
|
||||
return await body();
|
||||
} finally {
|
||||
timings.push({
|
||||
id,
|
||||
ms: Date.now() - start,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Force install is set in case a flag is passed or
|
||||
// if the `.yarn-integrity` file is not found which
|
||||
|
@ -70,20 +82,14 @@ export const BootstrapCommand: ICommand = {
|
|||
//
|
||||
|
||||
if (forceInstall) {
|
||||
const forceInstallStartTime = Date.now();
|
||||
await runBazel(['run', '@nodejs//:yarn'], runOffline);
|
||||
timings.push({
|
||||
id: 'force install dependencies',
|
||||
ms: Date.now() - forceInstallStartTime,
|
||||
await time('force install dependencies', async () => {
|
||||
await runBazel(['run', '@nodejs//:yarn'], runOffline);
|
||||
});
|
||||
}
|
||||
|
||||
// build packages
|
||||
const packageStartTime = Date.now();
|
||||
await runBazel(['build', '//packages:build', '--show_result=1'], runOffline);
|
||||
timings.push({
|
||||
id: 'build packages',
|
||||
ms: Date.now() - packageStartTime,
|
||||
await time('build packages', async () => {
|
||||
await runBazel(['build', '//packages:build', '--show_result=1'], runOffline);
|
||||
});
|
||||
|
||||
// Install monorepo npm dependencies outside of the Bazel managed ones
|
||||
|
@ -112,30 +118,38 @@ export const BootstrapCommand: ICommand = {
|
|||
}
|
||||
}
|
||||
|
||||
await sortPackageJson(kbn);
|
||||
await time('sort package json', async () => {
|
||||
await sortPackageJson(kbn);
|
||||
});
|
||||
|
||||
const yarnLock = await readYarnLock(kbn);
|
||||
const yarnLock = await time('read yarn.lock', async () => await readYarnLock(kbn));
|
||||
|
||||
if (options.validate) {
|
||||
await validateDependencies(kbn, yarnLock);
|
||||
await time('validate dependencies', async () => {
|
||||
await validateDependencies(kbn, yarnLock);
|
||||
});
|
||||
}
|
||||
|
||||
// Assure all kbn projects with bin defined scripts
|
||||
// copy those scripts into the top level node_modules folder
|
||||
//
|
||||
// NOTE: We don't probably need this anymore, is actually not being used
|
||||
await linkProjectExecutables(projects, projectGraph);
|
||||
await time('link project executables', async () => {
|
||||
await linkProjectExecutables(projects, projectGraph);
|
||||
});
|
||||
|
||||
// Update vscode settings
|
||||
await spawnStreaming(
|
||||
process.execPath,
|
||||
['scripts/update_vscode_config'],
|
||||
{
|
||||
cwd: kbn.getAbsolute(),
|
||||
env: process.env,
|
||||
},
|
||||
{ prefix: '[vscode]', debug: false }
|
||||
);
|
||||
await time('update vscode config', async () => {
|
||||
// Update vscode settings
|
||||
await spawnStreaming(
|
||||
process.execPath,
|
||||
['scripts/update_vscode_config'],
|
||||
{
|
||||
cwd: kbn.getAbsolute(),
|
||||
env: process.env,
|
||||
},
|
||||
{ prefix: '[vscode]', debug: false }
|
||||
);
|
||||
});
|
||||
|
||||
// send timings
|
||||
await reporter.timings({
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/setup_node_env/no_transpilation');
|
||||
require('@kbn/dev-utils').runUpdateVscodeConfigCli();
|
||||
|
|
|
@ -101,7 +101,7 @@ const DEFAULT_ARGS = [
|
|||
const DIAGNOSTIC_TIME = 5 * 1000;
|
||||
|
||||
export class HeadlessChromiumDriverFactory {
|
||||
private userDataDir = fs.mkdtempSync(path.join(getDataPath(), 'chromium-'));
|
||||
private userDataDir: string;
|
||||
type = 'chromium';
|
||||
|
||||
constructor(
|
||||
|
@ -111,6 +111,10 @@ export class HeadlessChromiumDriverFactory {
|
|||
private binaryPath: string,
|
||||
private basePath: string
|
||||
) {
|
||||
const dataDir = getDataPath();
|
||||
fs.mkdirSync(dataDir, { recursive: true });
|
||||
this.userDataDir = fs.mkdtempSync(path.join(dataDir, 'chromium-'));
|
||||
|
||||
if (this.config.browser.chromium.disableSandbox) {
|
||||
logger.warn(`Enabling the Chromium sandbox provides an additional layer of protection.`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue