Skip to content

Commit

Permalink
[build] Add task skips intended for partial builds (#92679)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jbudz and kibanamachine authored Mar 3, 2021
1 parent 83023ea commit 294db10
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 36 deletions.
21 changes: 21 additions & 0 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ it('build default and oss dist for current platform, without packages, by defaul
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": false,
"versionQualifier": "",
Expand All @@ -57,8 +60,11 @@ it('builds packages if --all-platforms is passed', () => {
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
Expand All @@ -81,8 +87,11 @@ it('limits packages if --rpm passed with --all-platforms', () => {
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
Expand All @@ -105,8 +114,11 @@ it('limits packages if --deb passed with --all-platforms', () => {
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
Expand All @@ -130,8 +142,11 @@ it('limits packages if --docker passed with --all-platforms', () => {
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
Expand Down Expand Up @@ -162,8 +177,11 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": false,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
Expand All @@ -187,8 +205,11 @@ it('limits packages if --all-platforms passed with --skip-docker-centos', () =>
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": true,
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"initialize": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
Expand Down
6 changes: 6 additions & 0 deletions src/dev/build/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export function readCliArgs(argv: string[]) {
'oss',
'no-oss',
'skip-archives',
'skip-initialize',
'skip-generic-folders',
'skip-platform-folders',
'skip-os-packages',
'rpm',
'deb',
Expand Down Expand Up @@ -93,7 +96,10 @@ export function readCliArgs(argv: string[]) {
versionQualifier: flags['version-qualifier'],
buildOssDist: flags.oss !== false,
buildDefaultDist: !flags.oss,
initialize: !Boolean(flags['skip-initialize']),
downloadFreshNode: !Boolean(flags['skip-node-download']),
createGenericFolders: !Boolean(flags['skip-generic-folders']),
createPlatformFolders: !Boolean(flags['skip-platform-folders']),
createArchives: !Boolean(flags['skip-archives']),
createRpmPackage: isOsPackageDesired('rpm'),
createDebPackage: isOsPackageDesired('deb'),
Expand Down
69 changes: 40 additions & 29 deletions src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface BuildOptions {
buildOssDist: boolean;
buildDefaultDist: boolean;
downloadFreshNode: boolean;
initialize: boolean;
createGenericFolders: boolean;
createPlatformFolders: boolean;
createArchives: boolean;
createRpmPackage: boolean;
createDebPackage: boolean;
Expand All @@ -41,45 +44,53 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
/**
* verify, reset, and initialize the build environment
*/
await run(Tasks.VerifyEnv);
await run(Tasks.Clean);
await run(options.downloadFreshNode ? Tasks.DownloadNodeBuilds : Tasks.VerifyExistingNodeBuilds);
await run(Tasks.ExtractNodeBuilds);
if (options.initialize) {
await run(Tasks.VerifyEnv);
await run(Tasks.Clean);
await run(
options.downloadFreshNode ? Tasks.DownloadNodeBuilds : Tasks.VerifyExistingNodeBuilds
);
await run(Tasks.ExtractNodeBuilds);
}

/**
* run platform-generic build tasks
*/
await run(Tasks.CopySource);
await run(Tasks.CopyBinScripts);
await run(Tasks.ReplaceFavicon);
await run(Tasks.CreateEmptyDirsAndFiles);
await run(Tasks.CreateReadme);
await run(Tasks.BuildBazelPackages);
await run(Tasks.BuildPackages);
await run(Tasks.BuildKibanaPlatformPlugins);
await run(Tasks.TranspileBabel);
await run(Tasks.CreatePackageJson);
await run(Tasks.InstallDependencies);
await run(Tasks.CleanPackages);
await run(Tasks.CreateNoticeFile);
await run(Tasks.UpdateLicenseFile);
await run(Tasks.RemovePackageJsonDeps);
await run(Tasks.CleanTypescript);
await run(Tasks.CleanExtraFilesFromModules);
await run(Tasks.CleanEmptyFolders);
if (options.createGenericFolders) {
await run(Tasks.CopySource);
await run(Tasks.CopyBinScripts);
await run(Tasks.ReplaceFavicon);
await run(Tasks.CreateEmptyDirsAndFiles);
await run(Tasks.CreateReadme);
await run(Tasks.BuildBazelPackages);
await run(Tasks.BuildPackages);
await run(Tasks.BuildKibanaPlatformPlugins);
await run(Tasks.TranspileBabel);
await run(Tasks.CreatePackageJson);
await run(Tasks.InstallDependencies);
await run(Tasks.CleanPackages);
await run(Tasks.CreateNoticeFile);
await run(Tasks.UpdateLicenseFile);
await run(Tasks.RemovePackageJsonDeps);
await run(Tasks.CleanTypescript);
await run(Tasks.CleanExtraFilesFromModules);
await run(Tasks.CleanEmptyFolders);
}

/**
* copy generic build outputs into platform-specific build
* directories and perform platform/architecture-specific steps
*/
await run(Tasks.CreateArchivesSources);
await run(Tasks.PatchNativeModules);
await run(Tasks.InstallChromium);
await run(Tasks.CleanExtraBinScripts);
await run(Tasks.CleanNodeBuilds);
if (options.createPlatformFolders) {
await run(Tasks.CreateArchivesSources);
await run(Tasks.PatchNativeModules);
await run(Tasks.InstallChromium);
await run(Tasks.CleanExtraBinScripts);
await run(Tasks.CleanNodeBuilds);

await run(Tasks.PathLength);
await run(Tasks.UuidVerification);
await run(Tasks.PathLength);
await run(Tasks.UuidVerification);
}

/**
* package platform-specific builds into archives
Expand Down
18 changes: 11 additions & 7 deletions src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ export async function runDockerGenerator(
revision: config.getBuildSha(),
};

type HostArchitectureToDocker = Record<string, string>;
const hostTarget: HostArchitectureToDocker = {
x64: 'x64',
arm64: 'aarch64',
};
const buildArchitectureSupported = hostTarget[process.arch] === flags.architecture;
if (flags.architecture && !buildArchitectureSupported) {
return;
}

// Verify if we have the needed kibana target in order
// to build the kibana docker image.
// Also create the docker build target folder
Expand Down Expand Up @@ -132,13 +142,7 @@ export async function runDockerGenerator(
await chmodAsync(`${resolve(dockerBuildDir, 'build_docker.sh')}`, '755');

// Only build images on native targets
type HostArchitectureToDocker = Record<string, string>;
const hostTarget: HostArchitectureToDocker = {
x64: 'x64',
arm64: 'aarch64',
};
const buildImage = hostTarget[process.arch] === flags.architecture && flags.image;
if (buildImage) {
if (flags.image) {
await exec(log, `./build_docker.sh`, [], {
cwd: dockerBuildDir,
level: 'info',
Expand Down

0 comments on commit 294db10

Please sign in to comment.