bazel-contrib / target-determinator

Determines which Bazel targets were affected between two git commits.
Apache License 2.0
144 stars 22 forks source link

Don't expand configurations when resolving alias targets #58

Closed illicitonion closed 1 year ago

illicitonion commented 1 year ago

This is somewhat of a one-off hack, and worse, one that doesn't have any tests at the moment.

I'm hoping we can delete the whole ruleInput-traversing code once configuredRuleInputs work properly, so I don't want to spend too much effort on fixing/cleaning this up. But this fixes an issue where we end up with dependency cycles from repos using nogo.

Example of a dep cycle detected from the repro in https://github.com/bazel-contrib/target-determinator/issues/57:

//:foo({c80b9498488335b21bd4632dcf0aa4f7db11cd6c89f3f35f25fa68710bf56b7e}) ->
@io_bazel_rules_go//:go_context_data({32ab441c58045d9b4e47c3bb3cf71e8d1e52d86f4107a8b967abde5e5d73cb8f}) ->
@io_bazel_rules_nogo//:nogo({34b4f9b498e11062e731da9c967ee9bfbe4e9aa4039c19fc8f9a1ea22a6f076c}) ->
//:foo_nogo({34b4f9b498e11062e731da9c967ee9bfbe4e9aa4039c19fc8f9a1ea22a6f076c}) ->
//:foo_nogo_actual({1244bd2b200dc7a4b988f96817d32268c059b3e80b99e063781853e0de944077}) ->
@io_bazel_rules_go//go/tools/builders:nogo_srcs({1244bd2b200dc7a4b988f96817d32268c059b3e80b99e063781853e0de944077}) ->
@org_golang_x_tools//go/analysis({1244bd2b200dc7a4b988f96817d32268c059b3e80b99e063781853e0de944077}) ->
@io_bazel_rules_go//:go_context_data({52be3afbb4a423ecd22f6ba6b8d0166a5eb300e983f453e78f8367af4f1e59ef}) ->
@io_bazel_rules_nogo//:nogo({55436eb059be055001217ca71db4b17b8a7a5b4d64199d98d857c06fde9625b3}) ->
//:foo_nogo({55436eb059be055001217ca71db4b17b8a7a5b4d64199d98d857c06fde9625b3}) ->
//:foo_nogo_actual({41d4bd4d71536ae43317891070271830cbb7f651b5828950ce64d0e2d28b9d68}) ->
@io_bazel_rules_go//go/tools/builders:nogo_srcs({41d4bd4d71536ae43317891070271830cbb7f651b5828950ce64d0e2d28b9d68}) ->
@org_golang_x_tools//go/analysis({41d4bd4d71536ae43317891070271830cbb7f651b5828950ce64d0e2d28b9d68}) ->
@io_bazel_rules_go//:go_context_data({55436eb059be055001217ca71db4b17b8a7a5b4d64199d98d857c06fde9625b3}) ->
@io_bazel_rules_nogo//:nogo({a29c3276bb2dc539f6def9b7e062542583b3a79f5da5025e86d7cf69ee15767c}) ->
//:foo_nogo({e4b8fafb84b60e087c1903096c15030fa40d930791854f7919e96553db49b18b}) ->
//:foo_nogo_actual({41d4bd4d71536ae43317891070271830cbb7f651b5828950ce64d0e2d28b9d68})

Both @io_bazel_rules_nogo//:nogo and //foo_nogo are alias targets which end up exploding out into multiple configurations causing cycles.

Fixes #57