This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-20
Channels
- # announcements (30)
- # babashka (118)
- # beginners (23)
- # calva (68)
- # cljdoc (10)
- # clojars (13)
- # clojure (90)
- # clojure-bangladesh (1)
- # clojure-europe (27)
- # clojure-gamedev (1)
- # clojure-nl (11)
- # clojure-uk (4)
- # clojurescript (59)
- # community-development (3)
- # cursive (13)
- # datomic (39)
- # defnpodcast (1)
- # emacs (10)
- # figwheel-main (1)
- # fulcro (18)
- # graalvm (21)
- # honeysql (1)
- # introduce-yourself (1)
- # juxt (1)
- # lsp (197)
- # malli (19)
- # off-topic (28)
- # practicalli (2)
- # re-frame (42)
- # reagent (4)
- # reitit (7)
- # releases (2)
- # sci (35)
- # shadow-cljs (13)
- # spacemacs (4)
- # vim (3)
yeah, we could support ^:babashka/tasks
as metadata as a pre-condition to make this file executable or so
but having the option of putting it on path and having it available globally would be a big plus indeed
but if you want to distribute that, that would be two things to download: the bash wrapper + the bb.edn
bb install --url https://raw.github.com/foobar/bb.edn --as unwordle ;)
yeah, I think we can work that out, e.g. choosing bash, zsh or whatever is available
babashka tasks install -g https://....
babashka tasks merge https://....
merge would merge remote tasks into the current projectI've already considered merge
in an issue by weavejester, it comes with some caveats like naming conflicts
for merge and conflicts: how about the default behaviour is to fail on conflict and have additional cmd-line opts like --overwrite task-a,task-b
--keep-existing task-c
?
i like the wrapper generator because it would be a consistent way to create standard cli tooling
I have a build
script in my bin folder like this:
#!/usr/bin/env bash
bb --config $HOME/build/bb.edn [email protected]
where $HOME/build/bb.edn
is a git clone of https://github.com/weavejester/build
this also requires a little hammock time since the project bb.edn might not always be the exported bb.edn
{:tasks {a ^:export (do something)}}
would be possible i guess, but i think you’re right, it’s more consistent requiring the map version here
maybe unrelated but i would settle for https://github.com/clojure/tools.deps.alpha/blob/f96c0baae1a07ab1c0f914d7baea8c8de2e427eb/src/main/clojure/clojure/tools/deps/alpha.clj#L106 to find bb.edn so when i run bb task it will look in some global bb.edn
i see, if you make logic to find bb.edn more advance, it would be just curl bb.edn and then bb tasks
hello hello, everyone! i'd like to know if there is any way to declare a variable before babashka tries to load dependencies. i'm trying to get babashka to run some [kaocha's](https://github.com/lambdaisland/kaocha) tests without the overhead of using lein
in the command line (i'm on a project that already has lein
setup for tests, it would not be ideal to replicate the lein
test setup to run a couple of tests using clj
in a very specific workflow), but it complains that the symbol *clojure-version*
isn't defined. i tried doing it as
BABASHKA_PRELOADS='(def *clojure-version* "1.10.3.1058")' bb -m pre-push
but that still fails. is the only way asking/contributing to kaocha to make it run with babashka?also great work on it, folks! babashka is a very amazing tool!!!
@jpedrodeamorim you can do this indeed via preloads, but are you trying to run tests written for babashka code or for jvm code?
for JVM code
i'm trying to define a pre-push
script to be run on GitHub hooks to test only the files changed
you have to do a more advanced analysis as namespaces can depend on each other. there is a tools namespace port available for babashka: https://github.com/babashka/tools.namespace
hmmm ok, makes sense
i was already eying tools.namespace
I've written babashka code for a similar problem at nextjournal where we cache CLJS builds if the code hasn't changed
would the code for that be available anywhere? sounds like it intersects a lot with what i'm trying to accomplish indeed
the code isn't public but I bet @mkvlr doesn't mind if I share this function:
(defn cljs-files
"Returns CLJS files + CLJ files that contain related macros from dirs."
[dirs]
(let [cp-dirs dirs
direct-inputs (mapcat #(glob-sources % "**.{cljs,cljc}") cp-dirs)
cljs-namespaces (map ns-file/read-file-ns-decl direct-inputs)
cljs-deps (set (mapcat ns-parse/deps-from-ns-decl cljs-namespaces))
clojure-files (find-clojure-files cp-dirs cljs-deps)
;; The assumption is that macro namespaces do not have dependencies on
;; other .clj namespaces. So far that assumption seems to hold.
macro-files (keep #(when (str/includes? (slurp %) "defmacro")
%) clojure-files)]
(println "Macro namespaces: "macro-files)
(concat direct-inputs macro-files)))
i could also look into using plain clojure.test
for it as well, instead of kaocha, given that we only want to run unit tests on pushes. integration and more complicated test suites are only run on merges
so you have to fiddle a bit with ns-parse/deps-from-ns-decl and calculate some transitive tree of namespaces
so if you make a change in namespace X and X is used in Y, you'll also have to run the tests for Y
it's a tricky problem since this is assuming that testing is based on namespace organization
yup, i'm trying to build some ad-hoc dependency tree for that purpose
thank you for sharing the code
hey, sorry to bother again
but i'm trying to use babashka's fork of tools.namespace
but i'm getting a Could not resolve symbol: *clojure-version*
😕
of course
here is bb.edn:
{:paths ["script"]
:tasks
{pre-push {:extra-paths ["test"]
:extra-deps {org.clojure/tools.namespace
{:git/url ""
:git/sha "56088a1e6fa8a87683c8c13a93d37af39ef8ccc9"}}
:requires ([pre-push])
:task (pre-push/-main)}}}
and on the pre-push file i have
(ns pre-push
(:require
[clojure.tools.namespace.parse :as ns-parse]))
(defn -main []
(ns-parse/read-ns-decl "foo.clj"))
running bb run pre-push
gives the following error:
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: *clojure-version*
Location: clojure/tools/reader/impl/utils.clj:17:35
Phase: analysis
do you need more info?
all right
i have also tried using preloads, defining *clojure-version*
as a dynamic var and normally, but still the same error comes up
And then this works:
(ns pre-push
(:require
[clojure.tools.namespace.parse :as ns-parse]
[ :as io]))
(defn -main []
(prn (ns-parse/read-ns-decl (java.io.PushbackReader. (io/reader "script/pre_push.clj")))))
this prints:
(ns pre-push (:require [clojure.tools.namespace.parse :as ns-parse] [ :as io]))
that does it
could you explain what was the problem?
i was using the SHA for one of the tags. was that a SHA for the original, unforked lib?
all right, that explains it