Skip to content

Commit

Permalink
[build] Remove OSS builds (#100577)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
jbudz and kibanamachine committed Jun 29, 2021
1 parent a2f9e94 commit b2d76a6
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 225 deletions.
4 changes: 2 additions & 2 deletions src/dev/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ node scripts/build --help
# build a release version
node scripts/build --release

# reuse already downloaded node executables, turn on debug logging, and only build the default distributable
node scripts/build --skip-node-download --debug --no-oss
# reuse already downloaded node executables, turn on debug logging
node scripts/build --skip-node-download --debug
```

# Fixing out of memory issues
Expand Down
7 changes: 0 additions & 7 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ it('build default and oss dist for current platform, without packages, by defaul
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": false,
Expand All @@ -54,7 +53,6 @@ it('builds packages if --all-platforms is passed', () => {
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": true,
Expand All @@ -81,7 +79,6 @@ it('limits packages if --rpm passed with --all-platforms', () => {
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": false,
Expand All @@ -108,7 +105,6 @@ it('limits packages if --deb passed with --all-platforms', () => {
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": false,
Expand Down Expand Up @@ -136,7 +132,6 @@ it('limits packages if --docker passed with --all-platforms', () => {
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": true,
Expand Down Expand Up @@ -171,7 +166,6 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": true,
Expand Down Expand Up @@ -199,7 +193,6 @@ it('limits packages if --all-platforms passed with --skip-docker-centos', () =>
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": false,
Expand Down
3 changes: 0 additions & 3 deletions src/dev/build/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export function readCliArgs(argv: string[]) {
const unknownFlags: string[] = [];
const flags = getopts(argv, {
boolean: [
'oss',
'no-oss',
'skip-archives',
'skip-initialize',
'skip-generic-folders',
Expand Down Expand Up @@ -94,7 +92,6 @@ export function readCliArgs(argv: string[]) {
const buildOptions: BuildOptions = {
isRelease: Boolean(flags.release),
versionQualifier: flags['version-qualifier'],
buildOssDist: flags.oss !== false,
buildDefaultDist: !flags.oss,
initialize: !Boolean(flags['skip-initialize']),
downloadFreshNode: !Boolean(flags['skip-node-download']),
Expand Down
2 changes: 0 additions & 2 deletions src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as Tasks from './tasks';

export interface BuildOptions {
isRelease: boolean;
buildOssDist: boolean;
buildDefaultDist: boolean;
downloadFreshNode: boolean;
initialize: boolean;
Expand All @@ -38,7 +37,6 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
config,
log,
buildDefaultDist: options.buildDefaultDist,
buildOssDist: options.buildOssDist,
});

/**
Expand Down
2 changes: 0 additions & 2 deletions src/dev/build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ if (showHelp) {
build the Kibana distributable
options:
--oss {dim Only produce the OSS distributable of Kibana}
--no-oss {dim Only produce the default distributable of Kibana}
--skip-archives {dim Don't produce tar/zip archives}
--skip-os-packages {dim Don't produce rpm/deb/docker packages}
--all-platforms {dim Produce archives for all platforms, not just this one}
Expand Down
39 changes: 11 additions & 28 deletions src/dev/build/lib/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,24 @@ beforeEach(() => {
jest.clearAllMocks();
});

const ossBuild = new Build(config, true);
const defaultBuild = new Build(config, false);

describe('#isOss()', () => {
it('returns true for oss', () => {
expect(ossBuild.isOss()).toBe(true);
});

it('returns false for default build', () => {
expect(defaultBuild.isOss()).toBe(false);
});
});
const defaultBuild = new Build(config);

describe('#getName()', () => {
it('returns kibana for default build', () => {
expect(defaultBuild.getName()).toBe('kibana');
});

it('returns kibana-oss for oss', () => {
expect(ossBuild.getName()).toBe('kibana-oss');
});
});

describe('#getLogTag()', () => {
it('returns string with build name in it', () => {
expect(defaultBuild.getLogTag()).toContain(defaultBuild.getName());
expect(ossBuild.getLogTag()).toContain(ossBuild.getName());
});
});

describe('#resolvePath()', () => {
it('uses passed config to resolve a path relative to the repo', () => {
expect(ossBuild.resolvePath('bar')).toMatchInlineSnapshot(
`<absolute path>/build/kibana-oss/bar`
expect(defaultBuild.resolvePath('bar')).toMatchInlineSnapshot(
`<absolute path>/build/kibana/bar`
);
});

Expand All @@ -89,28 +73,27 @@ describe('#resolvePath()', () => {

describe('#resolvePathForPlatform()', () => {
it('uses config.resolveFromRepo(), config.getBuildVersion(), and platform.getBuildName() to create path', () => {
expect(ossBuild.resolvePathForPlatform(linuxPlatform, 'foo', 'bar')).toMatchInlineSnapshot(
`<absolute path>/build/oss/kibana-8.0.0-linux-x86_64/foo/bar`
expect(defaultBuild.resolvePathForPlatform(linuxPlatform, 'foo', 'bar')).toMatchInlineSnapshot(
`<absolute path>/build/default/kibana-8.0.0-linux-x86_64/foo/bar`
);
});
});

describe('#getPlatformArchivePath()', () => {
it('creates correct path for different platforms', () => {
expect(ossBuild.getPlatformArchivePath(linuxPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-oss-8.0.0-linux-x86_64.tar.gz`
expect(defaultBuild.getPlatformArchivePath(linuxPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-8.0.0-linux-x86_64.tar.gz`
);
expect(ossBuild.getPlatformArchivePath(linuxArmPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-oss-8.0.0-linux-aarch64.tar.gz`
expect(defaultBuild.getPlatformArchivePath(linuxArmPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-8.0.0-linux-aarch64.tar.gz`
);
expect(ossBuild.getPlatformArchivePath(windowsPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-oss-8.0.0-windows-x86_64.zip`
expect(defaultBuild.getPlatformArchivePath(windowsPlatform)).toMatchInlineSnapshot(
`<absolute path>/target/kibana-8.0.0-windows-x86_64.zip`
);
});

describe('#getRootDirectory()', () => {
it('creates correct root directory name', () => {
expect(ossBuild.getRootDirectory()).toMatchInlineSnapshot(`"kibana-oss-8.0.0"`);
expect(defaultBuild.getRootDirectory()).toMatchInlineSnapshot(`"kibana-8.0.0"`);
});
});
Expand Down
12 changes: 4 additions & 8 deletions src/dev/build/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ import { Config } from './config';
import { Platform } from './platform';

export class Build {
private name = this.oss ? 'kibana-oss' : 'kibana';
private logTag = this.oss ? chalk`{magenta [kibana-oss]}` : chalk`{cyan [ kibana ]}`;
private name = 'kibana';
private logTag = chalk`{cyan [ kibana ]}`;

constructor(private config: Config, private oss: boolean) {}

isOss() {
return !!this.oss;
}
constructor(private config: Config) {}

resolvePath(...args: string[]) {
return this.config.resolveFromRepo('build', this.name, ...args);
Expand All @@ -28,7 +24,7 @@ export class Build {
resolvePathForPlatform(platform: Platform, ...args: string[]) {
return this.config.resolveFromRepo(
'build',
this.oss ? 'oss' : 'default',
'default',
`kibana-${this.config.getBuildVersion()}-${platform.getBuildName()}`,
...args
);
Expand Down
92 changes: 2 additions & 90 deletions src/dev/build/lib/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ beforeEach(() => {
jest.clearAllMocks();
});

const setup = async (opts: { buildDefaultDist: boolean; buildOssDist: boolean }) => {
const setup = async (opts: { buildDefaultDist: boolean }) => {
const config = await Config.create({
isRelease: true,
targetAllPlatforms: true,
Expand All @@ -61,48 +61,10 @@ const setup = async (opts: { buildDefaultDist: boolean; buildOssDist: boolean })
return { config, run };
};

describe('buildOssDist = true, buildDefaultDist = true', () => {
describe('default dist', () => {
it('runs global task once, passing config and log', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: true,
});

const mock = jest.fn();

await run({
global: true,
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenLastCalledWith(config, log, [expect.any(Build), expect.any(Build)]);
});

it('calls local tasks twice, passing each build', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: true,
});

const mock = jest.fn();

await run({
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(2);
expect(mock).toHaveBeenCalledWith(config, log, expect.any(Build));
});
});

describe('just default dist', () => {
it('runs global task once, passing config and log', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});

const mock = jest.fn();
Expand All @@ -120,49 +82,6 @@ describe('just default dist', () => {
it('calls local tasks once, passing the default build', async () => {
const { config, run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});

const mock = jest.fn();

await run({
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith(config, log, expect.any(Build));
const [args] = mock.mock.calls;
const [, , build] = args;
if (build.isOss()) {
throw new Error('expected build to be the default dist, not the oss dist');
}
});
});

describe('just oss dist', () => {
it('runs global task once, passing config and log', async () => {
const { config, run } = await setup({
buildDefaultDist: false,
buildOssDist: true,
});

const mock = jest.fn();

await run({
global: true,
description: 'foo',
run: mock,
});

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenLastCalledWith(config, log, [expect.any(Build)]);
});

it('calls local tasks once, passing the oss build', async () => {
const { config, run } = await setup({
buildDefaultDist: false,
buildOssDist: true,
});

const mock = jest.fn();
Expand All @@ -174,19 +93,13 @@ describe('just oss dist', () => {

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith(config, log, expect.any(Build));
const [args] = mock.mock.calls;
const [, , build] = args;
if (!build.isOss()) {
throw new Error('expected build to be the oss dist, not the default dist');
}
});
});

describe('task rejection', () => {
it('rejects, logs error, and marks error logged', async () => {
const { run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});

const error = new Error('FOO');
Expand Down Expand Up @@ -215,7 +128,6 @@ describe('task rejection', () => {
it('just rethrows errors that have already been logged', async () => {
const { run } = await setup({
buildDefaultDist: true,
buildOssDist: false,
});

const error = markErrorLogged(new Error('FOO'));
Expand Down
8 changes: 2 additions & 6 deletions src/dev/build/lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Config } from './config';
interface Options {
config: Config;
log: ToolingLog;
buildOssDist: boolean;
buildDefaultDist: boolean;
}

Expand All @@ -32,7 +31,7 @@ export interface Task {
run(config: Config, log: ToolingLog, build: Build): Promise<void>;
}

export function createRunner({ config, log, buildOssDist, buildDefaultDist }: Options) {
export function createRunner({ config, log, buildDefaultDist }: Options) {
async function execTask(desc: string, task: Task | GlobalTask, lastArg: any) {
log.info(desc);
log.indent(4);
Expand Down Expand Up @@ -64,10 +63,7 @@ export function createRunner({ config, log, buildOssDist, buildDefaultDist }: Op

const builds: Build[] = [];
if (buildDefaultDist) {
builds.push(new Build(config, false));
}
if (buildOssDist) {
builds.push(new Build(config, true));
builds.push(new Build(config));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/tasks/build_kibana_platform_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const BuildKibanaPlatformPlugins: Task = {
repoRoot: REPO_ROOT,
outputRoot: build.resolvePath(),
cache: false,
oss: build.isOss(),
oss: false,
examples: false,
watch: false,
dist: true,
Expand Down
Loading

0 comments on commit b2d76a6

Please sign in to comment.