Fork me on GitHub
#babashka
<
2024-03-06
>
jerger_at_dda12:03:17

Do someone know an existing specialized devops build (drives tools like docker, kubectl, c4k-*, helm, aws-cli, terraform, gopass, provs) on top of babashka? If no I am thinking about doing a rewrite from python-pyb to bb: https://repo.prod.meissa.de/meissa/dda-devops-build/src/branch/clj-bb-rewrite

👀 1
jerger_at_dda17:03:02

Okay, first POC is up and running & feels good 🙂

jerger_at_dda17:03:08

But test make some problems: If I use normal deps-test the bb-specific namespaces can not be resolved

(ns dda.devops-build.image
  (:require ...
            [babashka.tasks :as t])
(see https://repo.prod.meissa.de/meissa/dda-devops-build/src/branch/clj-bb-rewrite/src/main/clj/dda/devops_build/image.clj#L3) Is there a bb-way run tests?

jerger_at_dda13:03:55

just in time 🙂

borkdude13:03:17

I didn't notice your (separate) question since I didn't look past your first question to which I didn't have an answer

jerger_at_dda13:03:03

https://repo.prod.meissa.de/meissa/dda-devops-build/src/branch/clj-bb-rewrite/bb.edn Works like a charm 🙂 In this case it will make sense to keep only the main paths & deps in deps.edn and the testing-stuff in bb.edn I assume?

jerger_at_dda15:03:43

thx for your nice help ... and for the cool work :-)

❤️ 1
Ingy döt Net16:03:24

Does bb do anything special for its native-image build to get (System/getenv) to see the whole calling environment?

Ingy döt Net16:03:03

From a native-image I get only:

$ ys -Ye 'ENV.keys()'
- HOME
- USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM
- PATH
- PWD
- LANG
but with jvm I get my entire environment. $ bb -e '(System/getenv)' gets everything.

Ingy döt Net16:03:07

I set ENV with:

(sci/intern @ys/sci-ctx 'clojure.core 'ENV (into {} (System/getenv)))

Bob B17:03:23

Is that set maybe happening at build time?

☝️ 1
Ingy döt Net18:03:36

unless I really don't understand something. It looks like a purposefully minimal env but I just noticed USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM

Ingy döt Net18:03:53

that's probably a key worth googling

Ingy döt Net18:03:34

If I run the jar in the JVM it works fine

Ingy döt Net18:03:08

but I think I need to enable something in the native-image build setup

Ingy döt Net18:03:27

Having trouble finding what

lread18:03:30

Can you show us where/how you are calling (System/getenv)? Just to rule out build time vs runtime.

Ingy döt Net18:03:24

You can repro this with:

git clone [email protected]:yaml/yamlscript
cd yamlscript/
. .profile 
YS -pe ENV
make -C ys build
ys/bin/ys -pe ENV

Ingy döt Net18:03:20

$ type YS
YS is a function
YS () 
{ 
    ( set -e;
    base=$YAMLSCRIPT_ROOT/ys;
    libyamlscript_version=0.1.39;
    jar=yamlscript.cli-$libyamlscript_version-SNAPSHOT-standalone.jar;
    make --no-print-directory -C "$base" jar;
    java -jar "$base/target/uberjar/$jar" "$@" )
}

lread18:03:57

I can't easily make sense of or execute the above repro.

Ingy döt Net18:03:42

You can run those 6 commands verbatim

lread18:03:32

$ . .profile 
.: no such file or directory: .profile

Ingy döt Net18:03:29

cd you not cd into the clone?

Ingy döt Net18:03:10

oh. source .profile 😕

lread18:03:32

could be my shell, ya

lread18:03:07

. ./.profile does not return an error

lread18:03:34

Ok, running your YS -pe ENV and that seems to be downloading graalvm!

lread18:03:58

I already have that installed tho... are you getting me into trouble here? simple_smile

lread19:03:34

pinky swear?

Ingy döt Net19:03:46

it downloads graal and lein into /tmp/yamlscript/ and ignores anything else you use

Ingy döt Net19:03:16

it will work on any system java installed or not

1
Ingy döt Net19:03:16

I appreciate you digging. Was hoping this was something @U04V15CAJ knew off the top of his head. I'm writing my YS talk for tomorrow night and no tuits to dig on this 😞

lread19:03:42

Well, they have suggested the usual cause of confusion above.... build time vs runtime. Oh. Right. You are calling (reset!...) when the namespace loads. So that will happen a build time,ya?

lread19:03:36

Oh wait my eyeballs didn't work.

lread19:03:07

Ok, Loaded in emacs, so I can better see indentation! Ya, System/getenv is called when ns loads.

lread19:03:12

So build time.

Ingy döt Net19:03:38

Right:

$ (cd /tmp; ys -pe CWD)
"/home/ingy/src/yaml/yamlscript/ys"

Ingy döt Net19:03:59

that was supposed to be /tmp

lread19:03:32

No prob, sometimes those blind spots just need another set of eyeballs.

Ingy döt Net19:03:45

I really appreciate you doing this @UE21H2HHD I owe you one!

Ingy döt Net19:03:45

And thanks too @U013JFLRFS8 I really didn't understand something 🙂

Ingy döt Net19:03:47

I think I actually had this right before but refactored without the right tests

lread19:03:03

Things happen. Glad you are sorted out!

Ingy döt Net19:03:21

$ (cd /tmp && FOO=123 ys -e 'say: "FOO=$(ENV.FOO) cwd=$CWD"')
FOO=123 cwd=/tmp

🎉 2
Ingy döt Net19:03:52

To see that as Clojure:

$ ys -ce 'say: "FOO=$(ENV.FOO) cwd=$CWD"'
(+++ (say (str "FOO=" (__ ENV 'FOO) " cwd=" CWD)))

Pagoda 5B17:03:28

Hello people, I have a basic question on using future-call from babashka, namely does it uses the standard threadPool? I'm asking just for confirmation: when I run it, it looks like the operations are still sequential and not executed concurrently

Bob B18:03:59

the future-call var is copied straight over from core, so I don't see a reason it should work any differently from JVM Clojure

🙏 1
gratitude 1