mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
chore(NA): bazel machinery installation on kbn bootstrap (#89469)
* chore(NA): bazel machinery installation on kbn bootstrap * refact(NA): simplify install logic * chore(NA): update kbn pm with last changes
This commit is contained in:
parent
2572cd291b
commit
cf3c746eca
10 changed files with 1455 additions and 1290 deletions
1
.bazeliskversion
Normal file
1
.bazeliskversion
Normal file
|
@ -0,0 +1 @@
|
|||
1.7.3
|
1
.bazelversion
Normal file
1
.bazelversion
Normal file
|
@ -0,0 +1 @@
|
|||
4.0.0
|
3
WORKSPACE.bazel
Normal file
3
WORKSPACE.bazel
Normal file
|
@ -0,0 +1,3 @@
|
|||
workspace(
|
||||
name = "kibana",
|
||||
)
|
|
@ -346,6 +346,7 @@
|
|||
"@babel/register": "^7.12.10",
|
||||
"@babel/traverse": "^7.12.12",
|
||||
"@babel/types": "^7.12.12",
|
||||
"@bazel/ibazel": "^0.14.0",
|
||||
"@cypress/snapshot": "^2.1.7",
|
||||
"@cypress/webpack-preprocessor": "^5.5.0",
|
||||
"@elastic/apm-rum": "^5.6.1",
|
||||
|
|
2661
packages/kbn-pm/dist/index.js
vendored
2661
packages/kbn-pm/dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -17,12 +17,13 @@ import { getAllChecksums } from '../utils/project_checksums';
|
|||
import { BootstrapCacheFile } from '../utils/bootstrap_cache_file';
|
||||
import { readYarnLock } from '../utils/yarn_lock';
|
||||
import { validateDependencies } from '../utils/validate_dependencies';
|
||||
import { installBazelTools } from '../utils/bazel';
|
||||
|
||||
export const BootstrapCommand: ICommand = {
|
||||
description: 'Install dependencies and crosslink projects',
|
||||
name: 'bootstrap',
|
||||
|
||||
async run(projects, projectGraph, { options, kbn }) {
|
||||
async run(projects, projectGraph, { options, kbn, rootPath }) {
|
||||
const batchedProjects = topologicallyBatchProjects(projects, projectGraph);
|
||||
const kibanaProjectPath = projects.get('kibana')?.path;
|
||||
const extraArgs = [
|
||||
|
@ -30,6 +31,10 @@ export const BootstrapCommand: ICommand = {
|
|||
...(options['prefer-offline'] === true ? ['--prefer-offline'] : []),
|
||||
];
|
||||
|
||||
// Install bazel machinery tools if needed
|
||||
await installBazelTools(rootPath);
|
||||
|
||||
// Install monorepo npm dependencies
|
||||
for (const batch of batchedProjects) {
|
||||
for (const project of batch) {
|
||||
const isExternalPlugin = project.path.includes(`${kibanaProjectPath}${sep}plugins`);
|
||||
|
|
9
packages/kbn-pm/src/utils/bazel/index.ts
Normal file
9
packages/kbn-pm/src/utils/bazel/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* and the Server Side Public License, v 1; you may not use this file except in
|
||||
* compliance with, at your election, the Elastic License or the Server Side
|
||||
* Public License, v 1.
|
||||
*/
|
||||
|
||||
export * from './install_tools';
|
53
packages/kbn-pm/src/utils/bazel/install_tools.ts
Normal file
53
packages/kbn-pm/src/utils/bazel/install_tools.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* and the Server Side Public License, v 1; you may not use this file except in
|
||||
* compliance with, at your election, the Elastic License or the Server Side
|
||||
* Public License, v 1.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { spawn } from '../child_process';
|
||||
import { readFile } from '../fs';
|
||||
import { log } from '../log';
|
||||
|
||||
async function readBazelToolsVersionFile(repoRootPath: string, versionFilename: string) {
|
||||
const version = (await readFile(resolve(repoRootPath, versionFilename)))
|
||||
.toString()
|
||||
.split('\n')[0];
|
||||
|
||||
if (!version) {
|
||||
throw new Error(
|
||||
`[bazel_tools] Failed on reading bazel tools versions\n ${versionFilename} file do not contain any version set`
|
||||
);
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
export async function installBazelTools(repoRootPath: string) {
|
||||
log.debug(`[bazel_tools] reading bazel tools versions from version files`);
|
||||
const bazeliskVersion = await readBazelToolsVersionFile(repoRootPath, '.bazeliskversion');
|
||||
const bazelVersion = await readBazelToolsVersionFile(repoRootPath, '.bazelversion');
|
||||
|
||||
// Check what globals are installed
|
||||
log.debug(`[bazel_tools] verify if bazelisk is installed`);
|
||||
const { stdout } = await spawn('yarn', ['global', 'list'], { stdio: 'pipe' });
|
||||
|
||||
// Install bazelisk if not installed
|
||||
if (!stdout.includes(`@bazel/bazelisk@${bazeliskVersion}`)) {
|
||||
log.info(`[bazel_tools] installing Bazel tools`);
|
||||
|
||||
log.debug(
|
||||
`[bazel_tools] bazelisk is not installed. Installing @bazel/bazelisk@${bazeliskVersion} and bazel@${bazelVersion}`
|
||||
);
|
||||
await spawn('yarn', ['global', 'add', `@bazel/bazelisk@${bazeliskVersion}`], {
|
||||
env: {
|
||||
USE_BAZEL_VERSION: bazelVersion,
|
||||
},
|
||||
stdio: 'pipe',
|
||||
});
|
||||
}
|
||||
|
||||
log.success(`[bazel_tools] all bazel tools are correctly installed`);
|
||||
}
|
|
@ -65,6 +65,10 @@ export const IGNORE_FILE_GLOBS = [
|
|||
'x-pack/test/fleet_api_integration/apis/fixtures/test_packages/**/*',
|
||||
|
||||
'.teamcity/**/*',
|
||||
|
||||
// Bazel default files
|
||||
'**/WORKSPACE.bazel',
|
||||
'**/BUILD.bazel',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -1997,6 +1997,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@base2/pretty-print-object/-/pretty-print-object-1.0.0.tgz#860ce718b0b73f4009e153541faff2cb6b85d047"
|
||||
integrity sha512-4Th98KlMHr5+JkxfcoDT//6vY8vM+iSPrLNpHhRyLx2CFYi8e2RfqPLdpbnpo0Q5lQC5hNB79yes07zb02fvCw==
|
||||
|
||||
"@bazel/ibazel@^0.14.0":
|
||||
version "0.14.0"
|
||||
resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.14.0.tgz#86fa0002bed2ce1123b7ad98d4dd4623a0d93244"
|
||||
integrity sha512-s0gyec6lArcRDwVfIP6xpY8iEaFpzrSpyErSppd3r2O49pOEg7n6HGS/qJ8ncvme56vrDk6crl/kQ6VAdEO+rg==
|
||||
|
||||
"@bcoe/v8-coverage@^0.2.3":
|
||||
version "0.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue