Skip to content

Commit

Permalink
Keep ccc libraries separated
Browse files Browse the repository at this point in the history
This package is a collection of (mostly) unrelated libraries.  Let's
reflect this in Bazel to simplify and clean the dependency tree.

This package will also certainly grow with time and pull an increasing
amount of dependencies.  Therefore, keeping the components minimal
should have a positive impact in the long run.  This will further
simplify our work when we decide to refactor (or remove) some of these
cross-cutting concerns.

Change-Id: I1265ca34e565f0c06fab8030eaee2f0c32fb5658
  • Loading branch information
Synss committed Jan 22, 2025
1 parent ed12f1e commit 6aa8237
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 24 deletions.
11 changes: 10 additions & 1 deletion cmk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,16 @@ CSE_PY = glob([
CMK_PACKAGES = [
"//packages/cmk-agent-based",
"//packages/cmk-agent-receiver",
"//packages/cmk-ccc",
"//packages/cmk-ccc:crash-reporting",
"//packages/cmk-ccc:daemon",
"//packages/cmk-ccc:debug",
"//packages/cmk-ccc:exceptions",
"//packages/cmk-ccc:i18n",
"//packages/cmk-ccc:plugin-registry",
"//packages/cmk-ccc:profile",
"//packages/cmk-ccc:site",
"//packages/cmk-ccc:store",
"//packages/cmk-ccc:version",
"//packages/cmk-crypto",
"//packages/cmk-events",
"//packages/cmk-graphing",
Expand Down
160 changes: 139 additions & 21 deletions packages/cmk-ccc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,135 @@ exports_files([
])

py_library(
# TODO(ml): Split into separate libs. This package is really
# a collection of more or less unrelated modules.
name = "cmk-ccc",
name = "_init",
srcs = ["cmk/ccc/__init__.py"],
imports = ["."],
)

py_library(
name = "crash-reporting",
srcs = ["cmk/ccc/crash_reporting.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
"_init",
"plugin-registry",
"store",
],
)

py_library(
name = "daemon",
srcs = ["cmk/ccc/daemon.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
"_init",
"exceptions",
"store",
],
)

py_library(
name = "debug",
srcs = ["cmk/ccc/debug.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = ["_init"],
)

py_library(
name = "exceptions",
srcs = ["cmk/ccc/exceptions.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = ["_init"],
)

py_library(
name = "i18n",
srcs = ["cmk/ccc/i18n.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = ["_init"],
)

py_library(
name = "plugin-registry",
srcs = ["cmk/ccc/plugin_registry.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = ["_init"],
)

py_library(
name = "profile",
srcs = ["cmk/ccc/profile.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = ["_init"],
)

py_library(
name = "site",
srcs = ["cmk/ccc/site.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
"_init",
"i18n",
"//packages/cmk-livestatus-client:py_livestatus",
],
)

py_library(
name = "store",
srcs = [
"cmk/ccc/__init__.py",
"cmk/ccc/crash_reporting.py",
"cmk/ccc/daemon.py",
"cmk/ccc/debug.py",
"cmk/ccc/exceptions.py",
"cmk/ccc/i18n.py",
"cmk/ccc/plugin_registry.py",
"cmk/ccc/profile.py",
"cmk/ccc/site.py",
"cmk/ccc/store/__init__.py",
"cmk/ccc/store/_file.py",
"cmk/ccc/store/_locks.py",
"cmk/ccc/version.py",
],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
"//packages/cmk-livestatus-client:py_livestatus",
"_init",
"debug",
"exceptions",
"i18n",
"//packages/cmk-trace",
requirement("pydantic"), # store/_file.py
requirement("pydantic"),
],
)

py_library(
name = "version",
srcs = ["cmk/ccc/version.py"],
imports = ["."],
visibility = ["//visibility:public"],
deps = [
"_init",
"crash-reporting",
"site",
],
)

_ALL = [
"crash-reporting",
"daemon",
"debug",
"exceptions",
"i18n",
"plugin-registry",
"profile",
"site",
"store",
"version",
]

py_doc_test(
name = "doctest",
size = "small",
srcs = ["cmk-ccc"],
srcs = _ALL,
tags = ["no-mypy"],
)

Expand All @@ -53,13 +151,33 @@ py_pytest_main(
)

py_test(
name = "unit",
name = "daemon-tests",
size = "small",
srcs = [
"__test__.py",
"tests/test_daemon.py",
],
main = "__test__.py",
deps = [
"__test__",
"daemon",
"exceptions",
"store",
requirement("pytest"),
],
)

py_test(
name = "site-tests",
size = "small",
srcs = glob(["tests/**/*.py"]) + [":__test__.py"],
srcs = [
"__test__.py",
"tests/test_site.py",
],
main = "__test__.py",
deps = [
":__test__",
":cmk-ccc",
"__test__",
"site",
requirement("pytest"),
],
)
Expand All @@ -75,7 +193,7 @@ py_wheel(
strip_path_prefixes = ["packages/cmk-ccc"],
# TODO: Duplicated from pyproject.toml
version = "1.0.0",
deps = [":cmk-ccc"],
deps = _ALL,
)

package_wheel(
Expand Down
2 changes: 1 addition & 1 deletion packages/cmk-events/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ py_library(
imports = ["."],
visibility = ["//visibility:public"],
deps = [
"//packages/cmk-ccc",
"//packages/cmk-ccc:store",
"//packages/cmk-livestatus-client:py_livestatus",
],
)
Expand Down
3 changes: 2 additions & 1 deletion packages/cmk-werks/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ py_library(
"//omd:__pkg__",
],
deps = [
"//packages/cmk-ccc",
"//packages/cmk-ccc:i18n",
"//packages/cmk-ccc:version",
requirement("gitpython"),
requirement("lxml"),
requirement("markdown"),
Expand Down

0 comments on commit 6aa8237

Please sign in to comment.