chore(NA): bazel machinery installation on kbn bootstrap (#89469) (#89521)

* 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:
Tiago Costa 2021-01-28 02:42:44 +00:00 committed by GitHub
parent 78d7dcae7a
commit 228666c209
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1455 additions and 1290 deletions

1
.bazeliskversion Normal file
View file

@ -0,0 +1 @@
1.7.3

1
.bazelversion Normal file
View file

@ -0,0 +1 @@
4.0.0

3
WORKSPACE.bazel Normal file
View file

@ -0,0 +1,3 @@
workspace(
name = "kibana",
)

View file

@ -343,6 +343,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",

File diff suppressed because one or more lines are too long

View file

@ -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`);

View 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';

View 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`);
}

View file

@ -64,6 +64,10 @@ export const IGNORE_FILE_GLOBS = [
'x-pack/test/fleet_api_integration/apis/fixtures/test_packages/**/*',
'.teamcity/**/*',
// Bazel default files
'**/WORKSPACE.bazel',
'**/BUILD.bazel',
];
/**

View file

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