Skip to content

Commit e3449dc

Browse files
authored
Adding kwargs to gazelle_python_manifest (#1289)
Adding kwargs to gazelle_python_manifest, so we can set the tags and size to the test. This is similar to: https://github.com/bazelbuild/rules_python/blob/5b8fa22a2f22501b18b4aea97c5dbfe3a6913a0c/python/pip_install/requirements.bzl#L20-L62 Alternatively, we can add individual `go_test` attributes as needed. Please advice which way is preferred.
1 parent b4ab34e commit e3449dc

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

examples/bzlmod_build_file_generation/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ gazelle_python_manifest(
5353
"//:requirements_lock.txt",
5454
"//:requirements_windows.txt",
5555
],
56+
tags = ["exclusive"],
5657
# NOTE: we can use this flag in order to make our setup compatible with
5758
# bzlmod.
5859
use_pip_repository_aliases = True,

gazelle/manifest/defs.bzl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def gazelle_python_manifest(
2525
pip_repository_name = "",
2626
pip_deps_repository_name = "",
2727
manifest = ":gazelle_python.yaml",
28-
use_pip_repository_aliases = False):
28+
use_pip_repository_aliases = False,
29+
**kwargs):
2930
"""A macro for defining the updating and testing targets for the Gazelle manifest file.
3031
3132
Args:
@@ -39,6 +40,8 @@ def gazelle_python_manifest(
3940
pip_deps_repository_name: deprecated - the old pip_install target name.
4041
modules_mapping: the target for the generated modules_mapping.json file.
4142
manifest: the target for the Gazelle manifest file.
43+
**kwargs: other bazel attributes passed to the target target generated by
44+
this macro.
4245
"""
4346
if pip_deps_repository_name != "":
4447
# buildifier: disable=print
@@ -102,6 +105,14 @@ def gazelle_python_manifest(
102105
tags = ["manual"],
103106
)
104107

108+
attrs = {
109+
"env": {
110+
"_TEST_MANIFEST": "$(rootpath {})".format(manifest),
111+
"_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash),
112+
"_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
113+
},
114+
"size": "small",
115+
}
105116
go_test(
106117
name = "{}.test".format(name),
107118
srcs = [Label("//manifest/test:test.go")],
@@ -110,14 +121,10 @@ def gazelle_python_manifest(
110121
requirements,
111122
manifest_generator_hash,
112123
],
113-
env = {
114-
"_TEST_MANIFEST": "$(rootpath {})".format(manifest),
115-
"_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash),
116-
"_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
117-
},
118124
rundir = ".",
119125
deps = [Label("//manifest")],
120-
size = "small",
126+
# kwargs could contain test-specific attributes like size or timeout
127+
**dict(attrs, **kwargs)
121128
)
122129

123130
native.filegroup(

0 commit comments

Comments
 (0)