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.
diff --git a/examples/bzlmod_build_file_generation/BUILD.bazel b/examples/bzlmod_build_file_generation/BUILD.bazel
index c5e27c2..bd2fc80 100644
--- a/examples/bzlmod_build_file_generation/BUILD.bazel
+++ b/examples/bzlmod_build_file_generation/BUILD.bazel
@@ -53,6 +53,7 @@
"//:requirements_lock.txt",
"//:requirements_windows.txt",
],
+ tags = ["exclusive"],
# NOTE: we can use this flag in order to make our setup compatible with
# bzlmod.
use_pip_repository_aliases = True,
diff --git a/gazelle/manifest/defs.bzl b/gazelle/manifest/defs.bzl
index f1266a0..d5afe7c 100644
--- a/gazelle/manifest/defs.bzl
+++ b/gazelle/manifest/defs.bzl
@@ -25,7 +25,8 @@
pip_repository_name = "",
pip_deps_repository_name = "",
manifest = ":gazelle_python.yaml",
- use_pip_repository_aliases = False):
+ use_pip_repository_aliases = False,
+ **kwargs):
"""A macro for defining the updating and testing targets for the Gazelle manifest file.
Args:
@@ -39,6 +40,8 @@
pip_deps_repository_name: deprecated - the old pip_install target name.
modules_mapping: the target for the generated modules_mapping.json file.
manifest: the target for the Gazelle manifest file.
+ **kwargs: other bazel attributes passed to the target target generated by
+ this macro.
"""
if pip_deps_repository_name != "":
# buildifier: disable=print
@@ -102,6 +105,14 @@
tags = ["manual"],
)
+ attrs = {
+ "env": {
+ "_TEST_MANIFEST": "$(rootpath {})".format(manifest),
+ "_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash),
+ "_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
+ },
+ "size": "small",
+ }
go_test(
name = "{}.test".format(name),
srcs = [Label("//manifest/test:test.go")],
@@ -110,14 +121,10 @@
requirements,
manifest_generator_hash,
],
- env = {
- "_TEST_MANIFEST": "$(rootpath {})".format(manifest),
- "_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash),
- "_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements),
- },
rundir = ".",
deps = [Label("//manifest")],
- size = "small",
+ # kwargs could contain test-specific attributes like size or timeout
+ **dict(attrs, **kwargs)
)
native.filegroup(