Skip to content

Commit

Permalink
Pantsbuild: Add BUILD dependencies for logging.conf (#6251)
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd authored Sep 25, 2024
2 parents a5f4d1a + 1180d1a commit 3e952e7
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 22 deletions.
5 changes: 5 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ file(
shell_sources(
name="root",
)

file(
name="logs_directory",
source="logs/.gitignore",
)
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Added
* Continue introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
working on StackStorm, improve our security posture, and improve CI reliability thanks in part
to pants' use of PEX lockfiles. This is not a user-facing addition.
#6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244
#6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251
Contributed by @cognifloyd
* Build of ST2 EL9 packages #6153
Contributed by @amanda11
Expand Down
31 changes: 31 additions & 0 deletions pants-plugins/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,34 @@ def st2_shell_sources_and_resources(**kwargs):

kwargs["name"] += "_resources"
resources(**kwargs) # noqa: F821


# these are referenced by the logging.*.conf files.
_st2common_logging_deps = (
"//st2common/st2common/log.py",
"//st2common/st2common/logging/formatters.py",
)


def st2_logging_conf_files(**kwargs):
"""This creates a files target with logging dependencies."""
deps = kwargs.pop("dependencies", []) or []
deps = list(deps) + list(_st2common_logging_deps)
kwargs["dependencies"] = tuple(deps)
files(**kwargs) # noqa: F821


def st2_logging_conf_file(**kwargs):
"""This creates a file target with logging dependencies."""
deps = kwargs.pop("dependencies", []) or []
deps = list(deps) + list(_st2common_logging_deps)
kwargs["dependencies"] = tuple(deps)
file(**kwargs) # noqa: F821


def st2_logging_conf_resources(**kwargs):
"""This creates a resources target with logging dependencies."""
deps = kwargs.pop("dependencies", []) or []
deps = list(deps) + list(_st2common_logging_deps)
kwargs["dependencies"] = tuple(deps)
resources(**kwargs) # noqa: F821
8 changes: 5 additions & 3 deletions st2actions/conf/BUILD
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
file(
st2_logging_conf_file(
name="logging_console",
source="console.conf",
)

files(
st2_logging_conf_files(
name="logging",
sources=["logging*.conf"],
dependencies=["//:logs_directory"],
overrides={
"logging.conf": dict(
dependencies=[
"//:logs_directory",
"//:reqs#python-json-logger",
],
),
},
)

files(
st2_logging_conf_files(
name="logging_syslog",
sources=["syslog*.conf"],
)
10 changes: 6 additions & 4 deletions st2api/conf/BUILD
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
file(
st2_logging_conf_file(
name="logging_console",
source="console.conf",
)

file(
st2_logging_conf_file(
name="logging",
source="logging.conf",
dependencies=["//:logs_directory"],
)

file(
st2_logging_conf_file(
name="logging_gunicorn",
source="logging.gunicorn.conf",
dependencies=["//:logs_directory"],
)

file(
st2_logging_conf_file(
name="logging_syslog",
source="syslog.conf",
)
10 changes: 6 additions & 4 deletions st2auth/conf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ file(
source="htpasswd_dev",
)

file(
st2_logging_conf_file(
name="logging_console",
source="console.conf",
)

file(
st2_logging_conf_file(
name="logging",
source="logging.conf",
dependencies=["//:logs_directory"],
)

file(
st2_logging_conf_file(
name="logging_gunicorn",
source="logging.gunicorn.conf",
dependencies=["//:logs_directory"],
)

file(
st2_logging_conf_file(
name="logging_syslog",
source="syslog.conf",
)
7 changes: 4 additions & 3 deletions st2reactor/conf/BUILD
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
file(
st2_logging_conf_file(
name="logging_console",
source="console.conf",
)

files(
st2_logging_conf_files(
name="logging",
sources=["logging*.conf"],
dependencies=["//:logs_directory"],
)

files(
st2_logging_conf_files(
name="logging_syslog",
sources=["syslog*.conf"],
)
10 changes: 6 additions & 4 deletions st2stream/conf/BUILD
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
file(
st2_logging_conf_file(
name="logging_console",
source="console.conf",
)

file(
st2_logging_conf_file(
name="logging",
source="logging.conf",
dependencies=["//:logs_directory"],
)

file(
st2_logging_conf_file(
name="logging_gunicorn",
source="logging.gunicorn.conf",
dependencies=["//:logs_directory"],
)

file(
st2_logging_conf_file(
name="logging_syslog",
source="syslog.conf",
)
4 changes: 2 additions & 2 deletions st2tests/conf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ file(
source="st2_kvstore_tests.crypto.key.json",
)

file(
st2_logging_conf_file(
name="logging.conf",
source="logging.conf",
)

files(
st2_logging_conf_files(
name="other_logging_conf",
sources=["logging.*.conf"],
)
Expand Down
7 changes: 6 additions & 1 deletion st2tests/st2tests/fixtures/conf/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
st2_logging_conf_resources(
name="logging",
sources=["logging.*.conf"],
)

resources(
name="st2.tests.conf",
sources=[
"st2.tests*.conf",
"logging.*.conf", # used by st2.tests*.conf
],
dependencies=[
":logging", # used by st2.tests*.conf
"st2tests/conf:other_logging_conf",
# depending on st2auth from st2tests is not nice.
"st2auth/conf:htpasswd",
Expand Down

0 comments on commit 3e952e7

Please sign in to comment.