Fork me on GitHub
#clojurescript
<
2020-01-29
>
Oliver George04:01:14

I'm trying to add a simple ClojureScript test runner in my CircleCI build process - it works but I have to throw to get an exit code which circleci can see to abort the build process when my tests fail. Can someone suggest a better approach?

dazld13:01:26

you could look into the malli build steps - itโ€™s really well done, https://github.com/metosin/malli

dazld13:01:32

uses kaocha-cljs

dazld13:01:54

and the junit-xml plugin to get nicely formatted test failures in circle

Oliver George22:01:58

Thanks, I'll check it out.

Oliver George04:01:18

Here's what I've got:

Mathieu Pasquet06:01:36

Hi Guys ๐Ÿ‘‹. I can't really wrap my head around how shadow-cljs handles dependencies. All I really want to do is use [this library](https://github.com/mrmcc3/tailwind-clj) in my project. How can I do that? I tried using deps.edn, but now I can't even start shadow-cljs at all with the following config: shadow-cljs.edn

{:deps true
 :dev-http {8700 "target/"}
 :builds {:app {:output-dir "target/js"
                :asset-path "/js"
                :target :browser
                :build-hooks [(costa.utils.build/tailwind)]
                :modules {:costa {:init-fn costa.main/main!}}
                :devtools {:after-load costa.main/reload!}}}}
and deps.edn
{:paths ["src"]
 :deps {thheller/shadow-cljs {:mvn/version <latest>}
        mrmcc3/tailwind-clj {:git/url ""
                             :sha     "67dc8999aef155dc197b4f207932b658e4496d39"}
        re-frame {:mvn/version <latest>}}}
When I try run npx shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.4 watch :app I get the following error:
shadow-cljs - config: /app/shadow-cljs.edn  cli version: 2.8.83  node: v10.16.3
shadow-cljs - starting via "clojure"
Error building classpath. class clojure.lang.Symbol cannot be cast to class java.lang.CharSequence (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.CharSequence is in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class clojure.lang.Symbol cannot be cast to class java.lang.CharSequence (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.CharSequence is in module java.base of loader 'bootstrap')
        at clojure.core$re_matcher.invokeStatic(core.clj:4849)
        at clojure.core$re_find.invokeStatic(core.clj:4898)
        at clojure.core$re_find.invoke(core.clj:4898)
        at clojure.tools.deps.alpha.util.maven$version_range_QMARK_.invokeStatic(maven.clj:241)
        at clojure.tools.deps.alpha.util.maven$version_range_QMARK_.invoke(maven.clj:239)
        at clojure.tools.deps.alpha.extensions.maven$eval730$fn__733.invoke(maven.clj:47)
        at clojure.lang.MultiFn.invoke(MultiFn.java:239)
        at clojure.tools.deps.alpha$canonicalize_deps$fn__1166.invoke(alpha.clj:68)
        at clojure.core.protocols$iter_reduce.invokeStatic(protocols.clj:49)
        at clojure.core.protocols$fn__8140.invokeStatic(protocols.clj:75)
        at clojure.core.protocols$fn__8140.invoke(protocols.clj:75)
        at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
        at clojure.core$reduce.invokeStatic(core.clj:6828)
        at clojure.core$reduce.invoke(core.clj:6810)
        at clojure.tools.deps.alpha$canonicalize_deps.invokeStatic(alpha.clj:67)
        at clojure.tools.deps.alpha$canonicalize_deps.invoke(alpha.clj:65)
        at clojure.tools.deps.alpha$resolve_deps.invokeStatic(alpha.clj:235)
        at clojure.tools.deps.alpha$resolve_deps.invoke(alpha.clj:216)
        at clojure.tools.deps.alpha.script.make_classpath2$create_classpath.invokeStatic(make_classpath2.clj:56)
        at clojure.tools.deps.alpha.script.make_classpath2$create_classpath.invoke(make_classpath2.clj:48)
        at clojure.tools.deps.alpha.script.make_classpath2$run_core.invokeStatic(make_classpath2.clj:82)
        at clojure.tools.deps.alpha.script.make_classpath2$run_core.invoke(make_classpath2.clj:73)
        at clojure.tools.deps.alpha.script.make_classpath2$run.invokeStatic(make_classpath2.clj:102)
        at clojure.tools.deps.alpha.script.make_classpath2$run.invoke(make_classpath2.clj:96)
        at clojure.tools.deps.alpha.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:147)
        at clojure.tools.deps.alpha.script.make_classpath2$_main.doInvoke(make_classpath2.clj:119)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.core$apply.invokeStatic(core.clj:665)
        at clojure.main$main_opt.invokeStatic(main.clj:514)
        at clojure.main$main_opt.invoke(main.clj:510)
        at clojure.main$main.invokeStatic(main.clj:664)
        at clojure.main$main.doInvoke(main.clj:616)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:40)
