[build] Merge x-pack build (#138055)

This commit is contained in:
Jonathan Budzenski 2022-08-04 14:02:46 -04:00 committed by GitHub
parent a5da868db5
commit d5c6d471e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 134 deletions

View file

@ -78,8 +78,6 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
if (options.buildCanvasShareableRuntime) {
await run(Tasks.BuildCanvasShareableRuntime);
}
await run(Tasks.BuildXpack);
await run(Tasks.BuildKibanaPlatformPlugins);
await run(Tasks.TranspileBabel);
await run(Tasks.CreatePackageJson);

View file

@ -6,13 +6,12 @@
* Side Public License, v 1.
*/
import cpy from 'cpy';
import Path from 'path';
import { discoverBazelPackages } from '@kbn/bazel-packages';
import { runBazel } from '@kbn/bazel-runner';
import { Task, scanCopy, write, exec } from '../lib';
import { Task, scanCopy, write } from '../lib';
export const BuildBazelPackages: Task = {
description: 'Building distributable versions of Bazel packages',
@ -40,20 +39,3 @@ export const BuildBazelPackages: Task = {
}
},
};
export const BuildXpack: Task = {
description: 'Building distributable versions of x-pack',
async run(config, log, build) {
log.info('running x-pack build task');
await exec(log, 'yarn', ['build'], {
level: 'debug',
cwd: config.resolveFromRepo('x-pack'),
});
log.info('copying built x-pack into build dir');
await cpy('**/{.,}*', build.resolvePath('x-pack'), {
cwd: config.resolveFromRepo('x-pack/build/plugin/kibana/x-pack'),
parents: true,
});
},
};

View file

@ -19,35 +19,49 @@ export const CopySource: Task = {
select: [
'yarn.lock',
'.npmrc',
'src/**',
'!src/**/*.{test,test.mocks,mock}.{js,ts,tsx}',
'!src/**/mocks.ts', // special file who imports .mock files
'!src/**/{target,tests,__jest__,test_data,__tests__,__snapshots__,__mocks__,integration_tests,__fixtures__}/**',
'!src/core/server/core_app/assets/favicons/favicon.distribution.ico',
'!src/core/server/core_app/assets/favicons/favicon.distribution.png',
'!src/core/server/core_app/assets/favicons/favicon.distribution.svg',
'!src/test_utils/**',
'!src/fixtures/**',
'!src/cli/repl/**',
'!src/cli*/dev.js',
'!src/functional_test_runner/**',
'!src/dev/**',
'!**/jest.config.js',
'!**/jest.integration.config.js',
'!**/mocks.js',
'!**/test_utils.js',
'!**/test_helpers.js',
'!**/*.{md,mdx,asciidoc}',
'!src/plugins/telemetry/schema/**', // Skip telemetry schemas
// this is the dev-only entry
'!src/setup_node_env/index.js',
'!**/public/**/*.{js,ts,tsx,json,scss}',
'typings/**',
'kibana.d.ts',
'config/kibana.yml',
'config/node.options',
'typings/**',
'tsconfig*.json',
'.i18nrc.json',
'kibana.d.ts',
'src/**',
'x-pack/plugins/**',
'x-pack/.i18nrc.json',
'x-pack/package.json',
'!{src,x-pack}/**/*.{test,test.mocks,mock,mocks}.*',
'!{src,x-pack}/**/target/**',
'!{src,x-pack}/**/{__stories__,storybook,.storybook}/**',
'!{src,x-pack}/**/{test,tests,test_resources,test_data,__tests__,manual_tests,__jest__,__snapshots__,__mocks__,mock_responses,mocks,fixtures,__fixtures__,cypress,integration_tests}/**',
'!src/dev/**',
'!src/**/mocks.{js,ts}',
'!src/cli/repl/**',
'!src/cli*/dev.js',
'!src/plugins/telemetry/schema/**',
'!src/core/server/core_app/assets/favicons/favicon.distribution.{ico,png,svg}',
'!src/functional_test_runner/**',
'!src/setup_node_env/index.js',
'!x-pack/plugins/**/{ftr_e2e,e2e}/**',
'!x-pack/plugins/**/scripts/**',
'!x-pack/plugins/telemetry_collection_xpack/schema/**',
'!**/jest.config.js',
'!**/jest.config.dev.js',
'!**/jest.integration.config.js',
'!**/jest_setup.{js,ts}',
'!**/*.{story,stories}.{js,ts}',
'!**/test_mocks.ts',
'!**/*.{sh,md,mdx,asciidoc}',
'!**/*.console',
'!**/*.scss',
'!**/*.docnav.json',
'!**/{dev_docs,docs}/**',
'!**/public/**/*.{js,ts,tsx,json}',
// explicitly ignore all bazel package locations, even if they're not selected by previous patterns
...(await discoverBazelPackages()).map((pkg) => `!${pkg.normalizedRepoRelativeDir}/**`),
],

View file

@ -18,6 +18,7 @@ export const CleanNodeBuilds: Task = {
build.resolvePathForPlatform(platform, 'node/lib/node_modules'),
build.resolvePathForPlatform(platform, 'node/bin/npm'),
build.resolvePathForPlatform(platform, 'node/bin/npx'),
build.resolvePathForPlatform(platform, 'node/bin/corepack'),
],
log
);

