This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-26
Channels
- # announcements (3)
- # architecture (53)
- # babashka (6)
- # beginners (101)
- # bitcoin (3)
- # calva (4)
- # cider (3)
- # clara (7)
- # cljdoc (2)
- # cljsrn (14)
- # clojure (104)
- # clojure-europe (96)
- # clojure-germany (21)
- # clojure-nl (6)
- # clojure-serbia (3)
- # clojure-spain (1)
- # clojure-uk (13)
- # clojuredesign-podcast (4)
- # clojurescript (14)
- # cursive (5)
- # data-science (19)
- # datomic (16)
- # emacs (15)
- # fulcro (33)
- # graalvm (5)
- # honeysql (3)
- # instaparse (2)
- # jobs (3)
- # lsp (82)
- # malli (2)
- # off-topic (11)
- # pedestal (4)
- # polylith (62)
- # practicalli (4)
- # shadow-cljs (56)
- # tools-deps (53)
- # vim (17)
- # xtdb (53)
I just ran into a small issue with org.clojure/tools.namespace
, where when used in a deps.edn
project would over-zealously by default load namespaces found in ~/.gitlibs
. Presumably because prior to tools.deps it was assumed deps found on the filesystem were most likely to be source code in your project and suitable for loading.
Would it make sense for tns to now by default ignore any paths found in ~/.gitlibs
?
I don’t understand - can you explain a repro in an ask.clojure question?
https://ask.clojure.org/index.php/10381/should-tools-namespace-repl-refresh-exclude-found-gitlibs
Incidentally this is easily fixed by explicitly setting tnsrepl/set-refresh-dirs
, but it did cause a colleague to get a very misleading stacktrace about a missing class from a namespace that his project wasn’t explicitly requiring.
I should add that they likely weren’t even fully aware they were using tns, because they were using integrant.repl/reset
(which uses it)
Cognitect’s test-runner
seems to be accumulating issues and PRs without getting any feedback from Cognitect. Is it just considered “done” or just very low priority right now I wonder? I was thinking it would be really nice to have a -X
entry point so that folks could leverage :exec-args
and, in particular, their ability to merge across aliases so you could specify generic options via your :test
alias (or :runner
alias, in my case) and then specific options in other aliases. This would clean up a bit of boilerplate in our monorepo scenario where subprojects all have aliases but we still need to specify --dir
via the command-line (since :main-opts
don’t merge — just last-one-wins).
Luckily the test
function in cognitect.test-runner
is public so writing a tiny :exec-fn
wrapper outside the runner is easy to do for now.
Just waiting for a cycle of attention
I’ll write the wrapper in our codebase for now and maybe submit a PR if/when test-runner
gets an attention cycle.
Go for it!
@seancorfield I'd love to see an example invocation that is "better" with -X
than with the -main
function
We have a test alias for each subproject that brings in the test code and dependencies for that subproject. Via -X
we can specify :exec-args {:dir #{"subproject/test"}}
which will merge with our :runner
alias which already has :exec-fn
and the default :exec-args
.
With -M
, :main-opts
do not merge so we either have to repeat the whole :main-opts
for every subproject -test
alias with just -d
changed, or we have to specify -d
on the command-line.
Before:
$ clojure -M:defaults:subproj:subproj-test:test:runner -d subproj/test
After:
$ clojure -X:defaults:subproj:subproj-test:test:runner
@seancorfield Do you store these long invocations in some separate bash script or Makefile? Or do you remember them from the top of your head?
I'm currently considering a task runner which is supposed to solve this problem (of not having to remember these things)
We have a build
shell script that turns build test subproj
into the above command. But now that we have a primary deps.edn
file at the top of our monorepo, it’s easy enough to run most things with the CLI directly (for single command invocation).
The build
script supports multiple commands so we could say build tests subproj1 subproj2
and it runs two clojure
commands.
The example after -X is still pretty long, too long for me to remember without a bash history probably
That can happen when I switch systems yes, I have multiple laptops. But even then, fetching from history comes up with similar invocations and not always the one I'm looking for right away, unless I remember it more or less correctly. Hence, something like a task runner (something like make) could be nice
But also for making these invocations known to colleagues, contributors, etc, you don't want to depend on history
maybe; I am skeptical of lot of this additional tooling stuff. shells already support most of these things
you don't write any docs for your colleagues how to invoke the tests like Sean showed? I would have a hard time figuring that out by only looking at deps.edn
it is already the case that I almost never type a command in full into my shell, I pull it out of history and maybe edit it
yeah, I mean, he does a lot of work on the tooling, so documentation wise it is way more likely to be written for me then by me :)
Just as an example: https://github.com/borkdude/antq/blob/bb.edn/bb.edn (ported from this Makefile: https://github.com/borkdude/antq/blob/bb.edn/Makefile)
Like, the whole deal about makefiles is it tracks dependencies between files and has tasks that generate files
This task dsl is gross too. To impose a restrictive dsl without getting anything out of it (like dependency tracking) is silly. If you aren't doing extra stuff (dependency tracking, staleness tracking, rebuilding, etc) the just use normal clojure functions
This isn't my makefile btw, I just scouted some makefiles in the wild, and what I mostly see is that people just use it as a way to quickly invoke it from the command line. It's clear that you don't see the value of this, that was already clear in our earlier conversation. Thanks for the feedback.
Now ported the tasks to normal functions:
https://github.com/borkdude/antq/blob/bb.edn/script/tasks.clj
The code longer, but more flexible, so that may the way to go indeed.
Tasks can be discovered using (maybe warrants a bb dir
CLI option) :
$ bb -e "(require 'tasks) (clojure.repl/dir tasks)"
clean
coverage
deploy
docker
docker-test
install
jar
jar-file
lint
outdated
pom
repl
standalone-jar-file
tests
uberjar
Tasks can be invoked using:
bb -m runner/coverage
Docs:
$ bb doc tasks/coverage
-------------------------
tasks/coverage
([])
Run test coverage.
We’re not going to invest more work in pipelining this stuff until we’ve seen tools.build
released.
I’m anticipating being able to replace our build
shell script with a tools.build
invocation 🤞:skin-tone-2: 😸
Based on what Alex has said publicly about tools.build
, I would expect it to include “task runner” functionality (and some “standard” tasks). ISTR he’s already mentioned that it will add Java compilation as a task?