Finding the longest / most comprehensive successful build chain

208 views
Skip to first unread message

ittai zeidman

unread,
Sep 11, 2016, 10:58:02 AM9/11/16
to bazel-discuss
Hi,
I'm working on a migrating tool from maven to bazel which is aimed at building fine grain targets (package if possible, and if cycles exist then aggregate the packages).
For the first phase I'm migrating a codebase with ~100 maven modules to bazel and I was able to output 470 packages (includes packages for 3rdParty), ~770  targets and ~1800 actions.
The problem is that my build currently fails since I was too strict and I'm missing on some 3rd party compile dependencies.
I'd like to see if I can use the bazel query language to find the longest (or even better most comprehensive) successful build chain in the repo.
This will help me show the value of bazel for the part of the graph that works while continue to solve the problems in the part that doesn't.
This thread resembles what I need but I think I need something much more complex.
One thought I had was to do the following:
val allTargets = "bazel query //..."
val rdepsOfTargets = for each target => (target, "bazel query rdeps(//...,  $target)")  // for each target create a pair of the target and the transitive reverse dependencies of it
then go over the map and try to run the build for every target which has itself and all of it's deps in the "successful targets" set.
This means that at first i'll try to run only those without dependencies.
Afterwards only those which depend only on the successful ones (after success i add the target to the set). I think this can give me after a few dozen rounds a good view but:
1. I might be totally off here.
2. Sounds like it will take a long time. 

Would really appreciate input,
Ittai 

Brian Silverman

unread,
Sep 11, 2016, 12:02:44 PM9/11/16
to ittai zeidman, bazel-discuss
If you run `bazel build --keep_going --show_result=1000000 //...` you can parse the output saying which targets succeeded and stick it in a file. Targets depending on others which fail will be reported as failing automatically. Then a `bazel query --output=maxrank "deps($EACH_TARGET)" | tail` will give you the depth of the chain for each one.

If you want something faster for the second part which doesn't involve a query for each successful target, I think the easiest way is to parse `bazel query --output=proto 'deps(//... except set($(<failed_targets)))'` (use src/main/protobuf/build.proto from the Bazel source tree, or use --output=xml instead) and find the longest chain. I would just write a script running the --output=maxrank command for each file and leaving it running, but it depends on whether you want it to scale etc.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/01c7cbc4-7ea1-4ae1-8886-be9ffc1da743%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ittai zeidman

unread,
Sep 12, 2016, 9:42:09 AM9/12/16
to Brian Silverman, bazel-discuss
Thank you! 
I'll try these suggestions and update.

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages