Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Babashka tasks (at London Clojurians July 2021)

Babashka tasks (at London Clojurians July 2021)

In babashka 0.4.0 a new feature was introduced: the task runner.
In this talk, Michiel demonstrates how to best leverage this new feature to
automate and compose the execution of common project tasks.

Talk on Youtube:
https://youtu.be/u5ECoR7KT1Y

https://babashka.org/

Bbb17eeeecd3d9d06f4db310ab630a12?s=128

Michiel Borkent

July 20, 2021
Tweet

Transcript

  1. Tasks Michiel Borkent @borkdude 2021-07-20

  2. • Native Clojure scripting tool, single binary, no JVM •

    Developed since August 2019 (2000+ stars, 68 contributors) • Can be used to replace “the grey areas” of bash • Installable via script, brew (macOS, linux), aur (linux), scoop (Windows) $ time bb -e '(+ 1 2 3)'
 6
 0.00s user 0.00s system 67% cpu 0.013 total
  3. Make, just, etc. • Complex project-specific CLI invocations • Remember

    • Shortcuts • Discoverability • Fast startup • Only rebuild when necessary (make) • Clojure...?
  4. Babashka tasks $ bb run clean
 # or
 $ bb

    clean
  5. Use any bb compatible lib $ bb clean

  6. Arbitrary (EDN compatible) expressions $ bb clean
 Removing target folder.

  7. bb run options: --parallel $ bb run --parallel d
 d:

    #inst "2021-05-08T14:14:56.322-00:00"
 a: #inst "2021-05-08T14:14:56.357-00:00"
 b: #inst "2021-05-08T14:14:56.360-00:00"
 c: #inst "2021-05-08T14:15:01.366-00:00"
 "Elapsed time: 5023.894512 msecs"
  8. bb run options: --prn

  9. Hooks: :init

  10. Hooks: :enter, :leave

  11. Command line args • Just use *command-line-args*, bb leaves it

    unprocessed. • To pass args from a task to another task, use binding + run
  12. Task-local options

  13. Discoverability

  14. Tasks API: run, clojure, shell

  15. Tasks API: run, clojure, shell

  16. Tasks API: run, clojure, shell

  17. Tasks API: run, clojure, shell

  18. Dependencies

  19. Rebuild when necessary

  20. Dependencies (parallel) $ bb coffeep (1168ms)
 $ bb run --parallel

    coffeep (654ms)
  21. Dependencies (parallel)

  22. Invoking a main function

  23. Real examples • clj-kondo.lsp • bb.edn at Doctor Evidence •

    rewrite-clj • More links in docs
  24. Docs https://book.babashka.org/#tasks

  25. Babashka tasks • Complex project-specific CLI invocations • Remember •

    Shortcuts • Discoverability • Fast startup • Only rebuild when necessary • Clojure!
  26. Thanks to sponsors! https://opencollective.com/babashka/contribute https://github.com/sponsors/borkdude

  27. Thanks Michiel Borkent @borkdude 2021-07-20