View file

@ -7,11 +7,9 @@
require('../src/setup_node_env');
const { buildTask } = require('./tasks/build');
const { downloadChromium } = require('./tasks/download_chromium');
// export the tasks that are runnable from the CLI
module.exports = {
build: buildTask,
downloadChromium,
};

View file

@ -8,7 +8,6 @@
"github-checks-reporter": "../node_modules/.bin/github-checks-reporter",
"kbn": "node ../scripts/kbn",
"start": "node ../scripts/kibana --dev",
"build": "node --preserve-symlinks ../node_modules/.bin/gulp build",
"test:jest": "node ../scripts/jest"
},
"kibana": {

View file

@ -1,85 +0,0 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { resolve } from 'path';
import { promisify } from 'util';
import { pipeline } from 'stream';
import { discoverBazelPackages } from '@kbn/bazel-packages';
import { REPO_ROOT } from '@kbn/utils';
import { ToolingLog } from '@kbn/tooling-log';
import gulp from 'gulp';
import del from 'del';
import vfs from 'vinyl-fs';
const asyncPipeline = promisify(pipeline);
const XPACK_DIR = resolve(REPO_ROOT, 'x-pack');
const BUILD_DIR = resolve(XPACK_DIR, 'build');
const PLUGIN_BUILD_DIR = resolve(BUILD_DIR, 'plugin/kibana/x-pack');
async function cleanBuildTask() {
const log = new ToolingLog();
log.info('Deleting', BUILD_DIR);
await del(BUILD_DIR);
}
async function copySource() {
// get bazel packages inside x-pack
const xpackBazelPackages = (await discoverBazelPackages())
.filter((pkg) => pkg.normalizedRepoRelativeDir.startsWith('x-pack/'))
.map((pkg) => `${pkg.normalizedRepoRelativeDir.replace('x-pack/', '')}/**`);
// copy source files
await asyncPipeline(
vfs.src(
[
'LICENSE.txt',
'NOTICE.txt',
'package.json',
'yarn.lock',
'tsconfig.json',
'index.js',
'.i18nrc.json',
'plugins/**/*',
'typings/**/*',
],
{
cwd: XPACK_DIR,
base: XPACK_DIR,
buffer: true,
nodir: true,
ignore: [
'**/*.{md,mdx,asciidoc}',
'**/jest.config.js',
'**/jest.config.dev.js',
'**/jest_setup.js',
'**/jest.integration.config.js',
'**/*.stories.js',
'**/*.{test,test.mocks,mock,mocks}.*',
'**/*.d.ts',
'**/node_modules/**',
'**/public/**/*.{js,ts,tsx,json,scss}',
'**/{test,__tests__,__mocks__,__snapshots__,__fixtures__,__jest__,cypress,fixtures}/**',
'plugins/*/target/**',
'plugins/canvas/shareable_runtime/test/**',
'plugins/screenshotting/chromium/**',
'plugins/telemetry_collection_xpack/schema/**', // Skip telemetry schemas
'plugins/apm/ftr_e2e/**',
'plugins/apm/scripts/**',
'plugins/lists/server/scripts/**',
...xpackBazelPackages,
],
allowEmpty: true,
}
),
vfs.dest(PLUGIN_BUILD_DIR)
);
}
export const buildTask = gulp.series(cleanBuildTask, copySource);