babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
Marco Pas 2021-01-23T06:03:14.052200Z

@borkdude You are really helping me out in understanding BB and also Clojure txs!!

Marco Pas 2021-01-23T07:51:48.054600Z

Question about running tests again 🙂

.
├── run-test.sh
├── src
│   └── cap
└── test
    └── cap
        ├── test_a.clj
        └── test_b.clj
#test_a.clj
(ns cap.test-a (:require [clojure.test :as t :refer [deftest, is]]))

(deftest test-simple-pass
  (is (= 2 (+ 1 1))))
#test_b.clj
(ns cap.test-b (:require [clojure.test :as t :refer [deftest, is]]))

(deftest test-simple-fail
  (is (= 3 (+ 1 1))))
I can run a single test file with the recipe like:
#!/usr/bin/env bash
bb -cp "src:test:resources" \
   -e "(require '[clojure.test :as t] '[cap.test-a])
       (let [{:keys [:fail :error]} (t/run-tests 'cap.test-a)]
         (System/exit (+ fail error)))"
But how can i run all tests? Also the tests from test_b.clj

borkdude 2021-01-23T08:09:07.056100Z

@marco.pasopas you should also require the b namespace and you can use run-all-tests from Clojure.test

Marco Pas 2021-01-23T08:13:43.058700Z

@borkdude something like this??

#!/usr/bin/env bash
bb -cp "src:test:resources" \
   -e "(require '[clojure.test :as t] '[cap.test-a] '[cap.test-b])
       (let [{:keys [:fail :error]} (t/run-all-tests)]
         (System/exit (+ fail error)))"
This also runs the tests like
Testing cap.test-a
Testing bencode.core
Testing clj-yaml.core
Testing clojure.java.browse

Marco Pas 2021-01-23T08:14:07.059300Z

Would it be more idiomatic to create somekind of test runner namespace or something?

borkdude 2021-01-23T08:15:33.061200Z

Yes, you can just add the name to run-tests. You can add multiple namespaces there. I updated the book to make this a test runner script instead of a command line expression

👍 1
borkdude 2021-01-23T08:20:32.062Z

I’ll update it with multiple namespaces and also with add-classpath

👍 2
Felipe Marques 2021-01-24T16:38:16.094900Z

Awesome! I was just going to add tests to the internal CLI of the company that I work for. Btw, do you have any suggestion for easy mocking in Babashaka for tests? I've being using match which gives me a easy way to mach cases for sh calls like this:

(match args
             ["aws" "s3" "cp" "<s3://pipo-prod/features-config-v2.edn>" _] (spit (nth args 4) new-features-config)
             ["aws" "s3" "cp" _ "<s3://pipo-prod/features-config-v2.edn>"] nil
             ["rm" _] (io/delete-file (second args))
             :else (throw (ex-info "unexpected sh call: " args)))))
But as I'm not sure this will work on babashka, I'm running the tests in Clojure

borkdude 2021-01-24T16:40:00.095100Z

@marques.goncalves.fel is this core.match?

Felipe Marques 2021-01-24T16:40:05.095300Z

yes

borkdude 2021-01-24T16:40:14.095500Z

core.match is now merged to master

❤️ 1
borkdude 2021-01-24T16:40:29.095700Z

will be included in the next release

❤️ 1
Felipe Marques 2021-01-24T16:40:50.095900Z

wow! awesome! thanks!

borkdude 2021-01-24T16:41:23.096300Z

you can already try it out by downloading a binary from the builds

👍 1
borkdude 2021-01-24T21:41:19.099900Z

@marques.goncalves.fel now released as 0.2.8

Felipe Marques 2021-01-24T23:23:57.113800Z

Just set up the test runner and the CI using babashka 0.2.8! It worked great including the tests with core.match! Thanks!

🎉 1
Marco Pas 2021-01-23T08:28:03.063500Z

Apologies for asking dumb questions 🙂 , still need to get used to the Clojure / BB ecosystem

borkdude 2021-01-23T08:47:26.063900Z

No problem!

borkdude 2021-01-23T08:57:18.064100Z

@marco.pasopas Updated: https://book.babashka.org/#recipes

borkdude 2021-01-23T13:31:41.065500Z

I am looking into including hiccup in babashka for static site generation, but the standard hiccup library doesn't work with GraalVM, since it's based on ... eval 😲

1
😮 1
polymeris 2021-01-23T13:47:06.066800Z

Does anyone know of a less "minimal" babashka docker image to use in CI (one that includes e.g. git)

borkdude 2021-01-23T13:48:06.067900Z

@polymeris There is now a babashka/babashka image and also a babashka-alpine image. The first one is based on ubuntu and the second one on alpine. Both come with curl (for babashka.curl) but nothing more than that. Just derive another image from it.

👍 1
❤️ 1
Jakub Holý 2021-01-23T14:45:26.068800Z

Where can I download a pre-built sql pod binary?

borkdude 2021-01-23T14:45:43.069Z

