mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
Add conditional switching between EUI releases (#219818)
## Summary This PR simplifies the weekly EUI upgrade and backport process by conditionally aliasing `@elastic/eui` in shared deps webpack configurations. # Backstory The EUI team (@elastic/eui-team) is responsible for keeping EUI up to date in Kibana. Historically, this has been a relatively straightforward (yet time-consuming) process, however, due to `8.x` backport complexities caused by it using a different theme, it has become way more demanding on everybody involved. EUI is released on weekly basis. Each week, we release official EUI versions tagged `latest` in npmjs and get a PR open that updates the package in kibana `main`. Our upgrade PRs tend to require anywhere between 2 and 25 codeowner reviews due to the number of snapshots we need to update while working on the EUI upgrade PRs. These snapshot changes are 99% of the time harmless, yet it still takes 2+ full workdays to ping teams and get all reviews necessary to get the PR merged. Generally speaking, we aim to have the upgrade PR open on Monday and merged by Friday. ## The issue with `8.x` backports Kibana 8.x uses the Amsterdam theme instead of Borealis, which is used in Kibana 9.0 and up. To keep 8.x up to date, for each official EUI release we prepare another special Kibana 8.x only release of EUI (e.g., `101.2.0-amsterdam.0`). These special releases have the theme hardcoded to Amsterdam at compile-time to avoid any initial theme errors Kibana could otherwise experience. This is done primarily because some areas in Kibana read EUI theme values outside of React components, and we have no stable way to determine what the active theme is since there's no context information. This is where we need to fall back to Amsterdam in 8.x and Borealis in 9.x. **Since there are two different EUI versions - one for Kibana `main` and 9.0, and another for 8.x branches, we cannot use the automated backports feature**. Instead, we open two separate PRs and configure backport labels accordingly. Having two PRs is far from ideal since codeowners need to review our changes twice, and we're more likely to make mistakes. # Our proposal Following the recently introduced React version switching logic, we want to conditionally switch between two `@elastic/eui` releases depending on the kibana branch/version while keeping automated backports possible. To achieve that, I added a dependency alias `@elastic/eui-amsterdam` that points to the Amsterdam EUI release and configured `resolve.alias` in shared deps to resolve the correct dependency based on the optional `EUI_AMSTERDAM` environment variable. When this change is merged to `main` and backported to `9.0` and `8.19`, I'll open a follow-up PR to the `8.19` branch updating the default value of `EUI_AMSTERDAM` to `"true"`. This should result in no conflicts and be easy to follow. Since 8.19 [uses the Amsterdam release of `@elastic/eui`](https://github.com/elastic/kibana/blob/8.19/package.json#L126) (e.g., `101.2.0-amsterdam.0`), there's no risk backporting this PR as-is without `EUI_AMSTERDAM` configured beforehand. ## What does it change? With this setup, we'll be able to update versions of `@elastic/eui` and `@elastic/eui-amsterdam` at the same time in a single PR and make use of automated kibana backports. There will be only one set of changes to review by codeowners, and if there are any failing tests when backporting to `8.19` due to, for example, changed color values, we can follow the regular kibana procedures and fix them right in the created backport PR. It'll simplify our workflow quite drastically while keeping the same level of quality. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b08057dae4
commit
ac3fc27a53
11 changed files with 103 additions and 12 deletions
|
@ -55,6 +55,7 @@ export const command = {
|
|||
const validate = args.getBooleanValue('validate') ?? true;
|
||||
const quiet = args.getBooleanValue('quiet') ?? false;
|
||||
const reactVersion = process.env.REACT_18 ? '18' : '17';
|
||||
const euiAmsterdam = process.env.EUI_AMSTERDAM === 'true';
|
||||
const vscodeConfig =
|
||||
args.getBooleanValue('vscode') ?? (process.env.KBN_BOOTSTRAP_NO_VSCODE ? false : true);
|
||||
|
||||
|
@ -115,7 +116,7 @@ export const command = {
|
|||
}
|
||||
|
||||
await time('pre-build webpack bundles for packages', async () => {
|
||||
await Bazel.buildWebpackBundles(log, { offline, quiet, reactVersion });
|
||||
await Bazel.buildWebpackBundles(log, { offline, quiet, reactVersion, euiAmsterdam });
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
|
|
|
@ -28,6 +28,7 @@ export const command = {
|
|||
await Bazel.watch(log, {
|
||||
offline: args.getBooleanValue('offline') ?? true,
|
||||
reactVersion: process.env.REACT_18 ? '18' : '17',
|
||||
euiAmsterdam: process.env.EUI_AMSTERDAM === 'true',
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ function throwBazelError(log, name, code, output) {
|
|||
/**
|
||||
* @param {import('./log.mjs').Log} log
|
||||
* @param {string[]} inputArgs
|
||||
* @param {{ quiet?: boolean; offline?: boolean, reactVersion?: string, env?: Record<string, string> } | undefined} opts
|
||||
* @param {{ quiet?: boolean; offline?: boolean, reactVersion?: string, euiAmsterdam?: boolean, env?: Record<string, string> } | undefined} opts
|
||||
*/
|
||||
async function runBazel(log, inputArgs, opts = undefined) {
|
||||
const bazel = (await getBazelRunner()).runBazel;
|
||||
|
@ -66,11 +66,16 @@ async function runBazel(log, inputArgs, opts = undefined) {
|
|||
const args = [
|
||||
...inputArgs,
|
||||
`--define=REACT_18=${opts?.reactVersion === '18' ? 'true' : 'false'}`,
|
||||
`--define=EUI_AMSTERDAM=${opts?.euiAmsterdam ? 'true' : 'false'}`,
|
||||
...(opts?.offline ? ['--config=offline'] : []),
|
||||
];
|
||||
log.debug(`> bazel ${args.join(' ')}`);
|
||||
await bazel(args, {
|
||||
env: { ...opts?.env, REACT_18: opts?.reactVersion === '18' ? 'true' : 'false' },
|
||||
env: {
|
||||
...opts?.env,
|
||||
REACT_18: opts?.reactVersion === '18' ? 'true' : 'false',
|
||||
EUI_AMSTERDAM: opts?.euiAmsterdam ? 'true' : 'false',
|
||||
},
|
||||
cwd: REPO_ROOT,
|
||||
quiet: opts?.quiet,
|
||||
logPrefix: Color.info('[bazel]'),
|
||||
|
@ -83,7 +88,7 @@ async function runBazel(log, inputArgs, opts = undefined) {
|
|||
/**
|
||||
*
|
||||
* @param {import('./log.mjs').Log} log
|
||||
* @param {{ offline: boolean, reactVersion?: string } | undefined} opts
|
||||
* @param {{ offline: boolean, reactVersion?: string, euiAmsterdam?: boolean } | undefined} opts
|
||||
*/
|
||||
export async function watch(log, opts = undefined) {
|
||||
const ibazel = (await getBazelRunner()).runIBazel;
|
||||
|
@ -98,11 +103,16 @@ export async function watch(log, opts = undefined) {
|
|||
'--show_result=1',
|
||||
...(opts?.offline ? ['--config=offline'] : []),
|
||||
`--define=REACT_18=${opts?.reactVersion === '18' ? 'true' : 'false'}`,
|
||||
`--define=EUI_AMSTERDAM=${opts?.euiAmsterdam ? 'true' : 'false'}`,
|
||||
];
|
||||
log.debug(`> ibazel ${args.join(' ')}`);
|
||||
await ibazel(args, {
|
||||
cwd: REPO_ROOT,
|
||||
env: { ...process.env, REACT_18: opts?.reactVersion === '18' ? 'true' : 'false' },
|
||||
env: {
|
||||
...process.env,
|
||||
REACT_18: opts?.reactVersion === '18' ? 'true' : 'false',
|
||||
EUI_AMSTERDAM: opts?.euiAmsterdam ? 'true' : 'false',
|
||||
},
|
||||
logPrefix: Color.info('[ibazel]'),
|
||||
onErrorExit(code, output) {
|
||||
throwBazelError(log, 'ibazel', code, output);
|
||||
|
@ -167,13 +177,14 @@ export async function installYarnDeps(log, opts = undefined) {
|
|||
|
||||
/**
|
||||
* @param {import('./log.mjs').Log} log
|
||||
* @param {{ offline?: boolean, quiet?: boolean, reactVersion?: string } | undefined} opts
|
||||
* @param {{ offline?: boolean, quiet?: boolean, reactVersion?: string, euiAmsterdam?: boolean } | undefined} opts
|
||||
*/
|
||||
export async function buildWebpackBundles(log, opts = undefined) {
|
||||
await runBazel(log, ['build', ...BAZEL_TARGETS, '--show_result=1'], {
|
||||
offline: opts?.offline,
|
||||
quiet: opts?.quiet,
|
||||
reactVersion: opts?.reactVersion,
|
||||
euiAmsterdam: opts?.euiAmsterdam,
|
||||
});
|
||||
|
||||
log.success('shared bundles built');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue