Skip to content

Commit

Permalink
chore(NA): @kbn/pm new commands to support development on Bazel packa…
Browse files Browse the repository at this point in the history
…ges (#96465)

* chore(NA): add warnings both to run and watch commands about Bazel built packages

* chore(NA): add new commands to build and watch bazel packages

* docs(NA): add documentation about how to deal with bazel packages

* chore(NA): addressed majority of the feedback received except for improved error logging

* chore(NA): disable ibazel info notification.

* chore(NA): remove iBazel notification

* chore(NA): remove iBazel notification - kbn pm dist

* chore(NA): move show_results option to kbn-pm only

* chore(NA): patch build bazel command to include packages target list

* chore(NA): add pretty logging for elastic-datemath

* chore(NA): remove double error output from commands ran with Bazel

* fix(NA): include simple error message to preserve subprocess failure state

* docs(NA): missing docs about how to independentely watch non bazel packages

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mistic and kibanamachine authored Apr 13, 2021
1 parent c218ba8 commit e3f5249
Show file tree
Hide file tree
Showing 13 changed files with 1,184 additions and 921 deletions.
14 changes: 9 additions & 5 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
build --experimental_guard_against_concurrent_changes
run --experimental_guard_against_concurrent_changes
test --experimental_guard_against_concurrent_changes
query --experimental_guard_against_concurrent_changes

## Cache action outputs on disk so they persist across output_base and bazel shutdown (eg. changing branches)
build --disk_cache=~/.bazel-cache/disk-cache
common --disk_cache=~/.bazel-cache/disk-cache

## Bazel repo cache settings
build --repository_cache=~/.bazel-cache/repository-cache
common --repository_cache=~/.bazel-cache/repository-cache

# Bazel will create symlinks from the workspace directory to output artifacts.
# Build results will be placed in a directory called "bazel-bin"
Expand All @@ -35,13 +36,16 @@ build --experimental_inprocess_symlink_creation
# Incompatible flags to run with
build --incompatible_no_implicit_file_export
build --incompatible_restrict_string_escapes
query --incompatible_no_implicit_file_export
query --incompatible_restrict_string_escapes

# Log configs
## different from default
common --color=yes
build --show_task_finish
build --noshow_progress
common --noshow_progress
common --show_task_finish
build --noshow_loading_progress
query --noshow_loading_progress
build --show_result=0

# Specifies desired output mode for running tests.
Expand Down Expand Up @@ -82,7 +86,7 @@ test:debug --test_output=streamed --test_strategy=exclusive --test_timeout=9999
run:debug --define=VERBOSE_LOGS=1 -- --node_options=--inspect-brk
# The following option will change the build output of certain rules such as terser and may not be desirable in all cases
# It will also output both the repo cache and action cache to a folder inside the repo
build:debug --compilation_mode=dbg --show_result=1
build:debug --compilation_mode=dbg --show_result=0 --noshow_loading_progress --noshow_progress --show_task_finish

# Turn off legacy external runfiles
# This prevents accidentally depending on this feature, which Bazel will remove.
Expand Down
3 changes: 0 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ node_repositories(
# NOTE: FORCE_COLOR env var forces colors on non tty mode
yarn_install(
name = "npm",
environment = {
"FORCE_COLOR": "True",
},
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
data = [
Expand Down
5 changes: 4 additions & 1 deletion docs/developer/getting-started/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ yarn kbn bootstrap --force-install

(You can also run `yarn kbn` to see the other available commands. For
more info about this tool, see
{kib-repo}tree/{branch}/packages/kbn-pm[{kib-repo}tree/{branch}/packages/kbn-pm].)
{kib-repo}tree/{branch}/packages/kbn-pm[{kib-repo}tree/{branch}/packages/kbn-pm]. If you want more
information about how to actively develop over packages please read <<monorepo-packages>>)

When switching branches which use different versions of npm packages you
may need to run:
Expand Down Expand Up @@ -169,3 +170,5 @@ include::debugging.asciidoc[leveloffset=+1]
include::building-kibana.asciidoc[leveloffset=+1]

include::development-plugin-resources.asciidoc[leveloffset=+1]

include::monorepo-packages.asciidoc[leveloffset=+1]
66 changes: 66 additions & 0 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[[monorepo-packages]]
== {kib} Monorepo Packages

Currently {kib} works as a monorepo composed by a core, plugins and packages.
The latest are located in a folder called `packages` and are pieces of software that
composes a set of features that can be isolated and reused across the entire repository.
They are also supposed to be able to imported just like any other `node_module`.

Previously we relied solely on `@kbn/pm` to manage the development tools of those packages, but we are
now in the middle of migrating those responsibilities into Bazel. Every package already migrated
will contain in its root folder a `BUILD.bazel` file and other `build` and `watching` strategies should be used.

Remember that any time you need to make sure the monorepo is ready to be used just run:

[source,bash]
----
yarn kbn bootstrap
----

[discrete]
=== Building Non Bazel Packages

Non Bazel packages can be built independently with

[source,bash]
----
yarn kbn run build -i PACKAGE_NAME
----

[discrete]
=== Watching Non Bazel Packages

Non Bazel packages can be watched independently with

[source,bash]
----
yarn kbn watch -i PACKAGE_NAME
----

[discrete]
=== Building Bazel Packages

Bazel packages are built as a whole for now. You can use:

[source,bash]
----
yarn kbn build-bazel
----

[discrete]
=== Watching Bazel Packages

Bazel packages are watched as a whole for now. You can use:

[source,bash]
----
yarn kbn watch-bazel
----


[discrete]
=== List of Already Migrated Packages to Bazel

- @elastic/datemath


1 change: 1 addition & 0 deletions packages/elastic-datemath/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ts_config(

ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
Expand Down
Loading

0 comments on commit e3f5249

Please sign in to comment.