This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-16
Channels
- # adventofcode (24)
- # announcements (3)
- # aws (3)
- # babashka (16)
- # beginners (88)
- # biff (5)
- # calva (27)
- # cider (15)
- # cljs-dev (70)
- # clojure (87)
- # clojure-austin (3)
- # clojure-belgium (6)
- # clojure-europe (59)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojure-uk (3)
- # clojurescript (37)
- # data-science (2)
- # datalevin (40)
- # datomic (1)
- # emacs (23)
- # events (2)
- # graalvm (13)
- # graphql (7)
- # gratitude (1)
- # holy-lambda (193)
- # inf-clojure (15)
- # lsp (27)
- # malli (9)
- # off-topic (20)
- # polylith (6)
- # reitit (29)
- # releases (2)
- # scittle (13)
- # shadow-cljs (51)
- # transit (15)
- # xtdb (29)
Is migrating canary to GitHub Actions viable and of interest? I can take a look if you like.
I have received a clj-kondo report in which clj-kondo marks Foo.Bar
as unused in this example:
(ns script
(:require ["./foo" :refer [Foo Foo.Bar]]))
(prn Foo)
(prn Foo.Bar)
Is :refer [Foo.Bar]
even supported?
I would have expected this example to have worked without referring Foo.Bar
since in JS you can write this as:
import { Foo } from './foo.js';
console.log(Foo);
console.log(Foo.Bar);
and import { Foo, Foo.Bar } from "./foo.js"
doesn't even work.yes, I was just going to say I only tested this with shadow-cljs since I didn't even know how to import a local JS file with vanilla CLJS, but this isn't very relevant here, the original report did this with a normal npm lib:
(ns headless-ui
(:require ["@headlessui/react" :refer [Dialog Dialog.Overlay]]))
(defn modal-overlay [_]
(into [:> Dialog.Overlay {:class-name "fixed"}]))
technically the Dialog
refer already covers Dialog.Overlay
, as such cljkondo is correct
but without Foo.Bar
in :refer
you get this in shadow-cljs:
file:///private/tmp/dudejs/out/cljs-runtime/script.js:4
cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([Foo.Bar], 0));
^
ReferenceError: Foo is not defined
yes, there is a warning during compilation:
------ WARNING #1 - :undeclared-var --------------------------------------------
File: /private/tmp/dudejs/src/script.cljs:5:6
--------------------------------------------------------------------------------
2 | (:require ["./foo" :refer [Foo #_Foo.Bar]]))
3 |
4 | (prn Foo)
5 | (prn Foo.Bar)
------------^-------------------------------------------------------------------
Use of undeclared Var script/Foo
@U05224H0W Do you want an issue for this case?
the fact that its a local JS require shouldn't matter, behaviour for any require should be the same
Is the fact that it's a JS library at all relevant? E.g. (:require [foo :refer [foo.bar])
?
but :refer against cljs namespaces is checked in the analyzer data, so might yield errors
For a CLJS namespace this already works:
(ns script
(:require #_["./foo" :refer [Foo #_Foo.Bar]]
[bar :refer [Foo]]))
(prn Foo)
(prn (.-Bar Foo))
(prn :dude 1)
clj -M:cljs -m cljs.main -t node -c script
complains about window not being defined, how do I do this againWith:
clj -M:cljs -m cljs.main -t node -m script
it still works, that's not a REPL right?don't know if you got the above message, went through an area with bad internet, I'm on a train right now
With:
clj -M:cljs -m cljs.main -t node -m script
it still works, that's not a REPL right?@U04V15CAJ thank you!
@U05224H0W thank you π
@alexmiller sorry to be clear the matrix would be set up in GH as a Clojure repo, not the Clojure build box - no need to burden you
but I believe the set of libraries / tools that are popular is relatively stable and we should know that some change isnβt going to affect something a lot of people use
yeah, definitely open to that - is this a thing that already exists elsewhere I can look at?
I think it runs in Travis, but I think we can convert the whole thing into GH actions
I guess one consideration would be what the cost is in github action minutes, but I assume that's probably not a big deal
IIRC The existing canary scripts even work by triggering tests on the library project itself, so the library will cover CI minutes themselves, and the Canary jobs are just used to trigger those jobs and build the reports.
https://github.com/cljs-oss/canary/blob/master/runner/src/canary/projects/binaryage.clj
@juhoteperi I suppose that means the libraries that want to participate have to be setup?
doesn't that seem potentially bad to be charging people CI minutes?
@dnolen Yes. Though I think there were some forks previously for that purpose (https://github.com/cljs-oss/canary/commit/16de8e6fb1eb1a32b5ec364dbaad2fd1b2d80676) or maybe just non-library-project Travis projects for the libraries. I think the idea is good, if we want to run the same test suite as the library is running itself with the same tools. But is could be simpler and good enough to just clone projects and run some tests, should be possible if the project tests are easy enough to run without specific test runners etc.
@alexmiller It is possible. Depends on the project, e.g., for Reagent the credits Github provides for OS projects is more than enough even if there was double the builds, but some projects are probably using more minutes.
this seems like a weird way to go about this to me
given a project, seems like if you know: a) how to force a specific CLJS version b) command to run a test suite c) how to verify test success then the canary process can clone and do a/b/c for every known project
I've been considering setting up a similar thing for Clojure
Step b) could include installing test runner like lein-doo, kaocha, shadow-cljs and/or npm packages like karma which can be make that part a bit more complicated. But it might be indeed enough to only support some runners.
FWIW, babashka runs a ton of library test suites (from the wild) on every commit as part of its own CI
I'm using gitlibs to pull the test code and add it to the classpath, then run the tests within the newly compiled bb
is that a setup that could be borrowed? :)
This is the central part of that code: https://github.com/babashka/babashka/blob/965c177bca31ae9882c975ef7db448e12f59984e/test-resources/lib_tests/babashka/run_all_libtests.clj#L56-L68 I look at a config file which describes which libraries to run tests for. They are present as git libs, so then I find their test directories (as described in the config file), add them to the classpath, and then run.
ok, I might take a look at this next week
Perhaps also of interest: I do canary testing on each commit to rewrite-clj by running canary libs' tests. Canaries are current official lib releases (bumped manually by me). Fwiw, here's the https://github.com/clj-commons/rewrite-clj/blob/main/script/test_libs.clj. The https://github.com/clj-commons/rewrite-clj/blob/main/.github/workflows/libs-test.yml runs canary libs tests in parallel.