feat: add debug logging of repo sub processes#1735
feat: add debug logging of repo sub processes#1735rickeylev merged 5 commits intobazel-contrib:mainfrom
Conversation
Debugging what the repo rules are up to can be difficult because Bazel doesn't provide many facilities to inspect what they're up to. This adds an environment variable, `RULES_PYTHON_REPO_DEBUG`, that, when set, will make our repo rules print out detailed information about the subprocesses they are running. This also makes failed commands dump much more comprehensive information.
aignas
left a comment
There was a problem hiding this comment.
Thanks, this is really great!
| args, | ||
| repo_utils.execute_checked( | ||
| rctx, | ||
| op = "whl_library.ResolveRequirement({}, {})".format(rctx.attr.name, rctx.attr.requirement), |
There was a problem hiding this comment.
nit: we could also have this semantics for the op, where the first item is the function name and the remaining are parameters which will be formated to: op[0] + "(" + ",".join(op[1:]) + ")"
| op = "whl_library.ResolveRequirement({}, {})".format(rctx.attr.name, rctx.attr.requirement), | |
| op = ["whl_library.ResolveRequirement", rctx.attr.name, rctx.attr.requirement], |
There was a problem hiding this comment.
I like the idea. It also gave me another idea: automatically add the "whl_library" part (the repo rule name) by looking for a _repo_name attribute we set on all our repo rules.
But, I'm strapped for time today, so I'm going to merge this as-is.
rickeylev
left a comment
There was a problem hiding this comment.
I tried writing some tests for this but it started to spiral out of control pretty quickly (I tried mocking rctx, fail, and print 😵💫) and didn't test very well. I manually ran bazel build ... with the env set and forcing failures instead.
| args, | ||
| repo_utils.execute_checked( | ||
| rctx, | ||
| op = "whl_library.ResolveRequirement({}, {})".format(rctx.attr.name, rctx.attr.requirement), |
There was a problem hiding this comment.
I like the idea. It also gave me another idea: automatically add the "whl_library" part (the repo rule name) by looking for a _repo_name attribute we set on all our repo rules.
But, I'm strapped for time today, so I'm going to merge this as-is.
…on into repos.cmds
Debugging what the repo rules are up to can be difficult because Bazel doesn't provide many facilities to inspect what they're up to. This adds an environment variable,
RULES_PYTHON_REPO_DEBUG, that, when set, will make our repo rules print out detailed information about the subprocesses they are running.This also makes failed commands dump much more comprehensive information.
This was driven by the recent report of failures on Windows during a repo rule.