Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bazel/dependency/reachability.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ on a path. The same pruning applies to `attributed_packages`: excluded
repositories are not attributed, and packages are not attributed to repositories
reachable only through an excluded repository.

Aliases are transparent: an edge to an `alias` is recorded against the actual
target's repository. `excluded_patterns` and JSON consumers such as `deps.yaml`
validation must therefore match the resolved repository, not the alias's.

`attribution_patterns` is opt-in and defaults to empty. When left unset, the
emitted JSON is byte-identical to the historical output and no attribution sets
are propagated through the aspect. Opt in only when a consumer specifically
Expand Down
21 changes: 20 additions & 1 deletion bazel/dependency/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,9 @@ filegroup(
name = "pattern_root",
srcs = [
"@bazel_skylib//lib:paths",
"@bazel_tools//tools/bash/runfiles",
# Use a concrete rule: since Bazel 9, bash/runfiles aliases rules_shell,
# and aspects observe the actual target's repository.
"@bazel_tools//tools/cpp:toolchain_type",
],
)

Expand All @@ -505,6 +507,22 @@ dependency_reachability(
roots = [":pattern_root"],
)

alias(
name = "skylib_alias",
actual = "@bazel_skylib//lib:sets",
)

filegroup(
name = "alias_root",
srcs = [":skylib_alias"],
)

dependency_reachability(
name = "reachability_alias",
testonly = True,
roots = [":alias_root"],
)

filegroup(
name = "apparent_exclusion_root",
srcs = ["@apparent_excluded_repo//:direct"],
Expand Down Expand Up @@ -560,6 +578,7 @@ sh_test(
size = "small",
srcs = ["exclusions_reachability_test.sh"],
data = [
":reachability_alias",
":reachability_apparent_exclusion",
":reachability_apparent_exclusion_baseline",
":reachability_attribution_excluded",
Expand Down
6 changes: 6 additions & 0 deletions bazel/dependency/test/exclusions_reachability_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ else
fi

JQ="${JQ_BIN:-jq}"
REACHABILITY_ALIAS_JSON="${RUNFILES_DIR}/dependency/test/reachability_alias.json"
REACHABILITY_EXCLUDED_EDGE_JSON="${RUNFILES_DIR}/dependency/test/reachability_excluded_edge.json"
REACHABILITY_EDGE_AND_PATTERN_JSON="${RUNFILES_DIR}/dependency/test/reachability_edge_and_pattern.json"
REACHABILITY_EXCLUDED_PATTERN_JSON="${RUNFILES_DIR}/dependency/test/reachability_excluded_pattern.json"
Expand Down Expand Up @@ -72,6 +73,11 @@ check "excluded_patterns can remove all matching deps from one root" \
"0" \
"${REACHABILITY_EXCLUDED_PATTERN_JSON}"

check "alias edges record the actual target under its external repository" \
'.dependencies[] | select(.name == "bazel_skylib") | .targets | map(sub("^@+[^/]*//"; "//")) | sort | join(",")' \
"//lib:sets" \
"${REACHABILITY_ALIAS_JSON}"

check "excluded_patterns baseline includes the matched boundary repo" \
'[.dependencies[] | .name] | any(. == "rules_pkg")' \
"true" \
Expand Down
Loading