I'm running in docker (`clojure:openjdk-14-alpine`) with npm installed in my dockerfile.

p-himik07:01:59

With :deps true, you have to specify :paths in deps.edn instead of :source-paths in shadow-cljs.edn.

Mathieu Pasquet07:01:08

Sorry, that was just me messing around with things to try troubleshoot. I did originally have :paths in deps.edn as expected. I'll update the post to reflect how things were.

p-himik07:01:07

Ah, right. Notice the clojure.tools.deps.alpha.util.maven$version_range_QMARK_ in there. And then check your version for thheller/shadow-cljs.

p-himik07:01:50

By <latest>, shadow-cljs documentation just means that you should put the latest version of shadow-cljs there yourself.

Mathieu Pasquet07:01:14

aaaaaah. :man-facepalming: Let me try that..

p-himik07:01:02

@U05224H0W Do you think it would be worth it to specify in the documentation that <latest> is just a placeholder and not an actual value that should be in there?

Mathieu Pasquet07:01:41

So yeah, that was the issue ๐Ÿ˜‘. Thanks for your help! re: the <latest> thing in the docs, it's not really a shadow-cljs issue, it's more of a deps.edn thing that I should've known about. However, in my defence, there isn't actually a section on how deps.edn parses those deps instructions that I could find anywhere.

Mathieu Pasquet07:01:06

[this page](https://clojure.org/guides/deps_and_cli) for example doesn't even mention sourcing libs from maven/clojars at all...

p-himik08:01:27

What do you mean? The whole page talks specifically about Maven and Git.

p-himik08:01:32

This is a reference to the deps.edn file, a bit more information dense than the guide that you linked: https://clojure.org/reference/deps_and_cli

thheller08:01:53

oh yeah should probably clarify that. I think deps.edn actually allows "LATEST" as version, maybe I should use that

p-himik08:01:24

I know that "RELEASE" can cause some cache issues. I.e. tools.deps won't check for a new version - it will just use the latest release available in the .m2. I have no idea whether "LATEST" has the same issue - maybe it's worth finding it out.

Mathieu Pasquet08:01:11

@U2FRKM4TW, you're right that the whole page is about git and maven, but if you come to that page with the question "How do I use a library from clojars?", it's not immediately apparent. You have to kinda put together the puzzle pieces. On the other hand, I may just be thick...

Mathieu Pasquet08:01:21

This bit from the second page you linked help answer the question a lot better imo > The deps are a map of library to coordinate. The library is (in Maven terms) the groupId and artifactId, which are sufficient to locate the desired project. The coordinate is used to describe a particular version that is being requested from a particular provider (like Maven).

p-himik08:01:47

And it doesn't make sense to add info about Clojars in there. Clojars is just a particular instance of a Maven repository. Maven Central is another one. And there are many, many others. It wouldn't make sense to describe them all in the tools.deps documentation - you just have to know whether what you're using is a Maven repository or not.

Mathieu Pasquet08:01:20

I see your point ๐Ÿ™‚

Wilson Velez19:01:10

I hope you can point me in the right direction, I am working on re-frame app, there is column to mark favorites, I want this favorite thing to be a separate component because Iโ€™m planning to use it in another component, how I do that? is there any tutorial?

aarkerio19:01:39

there is a #re-frame channel, surely they can help you.

jjttjj23:01:54

I got stuck on this for a bit https://github.com/cognitect/transit-cljs/issues/48 , adding the newer transit-js dep to my project fixed it as described, but anyone know why the project.clj in the transit-cljs repo says version "0.8.243" and DOES include the correct transit-js dep, but when including version "0.8.256" in my own project it brings in an older version of transit-js ?

alexmiller23:01:02

Because the pom is the real build file