Fork me on GitHub
#babashka
<
2024-06-09
>
joshuamz21:06:16

Hello. I'm trying to run multiple bb tasks sequentially (one after the other) using the :depends keyword but it's not working. I tried using {:parallel true} via a private task and it does work, but output gets mingled. My tasks are running custom functions. What am I missing?

...
  style     {:doc  "Check code style with cljfmt"
             :task (apply tasks.style/run "check" *command-line-args*)}

  lint      {:doc  "Lint code with clj-kondo"
             :task (apply tasks.lint/run "--lint" *command-line-args*)}

  check     {:doc "Check codebase with style and lint tasks"
             :depends [style lint]}
  ...
If I run bb check, it runs the style task, but not the lint task. If I use the private task and set :parallel to false, I get the same behavior just described.

borkdude21:06:33

@U02BATFPN78 bb check should run the style AND lint task, but if the style task throws an exception or something, then it won't run the lint task

borkdude21:06:45

if the code for style calls something like (System/exit 0) then it shuts down bb, which could also be the issue

joshuamz21:06:35

Ahh that's exactly what happened... I needed to know which error code was thrown by either cljfmt or clj-kondo native binaries (if available) and just left a (System/exit exit) expr at tail position, dropping composition as a side effect. Now I check (pos? exit) to call that. Thanks!

👍 1
borkdude21:06:24

instead of System/exit you can also do this in bb:

(throw (ex-info "something bad happened" {:babashka/exit 1}))
which will terminate without printing a stacktrace

joshuamz21:06:31

Oh nice! I'll try that out. Thank you again 🙂