-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Bazel for Kibana builds #69706
Comments
Pinging @elastic/kibana-operations (Team:Operations) |
Every detail written below intends to describe and make public all the progress we have made in our bazel exploration so far. Where are we and our current assumptionsWe have been developing a POC in order to investigate and learn about bazel as well as understand how could we benefit from adding it to our stack of tools. We realised that one of the areas we could change and use as a first step in our future bazel integration would be our local
Pending detailsThe following items will describe topics where some more thought or at least an agreement under the current solution is still needed in order to move them into next steps Redesign pre-commit hookThe pre-commit hook as is presents now a problem on Possible solutions: 1 - Follow the elasticsearch approach and give the developers the option to use or not the pre-commit hook. In our case that will be achieved only by removing the pre-commit hook from being run during the bootstrap as it can be already manually registered by 2 - I'm not 100% certain we can do that but it seems likely we can check the ability to write a repository rule to be called in the WORKSPACE file at the loading phase of bazel just like PackagesCurrently for the packages build with bazel I've setup bazel rules to mimic the production targets plus Problem 1:Will we want to keep supporting development and production builds? In case we want we could use the following (please be aware that if we want to have 2 different targets for packages both should be built on CI in order to update the remote cache so both the CI and the developers could benefit from successfull cache hits): Problem 1 possible solutions:1 - Keep the following approach described above which is about only generate one build type (prod one) plus 2 - Develop two set of rules (some intermediate targets could be used I think) and expose a two top level targets 3 - Use a bazel build flag Problem 2:Right now if a local kbn package with a build step also requires it to be published into the external npm repository it would cause problems. During the build or the workspace setup bazel will generate BUILD files for the node_modules. We are linking kbn packages in the package.json in order to keep the legacy build system working and as such BUILD files will be generated for local kbn packages (acting as node_modules) for their current contents. In the cases where we only reference those kbn packages inside the bazel build we can solve the problem by using the packages Problem 2 possible solutions:1 - We can re-implement the way bazel rules for node_js are generating the build files for node_modules as it can be solved if we create a symlink for the package source BUILD.bazel on the npm workspace instead of generating a file. I've validated that potential solution with the bazel team and it seems promising and doable. If we agree that is a future requirement for us we can move that into next steps and go ahead and implement that feature for bazel. Remote cacheRemote cache is one of the most benefits we can get once we start using bazel to build our project. Currently on my POC I've set up a google cloud storage bucket and integrated it. My idea around it is that our CI will build caches at every merge on tracked branches so other CI builds or the development team can all benefit from them. Those are my findings so far: Findings:
Problem 1:The cache mechanism generates a different actions output tree for different platforms or rule sets (for example if we are using dev and production builds according the situation). Problem 2:Node native modules generates non hermetic outputs if it generates/compiles the Problem 1 possible solutions:1 - We should generate caches on CI for every platform we want to use them (windows, linux and macOS) and then inside each platform for every different rule set we have, if any (dev, prod for example). I think I very good idea is to use CircleCI to generate those caches for us while we keep going with the other CI tasks. Problem 2 possible solutions:1 - The most problematic native module for now was Bazel Kibana IntegrationCurrently I have envisioned Problem 1:From that minimal required integration how will we want to expose bazel in the future? Problem 1 possible solutions:1- Keep integrating underlying bazel commands on 2 - Give full control of bazel to devs because they will be able to just call Webpack and Babel under BazelCurrently webpack and babel doesn't offer a proper integration under bazel with worker mode to persist some state and speed up incremental builds. While I don't think for babel is not a big problem because we are only using it in a couple of packages, for webpack the whole story could be different. Problem 1:Webpack doesn't have a worker implementation under bazel yet Problem 1 possible solutions:1 - Implementing that feature on bazel (it would take some time but is definitely possible I think) 2 - Try to build plugins with rollup instead which already has worker mode integration under bazel? Next stepsSingle package.jsonI think that is the only next step we can start thinking right now about its design in order to go ahead and make it a reality. I believe we would want to have it in the future, with or without bazel. The following is a replication of what can be found on: #76412 DesignThe proposal is to use a single top level package.json (in the kibana folder) to manage all the dependencies we need in the workspace. Sub-directories package.json will still be found from now in order to keep defining and informing boundaries around plugins and packages from the core and also to allow to run specific npm scripts. In the future those sub directories package.json could maybe be removed and replaced with BUILD.bazel files which can both be used to inform boundaries and also to define nodejs scripts to be run with bazel instead of npm. Benefits
Cons
Steps
|
All left my feedback and favourite solutions for each problem mentioned above. Redesign pre-commit hookSolution 1 at the beginning and re-evaluate later about Solution 2 PackagesProblem 1 -> Solution 1 as I don't think the changes on those are too frequently. We can implement solution 2 later if we need it. Remote CacheProblem 1 -> I believe we should use CircleCI to build the caches. To begin with, and according to my favourite solution to Packages problem 1, Bazel Kibana IntegrationProblem 1 -> I will advocate for solution 2: a minimal required integration with Webpack and Babel under BazelProblem 1 -> I think Solution 2 is only worth it in case we can do it without problems. However due to our advanced bundling usage I don't think it would be easy enough or even possible. I think we should go for Solution 1. Single package.jsonLet's do it! |
@elastic/kibana-operations at what stage you are going to add support for functional tests running from a plugin Bazel package? #92758 (comment) |
Closing as this issue is no longer providing value for tracking the project. |
We are planning to slowly introduce and using Bazel as our main build tool.
That issues summarises the steps we plan to take during the process.
Phase 1 (COMPLETED) #79757 #92220
Goals
packages/**
using Bazelpackages/**
with subsequent CI builds and local developer installationsExpected Benefits
packages/**
: reproducible and correct builds that only rebuilds when the inputs changesRough Planned Timeline
We are planning to land the phase 1 between
7.13
-7.14
Steps
fsevents
native module chore(NA): add resolution for chokidar to prevent [email protected] #85171kbn bootstrap
chore(NA): bazel machinery installation on kbn bootstrap #89469, chore(NA): introduce new yarn kbn reset command to support bazel workflow #89597, chore(NA): support bazel and kbn packages in parallel on kbn pm and on distributable build scripts #89961, chore(NA): build bazel projects all at once in the distributable build process #90328, chore(NA): add safe guard to remove bazelisk from yarn global at bootstrap #90538, chore(NA): assure bazel bin is available on kbn clean and reset commands #91406, chore(NA): stop grouping bazel out symlink folders #96066, chore(NA): upgrade bazel rules nodejs to v3.2.3 #95413, chore(NA): enable preserve symlinks for ts without breaking packages development #95433, chore(NA): @kbn/pm new commands to support development on Bazel packages #96465, chore(NA): upgrades iBazel to v0.15.10 #97489packages/**
with bazel chore(NA): moving @elastic/datemath into bazel #94665, fix(NA): support inspect flags on ensure_node_preserve_symlinks script #95344, chore(NA): moving @kbn/apm-utils into bazel #96227, chore(NA): moving @kbn/config-schema into bazel #96273, chore(NA): moving @kbn/tinymath into bazel #97022, chore(NA): moving @kbn/babel-preset into bazel #97271, chore(NA): chore(NA): moving @kbn/std into bazel #97771, chore(NA): chore(NA): moving @kbn/utils into bazel #97833, chore(NA): moving @elastic/safer-lodash-set into bazel #98187, chore(NA): moving @kbn/expect into bazel #98322, chore(NA): moving @kbn/apm-config-loader into bazel #98323, chore(NA): moving @kbn/dev-utils into bazel #98496, chore(NA): moving @kbn/logging into bazel #98564, chore(NA): moving @elastic/eslint-config-kibana into bazel #98648, chore(NA): moving @kbn/babel-code-parser into bazel #97675, chore(NA): moving @kbn/utility-types into bazel #97151, fix(NA): correct source root path on @kbn/config-schema #98788, chore(NA): moving @kbn/eslint-import-resolver-kibana into bazel #98798, [packages] Move @kbn/legacy-logging to Bazel #98810, chore(NA): moving @kbn/analytics into bazel #98917, chore(NA): moving @kbn/config into bazel #99199, [packages] Move @kbn/ace to Bazel #99129, chore(NA): moving @kbn/es into bazel #99371, chore(NA): moving @kbn/plugin-generator into bazel #99646, [packages] Move @kbn/telemetry-tools to Bazel #99726, chore(NA): moving @kbn/docs-utils into bazel #100051, chore(NA): moving @kbn/server-http-tools into bazel #100153, chore(NA): moving @kbn/monaco into bazel #100709, chore(NA): moving @kbn/io-ts-utils into bazel #100810, [packages] Move @kbn/interpreter to Bazel #101089, chore(NA): moving @kbn/rule-data-utils into bazel #101290, chore(NA): moving @kbn/server-route-repository into bazel #101484, chore(NA): moving @kbn/ui-shared-deps into bazel #101669, chore(NA): moving @kbn/storybook into bazel #102731, chore(NA): moving @kbn/ui-framework into bazel #102908, chore(NA): moving @kbn/optimizer into bazel #102965, chore(NA): moving @kbn/cli-dev-mode into bazel #103067, chore(NA): moving @kbn/plugin-helpers into bazel #103181, [packages] Migrate @kbn/test to Bazel #103122, chore(NA): moving @kbn/spec-to-console into bazel #103470, chore(NA): moving @kbn/test-subj-selector into bazel #103562, chore(NA): moving @kbn/es-archiver into bazel #103770Phase 2 (ON GOING) #104519
Rough Planned Timeline
We are planning to land the phase 2 between
8.0
-8.1
Goals
Expected Benefits
Steps
Phase 3
Goals
babel/register
can be completely removed since server-side code will be pre-built.Phase 4
Goals
The text was updated successfully, but these errors were encountered: