Skip to content

Commit e40cb04

Browse files
Cody Pizzaiameta-codesync[bot]
authored andcommitted
Adjust WA iOS audit scripts to ensure dummy mobileconfig deps don't trigger them
Summary: The MobileConfig codegen system on FoA is leverages a dummy_deps library (https://fburl.com/code/mpi4mhgl) in order to detect which mobileconfig params are defined on the dep targets. This library introduces no sources and only replicates deps already in the build, as a result it doesn't affect the build in any meaningful way. However, the dep verification signals on WA iOS are being triggered due to this new dep being introduced. This diff filters the problematic dep out of the workflows. Reviewed By: chatura-atapattu Differential Revision: D100378620 fbshipit-source-id: f2af45496356f006f0282fba7259bfab9f34e76f
1 parent 01e3a2c commit e40cb04

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

tests/check_dependencies_test.bxl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def _impl_check_dependencies_test(
2323
blocklist_patterns: list[str] | None,
2424
target: TargetLabel,
2525
target_deps: bool,
26-
deps_filter_pattern: str | None = None):
26+
deps_filter_pattern: str | None = None,
27+
deps_exclude_pattern: str | None = None):
2728
"""Test the dependencies of a given rule.
2829

2930
The behavior is determined by the verification_mode string value:
@@ -34,6 +35,12 @@ def _impl_check_dependencies_test(
3435
Each pattern list may contain target names (e.g. //foo/bar:bar)
3536
or regex patterns (e.g. //foo/.*)
3637

38+
deps_exclude_pattern: When set, targets matching this regex pattern are
39+
pruned from the dependency traversal. This is useful for excluding
40+
"dummy_deps" targets that exist only for query resolution and don't
41+
contribute to the actual binary. The exclusion happens during traversal,
42+
so the entire subtree under the excluded target is not explored.
43+
3744
"""
3845
if not allowlist_patterns and not blocklist_patterns:
3946
fail("Self-check and self-documentation: must provide allow or block list")
@@ -42,7 +49,13 @@ def _impl_check_dependencies_test(
4249
cquery_kwargs = {}
4350
if deps_filter_pattern:
4451
base = "target_deps()" if target_deps else "first_order_deps()"
45-
cquery_kwargs["filter"] = 'filter("{}", {})'.format(deps_filter_pattern, base)
52+
filter_expr = 'filter("{}", {})'.format(deps_filter_pattern, base)
53+
if deps_exclude_pattern:
54+
filter_expr = '{} - filter("{}", {})'.format(filter_expr, deps_exclude_pattern, base)
55+
cquery_kwargs["filter"] = filter_expr
56+
elif deps_exclude_pattern:
57+
base = "target_deps()" if target_deps else "first_order_deps()"
58+
cquery_kwargs["filter"] = '{} - filter("{}", {})'.format(base, deps_exclude_pattern, base)
4659
elif target_deps:
4760
cquery_kwargs["filter"] = "target_deps()"
4861

@@ -84,12 +97,14 @@ def _impl(ctx: bxl.Context):
8497
ctx.cli_args.target,
8598
ctx.cli_args.target_deps,
8699
ctx.cli_args.deps_filter_pattern,
100+
ctx.cli_args.deps_exclude_pattern,
87101
)
88102

89103
test = bxl_main(
90104
cli_args = {
91105
"allowlist_patterns": cli_args.option(cli_args.list(cli_args.string())),
92106
"blocklist_patterns": cli_args.option(cli_args.list(cli_args.string())),
107+
"deps_exclude_pattern": cli_args.option(cli_args.string()),
93108
"deps_filter_pattern": cli_args.option(cli_args.string()),
94109
"target": cli_args.target_label(),
95110
"target_deps": cli_args.bool(default = True),

tests/check_dependencies_test.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def check_dependencies_test(
5959
labels = [],
6060
target_deps = True,
6161
deps_filter_pattern = None,
62+
deps_exclude_pattern = None,
6263
**kwargs):
6364
"""
6465
Creates a test target from a buck2 bxl script. BXL script must use "test" as entry
@@ -131,6 +132,7 @@ def check_dependencies_test(
131132
"ALLOWLIST": allowlist_patterns,
132133
"BLOCKLIST": blocklist_patterns,
133134
"BXL_MAIN": bxl_main,
135+
"DEPS_EXCLUDE_PATTERN": deps_exclude_pattern or "",
134136
"DEPS_FILTER_PATTERN": deps_filter_pattern or "",
135137
"EXPECT_FAILURE_MSG": expect_failure_msg or "",
136138
"EXTRA_BUCK_ARGS_FILE": "@$(location :%s)" % (extra_buck_args_target),

tests/e2e_util/test_bxl_check_dependencies_template.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ async def test_check_dependencies_bxl(buck) -> None:
6161
if os.environ.get("DEPS_FILTER_PATTERN")
6262
else []
6363
),
64+
*(
65+
["--deps_exclude_pattern", os.environ["DEPS_EXCLUDE_PATTERN"]]
66+
if os.environ.get("DEPS_EXCLUDE_PATTERN")
67+
else []
68+
),
6469
env={
6570
"BUCK2_TEST_DISABLE_LOG_UPLOAD": "false",
6671
"BUCK2_RUNTIME_THREADS": "8",

0 commit comments

Comments
 (0)