Fork me on GitHub
#babashka
<
2022-04-03
>
David Pham07:04:27

I don’t know if it has been asked already, but it is possible to specify a different file for bb.edn? Like global tasks?

borkdude07:04:54

Yes, use --config

borkdude08:04:25

Let me know if that's enough info. I had to be short this morning, as I had to go somewhere :)

teodorlu09:04:26

neil PR ready for review: CLI for listing available versions of a library https://github.com/babashka/neil/pull/17

teodorlu09:04:05

I'm leaving the computer for a while, will probably check back later today.

borkdude10:04:14

I'll take a look

borkdude10:04:23

Looks good to me. Maybe we should add some rudimentary tests?

πŸ‘ 1
teodorlu15:04:07

I've got to admit that I've never written tests for a shell script before. This seems to work: https://github.com/teodorlu/neil/blob/0a415ee9724d3cfa72be0eaf84b9759ec8150055/tests.clj#L26-L35 Comments/suggestions?

borkdude15:04:16

Looks good!

borkdude15:04:36

One thing you may want to do is returns the right exit code based on failing tests

πŸ‘€ 1
borkdude15:04:42

and then we can run this in CI

teodorlu15:04:44

Right - now we're returning 0 regardless of test results.

borkdude15:04:55

run-tests returns a map

borkdude15:04:17

I usually do (System/exit (if (pos? (+ error fail)) 1 0)) or so

πŸ‘ 1
teodorlu16:04:39

in tests.clj or in bb.edn?

teodorlu16:04:15

looks like it must be in bb.edn.

borkdude16:04:32

you could also do (throw (ex-info "Tests failed" {:babashka/exit 1}))

borkdude16:04:38

from the test script

πŸ‘ 1
teodorlu16:04:22

Is there a good reason / convention to throw error in tests.clj vs handle error code directly in bb.edn?

borkdude16:04:06

don't worry about it, we can tweak where there is a good reason

πŸ‘ 1
teodorlu16:04:28

It doesn't look like we need the

(load-file "neil")
line in tests.clj. The tests are working as expected if I remove the file. I think we're only calling out to neil through the CLI? https://github.com/teodorlu/neil/blob/65d5fccfebb869e7530d28e67e95111ef481799d/tests.clj#L10

borkdude16:04:23

neil is generated. the real source is in src right?

borkdude16:04:29

so we can test against that

teodorlu16:04:31

yes - neil is generated, the real source is in src/babashka/neil.clj. But the (load-file "neil") line doesn't seem to do anything. The existing tests use the babashka.tasks API to run neil as a process. If I remove the load-file line, nothing changes.

borkdude16:04:54

I can take a look later, I'm cooking dinner

borkdude16:04:10

I forgot we had tests already

teodorlu16:04:54

Yeah, I just added some lines to the existing test code.

borkdude16:04:36

If you think something can be removed, just remove it

borkdude16:04:47

We should have tests that fail if you remove something that should not be removed

teodorlu16:04:22

Removed - tests are still passing.

Benjamin09:04:22

helllo wasn't there a way to print out the shell command that curl is making?

Benjamin09:04:31

(def url "")

;; works
(curl/get (str "" (api-key)))

;; does not work
(curl/get
 url
 {:query-params
  {:module :account
   :action :balance
   :address "0x5A534988535cf27a70e74dFfe299D06486f185B7"
   :apikey (api-key)}})

borkdude09:04:32

yes, it's in the docs: :debug true

Benjamin09:04:47

I figured out my issue by looking at it now. The url was wrong. And I needed to use strings instead of keywords for the values

borkdude09:04:10

I think keywords should be supported, but maybe you're using an old version?

Benjamin09:04:06

5e8daabd18387b3b1d0b5983e84d32fe83429d90 I use

borkdude09:04:14

as a JVM dep?

borkdude09:04:50

so not in bb that is, right?

Benjamin09:04:57

yea its jvm

borkdude09:04:24

weird, it should work, I see an explicit coerce-key in the code

Benjamin09:04:30

;; works
(curl/get
    url
    {:debug true
     :query-params {:module "account"
                    :action "balance"
                    :address "0x5A534988535cf27a70e74dFfe299D06486f185B7"
                    :apikey (api-key)}})
;; doesn't work
(curl/get
    url
    {:debug true
     :query-params {:module :account
                    :action :balance
                    :address "0x5A534988535cf27a70e74dFfe299D06486f185B7"
                    :apikey (api-key)}})

Benjamin09:04:34

now the api in my use case wants me to put "," in between more "addresses" . When I try passing "foo,bar" as query param value it ends up url encoding the "," I have a feeling I need the ","~ nvm

genmeblog18:04:42

Is there any easy way to go from lein as a build/deploy tool to bb ? I've made some analysis and I use mainly install, deploy clojars, test, check, compile, clean, deps, codox . Maybe there is a ready to use bb.edn somewhere?

borkdude19:04:05

This is one example to do so: https://github.com/weavejester/build

πŸ‘ 1
teodorlu20:04:35

Looks like getting CI for neil is quite feasible - https://github.com/teodorlu/neil/runs/5808019270 I tried the babashka/babashka image first, but that took ages to download. Installing on a default ubuntu-latest seemed to work fine.

borkdude20:04:16

We don't have CI for neil yet? πŸ˜… Feel free to set it up :) Shall we continue in #babashka-sci-dev? That's where we discuss dev-related stuff :)

πŸ‘ 1
πŸ˜„ 1