[ci/build] Add label for building example plugins (#139720)

* [ci/build] Add label for building example plugins

* update snapshots

* remove plugins before tests

* fix

* fix again

* fix formatting
This commit is contained in:
Jonathan Budzenski 2022-09-29 16:18:19 -05:00 committed by GitHub
parent 0cfaff4deb
commit 7274c27218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 26 deletions

View file

@ -10,6 +10,7 @@ echo "--- Build Kibana Distribution"
BUILD_ARGS=""
is_pr_with_label "ci:build-all-platforms" && BUILD_ARGS="--all-platforms"
is_pr_with_label "ci:build-example-plugins" && BUILD_ARGS="$BUILD_ARGS --example-plugins"
is_pr_with_label "ci:build-docker-cross-compile" && BUILD_ARG="$BUILD_ARGS --docker-cross-compile"
is_pr_with_label "ci:build-os-packages" || BUILD_ARGS="$BUILD_ARGS --skip-os-packages"
is_pr_with_label "ci:build-canvas-shareable-runtime" || BUILD_ARGS="$BUILD_ARGS --skip-canvas-shareable-runtime"

View file

@ -15,6 +15,13 @@ if [[ ! -d "$KIBANA_BUILD_LOCATION/bin" ]]; then
mkdir -p "$KIBANA_BUILD_LOCATION"
tar -xzf kibana-default.tar.gz -C "$KIBANA_BUILD_LOCATION" --strip=1
if is_pr_with_label "ci:build-example-plugins"; then
# Testing against an example plugin distribution is not supported,
# mostly due to snapshot failures when testing UI element lists
rm -rf "$KIBANA_BUILD_LOCATION/plugins"
mkdir "$KIBANA_BUILD_LOCATION/plugins"
fi
cd "$KIBANA_DIR"
tar -xzf ../kibana-default-plugins.tar.gz

View file

@ -1,4 +1,2 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
COPY ./* /var/lib/example_plugins
RUN find /var/lib/example_plugins/ -type f -name '*.zip' | xargs -I % /usr/share/kibana/bin/kibana-plugin install 'file://%'

1
.gitignore vendored
View file

@ -25,6 +25,7 @@ __tmp__
# Ignore example plugin builds
/examples/*/build
/x-pack/examples/*/build
# Ignore certain functional test runner artifacts
/test/*/failure_debug

View file

@ -28,13 +28,13 @@ it('build default and oss dist for current platform, without packages, by defaul
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": false,
"createDockerCloud": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createDockerUbuntu": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -62,13 +62,13 @@ it('builds packages if --all-platforms is passed', () => {
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": true,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createDockerUbuntu": true,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
@ -96,13 +96,13 @@ it('limits packages if --rpm passed with --all-platforms', () => {
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": false,
"createDockerCloud": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createDockerUbuntu": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
@ -130,13 +130,13 @@ it('limits packages if --deb passed with --all-platforms', () => {
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": true,
"createDockerCloud": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createDockerUbuntu": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -165,13 +165,13 @@ it('limits packages if --docker passed with --all-platforms', () => {
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": false,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createDockerUbuntu": true,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -207,13 +207,13 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": false,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerUBI": false,
"createDockerUbuntu": true,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
@ -242,13 +242,13 @@ it('limits packages if --all-platforms passed with --skip-docker-ubuntu', () =>
Object {
"buildOptions": Object {
"buildCanvasShareableRuntime": true,
"buildExamplePlugins": false,
"createArchives": true,
"createDebPackage": true,
"createDockerCloud": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createDockerUbuntu": false,
"createExamplePlugins": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,

View file

@ -127,7 +127,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']),
buildExamplePlugins: Boolean(flags['example-plugins']),
createRpmPackage: isOsPackageDesired('rpm'),
createDebPackage: isOsPackageDesired('deb'),
createDockerUbuntu:

View file

@ -32,7 +32,7 @@ export interface BuildOptions {
createDockerContexts: boolean;
versionQualifier: string | undefined;
targetAllPlatforms: boolean;
createExamplePlugins: boolean;
buildExamplePlugins: boolean;
eprRegistry: 'production' | 'snapshot';
}
@ -58,13 +58,6 @@ 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
*/
@ -79,6 +72,9 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
await run(Tasks.BuildCanvasShareableRuntime);
}
await run(Tasks.BuildKibanaPlatformPlugins);
if (options.buildExamplePlugins) {
await run(Tasks.BuildKibanaExamplePlugins);
}
await run(Tasks.CreatePackageJson);
await run(Tasks.InstallDependencies);
await run(Tasks.GeneratePackagesOptimizedAssets);

View file

@ -9,14 +9,16 @@
import Path from 'path';
import Fs from 'fs';
import { REPO_ROOT } from '@kbn/utils';
import { exec, mkdirp, copyAll, Task } from '../lib';
import { exec, Task } from '../lib';
export const BuildKibanaExamplePlugins: Task = {
description: 'Building distributable versions of Kibana example plugins',
async run(config, log) {
async run(config, log, build) {
const pluginsDir = build.resolvePath('plugins');
const args = [
Path.resolve(REPO_ROOT, 'scripts/plugin_helpers'),
'build',
'--skip-archive',
`--kibana-version=${config.getBuildVersion()}`,
];
@ -42,15 +44,12 @@ export const BuildKibanaExamplePlugins: Task = {
cwd: examplePlugin,
level: 'info',
});
log.info('Copying build to distribution');
const pluginBuild = Path.resolve(examplePlugin, 'build', 'kibana');
Fs.cpSync(pluginBuild, pluginsDir, { recursive: true });
} catch (e) {
log.info(`Skipping ${examplePlugin}, no kibana.json`);
}
}
const pluginsDir = config.resolveFromTarget('example_plugins');
await mkdirp(pluginsDir);
await copyAll(REPO_ROOT, pluginsDir, {
select: ['examples/*/build/*.zip', 'x-pack/examples/*/build/*.zip'],
});
},
};