[build] Add task to build example plugins (#104194) (#106903)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Jonathan Budzenski <jon@budzenski.me>
This commit is contained in:
Kibana Machine 2021-07-27 18:28:14 -04:00 committed by GitHub
parent a361ce2e85
commit ce3eec734f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 2 deletions

3
.gitignore vendored
View file

@ -19,6 +19,9 @@ target
*.iml
*.log
# Ignore example plugin builds
/examples/*/build
# Ignore certain functional test runner artifacts
/test/*/failure_debug
/test/*/screenshots/diff

View file

@ -4,7 +4,7 @@
"kibanaVersion": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["embeddable", "embeddableExamples", "dashboard", "developerExamples"],
"requiredPlugins": ["embeddable", "embeddableExamples", "dashboard", "developerExamples", "kibanaReact"],
"optionalPlugins": [],
"requiredBundles": ["esUiShared"]
}

View file

@ -4,6 +4,6 @@
"kibanaVersion": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["uiActions", "inspector", "embeddable", "embeddableExamples", "developerExamples"],
"requiredPlugins": ["uiActions", "inspector", "embeddable", "embeddableExamples", "developerExamples", "dashboard", "kibanaReact", "savedObjects"],
"optionalPlugins": []
}

View file

@ -31,6 +31,7 @@ it('build default and oss dist for current platform, without packages, by defaul
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -56,6 +57,7 @@ it('builds packages if --all-platforms is passed', () => {
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
@ -81,6 +83,7 @@ it('limits packages if --rpm passed with --all-platforms', () => {
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
@ -106,6 +109,7 @@ it('limits packages if --deb passed with --all-platforms', () => {
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -132,6 +136,7 @@ it('limits packages if --docker passed with --all-platforms', () => {
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -165,6 +170,7 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -191,6 +197,7 @@ it('limits packages if --all-platforms passed with --skip-docker-centos', () =>
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": true,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,

View file

@ -31,6 +31,7 @@ export function readCliArgs(argv: string[]) {
'verbose',
'debug',
'all-platforms',
'example-plugins',
'verbose',
'quiet',
'silent',
@ -43,6 +44,7 @@ export function readCliArgs(argv: string[]) {
},
default: {
debug: true,
'example-plugins': false,
rpm: null,
deb: null,
'docker-images': null,
@ -96,6 +98,7 @@ export function readCliArgs(argv: string[]) {
createGenericFolders: !Boolean(flags['skip-generic-folders']),
createPlatformFolders: !Boolean(flags['skip-platform-folders']),
createArchives: !Boolean(flags['skip-archives']),
createExamplePlugins: Boolean(flags['example-plugins']),
createRpmPackage: isOsPackageDesired('rpm'),
createDebPackage: isOsPackageDesired('deb'),
createDockerCentOS:

View file

@ -25,6 +25,7 @@ export interface BuildOptions {
createDockerContexts: boolean;
versionQualifier: string | undefined;
targetAllPlatforms: boolean;
createExamplePlugins: boolean;
}
export async function buildDistributables(log: ToolingLog, options: BuildOptions) {
@ -49,6 +50,13 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
await run(Tasks.ExtractNodeBuilds);
}
/**
* build example plugins
*/
if (options.createExamplePlugins) {
await run(Tasks.BuildKibanaExamplePlugins);
}
/**
* run platform-generic build tasks
*/

View file

@ -0,0 +1,47 @@
/*
* 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 { REPO_ROOT } from '@kbn/utils';
import { exec, mkdirp, copyAll, Task } from '../lib';
export const BuildKibanaExamplePlugins: Task = {
description: 'Building distributable versions of Kibana example plugins',
async run(config, log, build) {
const examplesDir = Path.resolve(REPO_ROOT, 'examples');
const args = [
'../../scripts/plugin_helpers',
'build',
`--kibana-version=${config.getBuildVersion()}`,
];
const folders = Fs.readdirSync(examplesDir, { withFileTypes: true })
.filter((f) => f.isDirectory())
.map((f) => Path.resolve(REPO_ROOT, 'examples', f.name));
for (const examplePlugin of folders) {
try {
Fs.accessSync(Path.join(examplePlugin, 'kibana.json'), Fs.constants.R_OK);
log.info(`Building ${examplePlugin}`);
await exec(log, 'node', args, {
cwd: examplePlugin,
level: 'info',
});
} catch (e) {
log.info(`Skipping ${examplePlugin}, no kibana.json`);
}
}
const pluginsDir = config.resolveFromTarget('example_plugins');
await mkdirp(pluginsDir);
await copyAll(examplesDir, pluginsDir, {
select: ['*/build/*.zip'],
});
},
};

View file

@ -8,6 +8,7 @@
export * from './bin';
export * from './build_kibana_platform_plugins';
export * from './build_kibana_example_plugins';
export * from './build_packages_task';
export * from './clean_tasks';
export * from './copy_source_task';