@holyjak do you mean the oracle one?

✔️ 1
borkdude 2021-01-23T14:47:47.069400Z

Do you mean, for third parties, other than you?

Jakub Holý 2021-01-23T14:54:54.069900Z

No, for me. I supposed that once merged, a binary for each DB and linux/Mac is built and published somewhere. Or do I always need to build pods myself? (for Linux)

borkdude 2021-01-23T14:55:30.070600Z

Ah, found the issue with hiccup. You have to take care to not map the html macro inside the sci interpreter, but a function, wrapping the macro call, to avoid hiccup to go into "compilation" mode which uses eval 😅

👍 1
borkdude 2021-01-23T14:56:22.070900Z

But it seems their site is under maintenance 😠

borkdude 2021-01-23T14:56:35.071100Z

Btw, I now see only 4 jobs, the postgres jobs disappeared?

Jakub Holý 2021-01-23T15:00:56.072100Z

(I want to include it in my aws lambda on Monday and would be happy not to need adding a build stage for it)

lread 2021-01-23T15:02:10.072500Z

Was that a sci of relief I just heard? 🙂

😎 2
borkdude 2021-01-23T15:02:49.072700Z

I get that. We can distribute it on the pod registry, but I need to know absolutely sure we are not offending any licenses

👍 1
Jakub Holý 2021-01-23T15:11:05.073100Z

Will verify the license

Jakub Holý 2021-01-23T16:30:46.073300Z

I hate Oracle. I will need to try to check this with our legal department. Signals from the internet are ambiguous.

borkdude 2021-01-23T16:41:45.073500Z

so which license has the helidon driver?

Jakub Holý 2021-01-23T16:50:05.073700Z

Helidon itself has Apache but their driver is literally wrapped ojdbc + reflection json

Jakub Holý 2021-01-23T16:52:11.073900Z

https://github.com/oracle/helidon/blob/master/integrations/db/ojdbc/pom.xml only mentions Apache

borkdude 2021-01-23T16:52:17.074200Z

Maybe post an issue on the Helidon issue tracker to ask how this should be considered?

👍 1
borkdude 2021-01-23T16:55:45.074400Z

As for the pod-registry, I will not distribute it in case of doubt, don't want the legal department of Oracle on my back

💯 1
borkdude 2021-01-23T16:56:21.074600Z

So you could maybe build it yourself locally and send it along with your AWS Lambda image

👍 1
Bret Horne 2021-01-23T21:18:04.078400Z

Is there a way to interactively develop something with the lanterna pod? This fork doesnt make use of the swing terminal so I was wondering what others have done. (Just remembered that prepl exists so will look further into that)

borkdude 2021-01-23T21:22:25.080900Z

@bret.horne I read that GraalVM 21 has support now for Swing on linux (https://medium.com/graalvm/graalvm-21-0-introducing-a-new-way-to-run-java-df894256de28) but it's experimental, this is why the lanterna pod doesn't have Swing yet. As for interactive development, there is a socket REPL, pREPL and nREPL in bb

Bret Horne 2021-01-23T21:22:52.081300Z

Also, thank you for your work on this btw. I love being able to run clojure in production now for tooling 🙂

❤️ 1
Bret Horne 2021-01-23T21:23:50.081700Z

I gotcha.

Bret Horne 2021-01-23T21:24:40.082700Z

I tried using nrepl first and connecting to that way, in emacs via cider-connect, but im not entirely sure how its supposed to work. The terminal seems to blend in with the repl and I lose all connection to it despite shutting down the terminal.

borkdude 2021-01-23T21:25:09.083100Z

ah that's tricky, yeah, not sure

borkdude 2021-01-23T21:25:44.083700Z

fwiw, a lot of the times, I just re-run the scripts I'm developing until it works, since the startup is so fast, the difference with a REPL isn't that big

Bret Horne 2021-01-23T21:26:45.084700Z

true. I tried using your clojure-lanterna fork directly and using javac to compile it as im not a lein user but use clj instead.

Bret Horne 2021-01-23T21:27:33.085300Z

so Ill continue down that path to run it on the jvm.

borkdude 2021-01-23T21:28:33.085600Z

yeah, that's also an option

Bret Horne 2021-01-23T21:41:45.087400Z

nrepl > /dev/tty seems to work well enough

borkdude 2021-01-23T21:48:49.087800Z

@holyjak For the time being, you can download it from here: https://app.circleci.com/pipelines/github/babashka/babashka-sql-pods/103/workflows/07264b48-367b-43e5-88f4-18784deecab8/jobs/341/artifacts This link will expire in 30 days

❤️ 1
Jakub Holý 2021-01-23T21:57:32.088200Z

Thank you very much!

borkdude 2021-01-23T22:04:27.088500Z

@holyjak One issue, I think the postgres jobs now disappeared

borkdude 2021-01-23T22:04:54.088700Z

hmm, no sorry. they are there

borkdude 2021-01-23T22:05:26.088900Z

it was a UI glitch, all good!