Tinder / bazel-diff

Performs Bazel Target Diffing between two revisions in Git, allowing for Test Target Selection and Selective Building
Other
405 stars 60 forks source link

Command hangs on bazel query #252

Closed antspy closed 3 weeks ago

antspy commented 3 weeks ago

Hi,

The lib looks really cool, thanks for sharing! But I am having trouble getting this to work - it seems like it hangs forever whatever I do :)

I downloaded the java binary and I am running it as so: java -jar bazel-diff.jar generate-hashes -v --excludeExternalTargets --includeTargetType -co --noimplicit_deps -w /workspaces/myrepo -m tmp.txt

Thanks to -v, I see the output:

[Info] Executing Query: '//...:all-targets'
[Info] Command: bazel, query, --output, streamed_proto, --order_output=no, --keep_going, --noimplicit_deps, --query_file, /tmp/8186454315808972442.txt

This hangs forever. I see that it's trying to query all targets, which is slow, but not that slow, especially as I pass the noimplicit_deps flag. In fact, if I run it myself: bazel query //...:all-targets --noimplicit_deps it takes around 10 seconds.

I have tried many things:

  1. Adding or removing the --excludeExternalTargets and --includeTargetType options make no difference. The output is the same, it says [Info] Executing Query: '//...:all-targets' and hangs forever.
  2. Adding or removing the modified filepaths option: -m makes no difference. The output is the same, it says [Info] Executing Query: '//...:all-targets' and hangs forever.
  3. I am trying to find a way to build all targets within a directory (equivalent to bazel query //src/...:all-targets --noimplicit_deps) but I don't seem to find an option to make this happen.
  4. Alternatively, would be nice to be able remove some directories from consideration (e.g. //node_modules). I am not sure how the code recognizes 'external targets', and I don't get how to modify it.

Would really appreciate any help here! I would love to be able to use this :)

tinder-maxwellelliott commented 3 weeks ago

Can you test with this change and see if it unblocks you? https://github.com/Tinder/bazel-diff/pull/246

antspy commented 3 weeks ago

I was using the 8.1.1 release, so the fix was already being used.

Turns out if I use bazel run //:bazel-diff -- generate-hashes ... it works as expected. If I try to instead use the script:

bazel run //:bazel-diff --script_path=${path}
${path} generate-hashes ...

then it hangs forever! No idea why - but I just switched to using bazel run directly. Thank you! :)