keith / rules_multirun

Bazel rules for running multiple commands in parallel in a single bazel invocation
Apache License 2.0
65 stars 13 forks source link

Use output of bazel query in multirun #12

Closed OscarVanL closed 1 year ago

OscarVanL commented 1 year ago

Hi, apologies if this is abusing the 'issues' section of this repo as it is more of a question.

I have some CI that pushes container images, unfortunately this happens sequentially as bazel run does not support multiple arguments, which makes it take longer than necessary.

My existing CI script looks like this:

for rule in $(bazel query 'kind(container_push, //...)'); do
    bazel run $rule;

I'd love to use multirun to make several container_push in my bazel workspace work in parallel, but I don't really understand how to do it 'on the fly' inside a terminal session. Am I going down the wrong path here?

keith commented 1 year ago

IIUC what you're saying is that you'd like to run multiple, but varying, container_pushes at once? If that's the case I think the easiest way using multirun would be to generate the rule on the fly based on your query, and then run that, would that make sense?

OscarVanL commented 1 year ago

Yes that is exactly it! Do you know how I could generate the rule on the fly?

keith commented 1 year ago

i was thinking wherever you are doing that for loop you could do something where you redirected the query output into a BUILD file to generate the rule

keith commented 1 year ago

lmk if you think of another way we should do this in these rules! hope that works for you!