New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #292: babashka compatibility #293
Conversation
Note that the test runner requires a recent version of babashka (as babashka only recently became compatible with eftest). |
Very cool. Quick benchmark: numbers_of_files runtime_in_seconds
Due to startup overhead, clojure takes 9.3x time compared to bb for 1 file. At 128 files, clojure overtakes bb and now takes 0.8x of bb's time. Conclusion: bb is much faster if you're only checking a small number of files (e.g. on save in an editor or in a pre-commit git hook) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I'd rather not manage two different CI solutions, so either we convert everything over to GitHub Actions (or Circle CI) in another PR, or we instead use Travis. Equally, I think we'd want to split out deps.edn into another PR if its absolutely necessary (again, I'd rather maintain one dependency file than two).
cljfmt/src/cljfmt/main.clj
Outdated
(defmacro if-bb [then else] | ||
(if (System/getProperty "babashka.version") | ||
then else)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this is a macro, instead of something like:
(def bb? (boolean (System/getProperty "babashka.version")))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that if you prefer, but imo it's cleaner to not have any side effects of macro-expansions in conditionals happening at all, which can only be prevented by using another macro. But in this case it's probably ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Babashka have a reader conditional in that case? i.e. would #?(:bb ...)
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weavejester I solved this using a more elegant solution: I added a .bb
file (which is always loaded first in bb) with the same namespace and vars so the main
namespace doesn't need any changes. A reader conditional would have worked, but then we'd needed to rename the .clj
namespace to .cljc
.
My current inclination would be to migrate from Travis to GitHub Actions, I think. |
I can remove the I don't have time (nor desire) to learn Travis. |
Keep the GitHub Actions for now; I'll use it for reference as part of another PR. I've been meaning to switch a project over to GitHub Actions for evaluation, and this seems like a good opportunity to do so. |
@weavejester The only thing left is if you want to keep this I can generate it dynamically in CI to test bb or use |
@@ -1,5 +1,5 @@ | |||
(ns cljfmt.test-util.cljs | |||
(:require [cljs.test :as test] | |||
(:require [clojure.test :as test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was needed since bb loads this namespace during tests and cljs.test
isn't part of bb
. Loading clojure.test
also works in ClojureScript so this change doesn't change any behavior.
If you don't like the formatting of the generated |
Note that adding a |
The solution I've chosen uses |
To reduce friction even more, I just published a lein plugin for lein2deps: |
There was also a project that I recall did the opposite: given a Ultimately I'd like to move over to tools.deps, but Leiningen handles deploying to Clojars or other Maven repositories better than any tool I've discovered for tools.deps. I've been attempting to fix this, but it hasn't been particularly interesting work, and I've kept putting it off. |
I’d be happy to add a build.cllj file but this would be even a bigger change. I can get to a deployable project with build.clj in seconds since I shifted that uninteresting work to “neil add build”. Just let me know how to proceed and I’ll do it, or if you want, I’ll create another PR first to address this other issue, happy to help.
|
The tools.deps ecosystem isn't mature enough for me to switch, yet, so don't worry about it. Leiningen currently has better pom generation and GPG integration, last I checked, so I'm waiting for tools.deps to get up to par (or eventually, I'll fix it myself). |
Sure. Can you let me know how to finish up this PR?
|
Ah, sorry for the confusion, I should have been much clearer about my intent. I was planning on converting the repository over to GitHub Actions, then getting back to you. That's now done. Could you rebase against - name: Install clojure tools
uses: DeLaGuardo/setup-clojure@10.1
with:
lein: 2.9.10
bb: latest
- name: Run Leiningen tests
working-directory: ./cljfmt
run: lein test
- name: Run Babashka tests
working-directory: ./cljfmt
run: bb test My understanding is that Babashka requires Also, for now, I think it might make more sense for the Finally, could you squash all the commits and change the final commit message to:
This is just to make it more consistent with previous commits. |
Absolutely, will do :) |
213a989
to
d1e22d6
Compare
@weavejester Should be all good now. |
It seems I forgot to add bb in the github runner, will do it now. |
Done. If you can re-trigger CI once more, that would be great. |
Looks good! |
Thanks! |
Hi @weavejester - this fixes and tests babashka compatibility.
I took the liberty to add a generated
deps.edn
based off theproject.clj
. This makes testing this library as a babashka dependency easier but also benefitsdeps.edn
users as this library can be used as a git dep. To re-generate thedeps.edn
, all you have to do is runbb gen-deps
.Also added: a Github CI config file for testing this library with babashka. I did not know how to work with Travis.
cc @lread