From 7bc255218a174943825644c4eacc6295c5af0b54 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Wed, 27 Nov 2024 22:23:48 +0100 Subject: [PATCH 01/20] Fix failing tests and enable running tests on JVM This commit enables a JVM-based workflow. The tests that pass without modification on a JVM can now be run on a JVM. The tests that fail on JVM now only run on Babashka. In addition, test data has been updated to reflect the reality - per 2024-11-27, the latest version of org.babashka/http-server is 0.1.13. --- .gitignore | 2 ++ bb.edn | 3 +- bbin | 28 ++++++++++++----- bin/kaocha | 2 ++ bin/launchpad | 8 +++++ deps.edn | 8 ++++- dev/babashka/bbin/dev.clj | 2 +- src/babashka/bbin/scripts/common.clj | 9 +++--- src/babashka/bbin/scripts/maven_jar.clj | 6 ++-- src/babashka/bbin/util.clj | 9 ++++++ test/babashka/bbin/scripts/local_dir_test.clj | 28 +++++++++-------- test/babashka/bbin/scripts/maven_jar_test.clj | 30 ++++++++++--------- tests.edn | 1 + 13 files changed, 91 insertions(+), 45 deletions(-) create mode 100755 bin/kaocha create mode 100755 bin/launchpad create mode 100644 tests.edn diff --git a/.gitignore b/.gitignore index 27df335..d9e5b14 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ /checkouts /classes /target + +/deps.local.edn \ No newline at end of file diff --git a/bb.edn b/bb.edn index 57a3e40..d832170 100644 --- a/bb.edn +++ b/bb.edn @@ -3,7 +3,8 @@ :pods {org.babashka/fswatcher {:version "0.0.3"}} :deps {org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha" :git/sha "951b49b8c173244e66443b8188e3ff928a0a71e7"} - local/deps {:local/root "."}} + local/deps {:local/root "."} + com.lambdaisland/launchpad {:mvn/version "0.33.149-alpha"}} :bbin/bin {bbin {:main-opts ["-f" "bbin"]}} :tasks {bbin {:requires ([babashka.bbin.cli :as bbin]) :task (apply bbin/-main *command-line-args*)} diff --git a/bbin b/bbin index d3f8554..694c75c 100755 --- a/bbin +++ b/bbin @@ -17,7 +17,9 @@ org.babashka/http-client {:mvn/version "0.1.8"}, version-clj/version-clj {:mvn/version "2.0.2"}, babashka/fs {:mvn/version "0.3.17"}, - org.babashka/json {:mvn/version "0.1.1"}}}) + ring/ring-core {:mvn/version "1.13.0"}, + org.babashka/json {:mvn/version "0.1.1"}, + http-kit/http-kit {:mvn/version "2.8.0"}}}) (ns babashka.bbin.meta) (def min-bb-version "This def was generated by the bbin build script." "0.9.162") @@ -740,12 +742,21 @@ WARNING: (We won't make any changes without asking you first.) (defn snake-case [s] (str/replace s "_" "-")) +(defmacro whenbb [& forms] + (when (System/getProperty "babashka.version") + `(do ~@forms))) + +(defmacro ifbb [then else] + (if (System/getProperty "babashka.version") + then + else)) + (ns babashka.bbin.scripts.common (:require [babashka.bbin.deps :as bbin-deps] [babashka.bbin.dirs :as dirs] [babashka.bbin.specs] - [babashka.bbin.util :as util :refer [sh]] - [babashka.deps :as deps] + [babashka.bbin.util :as util :refer [sh whenbb]] + ;; [babashka.deps :as deps] [babashka.fs :as fs] [clojure.edn :as edn] [clojure.main :as main] @@ -1040,8 +1051,9 @@ WARNING: (We won't make any changes without asking you first.) header' (if (#{::no-lib} lib) {:coords {:bbin/url (str "file://" (get-in header [:coords :local/root]))}} header) - _ (when-not (#{::no-lib} lib) - (deps/add-deps {:deps script-deps})) + _ (whenbb (when-not (#{::no-lib} lib) + ((requiring-resolve 'babashka.deps/add-deps) + {:deps script-deps}))) script-root (fs/canonicalize (or (get-in header [:coords :local/root]) (local-lib-path script-deps)) {:nofollow-links true}) @@ -1249,8 +1261,7 @@ WARNING: (We won't make any changes without asking you first.) (:require [babashka.bbin.dirs :as dirs] [babashka.bbin.protocols :as p] [babashka.bbin.scripts.common :as common] - [babashka.bbin.util :as util] - [babashka.deps :as deps] + [babashka.bbin.util :as util :refer [whenbb]] [babashka.fs :as fs] [babashka.http-client :as http] [babashka.json :as json] @@ -1338,7 +1349,8 @@ WARNING: (We won't make any changes without asking you first.) (select-keys cli-opts [:mvn/version])} header {:lib (key (first script-deps)) :coords (val (first script-deps))} - _ (deps/add-deps {:deps script-deps}) + _ (whenbb ((requiring-resolve 'babashka.deps/add-deps) + {:deps script-deps}) ) script-root (fs/canonicalize (or (:local/root cli-opts) (common/local-lib-path script-deps)) {:nofollow-links true}) script-name (or (:as cli-opts) (second (str/split (:script/lib cli-opts) #"/"))) script-config (common/default-script-config cli-opts) diff --git a/bin/kaocha b/bin/kaocha new file mode 100755 index 0000000..7e3a18e --- /dev/null +++ b/bin/kaocha @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +clojure -M:kaocha "$@" diff --git a/bin/launchpad b/bin/launchpad new file mode 100755 index 0000000..d876e5a --- /dev/null +++ b/bin/launchpad @@ -0,0 +1,8 @@ +#!/usr/bin/env bb + +(require '[lambdaisland.launchpad :as launchpad]) + +(launchpad/main {}) + +;; (launchpad/main {:steps (into [(partial launchpad/ensure-java-version 17)] +;; launchpad/default-steps)}) \ No newline at end of file diff --git a/deps.edn b/deps.edn index d8ba291..bc03db0 100644 --- a/deps.edn +++ b/deps.edn @@ -4,11 +4,17 @@ com.taoensso/timbre {:mvn/version "5.2.1"} expound/expound {:mvn/version "0.9.0"} fipp/fipp {:mvn/version "0.6.26"} + http-kit/http-kit {:mvn/version "2.8.0"} org.babashka/cli {:mvn/version "0.6.43"} org.babashka/http-client {:mvn/version "0.1.8"} org.babashka/json {:mvn/version "0.1.1"} org.clojure/tools.gitlibs {:mvn/version "2.4.181"} + ring/ring-core {:mvn/version "1.13.0"} selmer/selmer {:mvn/version "1.12.55"} version-clj/version-clj {:mvn/version "2.0.2"}} :aliases {:neil {:project {:name babashka/bbin - :version "0.2.4"}}}} + :version "0.2.4"}} + :dev {:extra-paths ["test" "test-resources" "dev"] + :extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}} + :kaocha {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}} + :main-opts ["-m" "kaocha.runner"]}}} diff --git a/dev/babashka/bbin/dev.clj b/dev/babashka/bbin/dev.clj index ad44aef..76e8958 100644 --- a/dev/babashka/bbin/dev.clj +++ b/dev/babashka/bbin/dev.clj @@ -1,6 +1,6 @@ (ns babashka.bbin.dev (:require [babashka.process :refer [sh]] - [clojure.core.async :refer [ maven-lib :coords :mvn/version)}) - out2 (tu/run-upgrade {:script/lib "http-server"})] - (is (= maven-lib out)) - (is (= upgraded-lib out2)) - (is (fs/exists? (fs/file (dirs/bin-dir nil) (name (:lib upgraded-lib))))) - (is (str/starts-with? (tu/run-bin-script (:lib upgraded-lib) "--help") - help-text)) - (is (= `{~'http-server ~upgraded-lib} (tu/run-ls)))))) +(whenbb + (deftest upgrade-maven-jar-test + (testing "upgrade (maven jar)" + (tu/reset-test-dir) + (dirs/ensure-bbin-dirs {}) + (let [out (tu/run-install {:script/lib (str (:lib maven-lib)) + :mvn/version (-> maven-lib :coords :mvn/version)}) + out2 (tu/run-upgrade {:script/lib "http-server"})] + (is (= maven-lib out)) + (is (= upgraded-lib out2)) + (is (fs/exists? (fs/file (dirs/bin-dir nil) (name (:lib upgraded-lib))))) + (is (str/starts-with? (tu/run-bin-script (:lib upgraded-lib) "--help") + help-text)) + (is (= {'http-server upgraded-lib} (tu/run-ls))))))) diff --git a/tests.edn b/tests.edn new file mode 100644 index 0000000..9d8d845 --- /dev/null +++ b/tests.edn @@ -0,0 +1 @@ +#kaocha/v1 {} From 1b3f849d4a31505aa38711086cb0c463fb61f608 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 13:30:47 +0100 Subject: [PATCH 02/20] Sort babashka tasks alphabetically I generally prefer to keep maps like this sorted, I find things more easily then. If there was some previous structure here that I didn't pick up, I'll revert. --- bb.edn | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bb.edn b/bb.edn index d832170..f3fcf2d 100644 --- a/bb.edn +++ b/bb.edn @@ -8,9 +8,6 @@ :bbin/bin {bbin {:main-opts ["-f" "bbin"]}} :tasks {bbin {:requires ([babashka.bbin.cli :as bbin]) :task (apply bbin/-main *command-line-args*)} - dev {:doc "Starts watcher to auto-build bbin script" - :requires ([babashka.bbin.dev :as dev]) - :task (dev/dev)} ci {:doc "Run all CI tasks locally" :requires ([taoensso.timbre :as log]) :task (do @@ -18,17 +15,15 @@ (run 'lint) (log/info "bb run test") (run 'test))} - lint (shell "clj-kondo --lint .") - test {:depends [gen-script] - :extra-deps {io.github.cognitect-labs/test-runner - {:git/tag "v0.5.1" :git/sha "dfb30dd"} - ring/ring-core {:mvn/version "1.12.1"}} - :task cognitect.test-runner/-main} + dev {:doc "Starts watcher to auto-build bbin script" + :requires ([babashka.bbin.dev :as dev]) + :task (dev/dev)} gen-script {:doc "Build the bbin script" :extra-deps {org.clojure/tools.namespace {:mvn/version "1.5.0"}} :requires ([babashka.bbin.gen-script :as gen-script]) :task (gen-script/gen-script)} + lint (shell "clj-kondo --lint .") render-templates {:requires ([clojure.string :as str] [clojure.edn :as edn] [selmer.parser :as p] @@ -42,4 +37,9 @@ (without-escaping (->> (p/render (slurp "templates/README.template.md") {:version version}) - (spit "README.md"))))}}} + (spit "README.md"))))} + test {:depends [gen-script] + :extra-deps {io.github.cognitect-labs/test-runner + {:git/tag "v0.5.1" :git/sha "dfb30dd"} + ring/ring-core {:mvn/version "1.12.1"}} + :task cognitect.test-runner/-main}}} From 10392b30a6243d806008953aa31ebe88d098dc73 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 13:34:04 +0100 Subject: [PATCH 03/20] Use bb task instead of bin/ script for Launchpad --- bb.edn | 5 ++++- bin/launchpad | 8 -------- 2 files changed, 4 insertions(+), 9 deletions(-) delete mode 100755 bin/launchpad diff --git a/bb.edn b/bb.edn index f3fcf2d..b45ad9b 100644 --- a/bb.edn +++ b/bb.edn @@ -23,6 +23,8 @@ {:mvn/version "1.5.0"}} :requires ([babashka.bbin.gen-script :as gen-script]) :task (gen-script/gen-script)} + launchpad {:requires ([lambdaisland.launchpad :as launchpad]) + :task (launchpad/main {})} lint (shell "clj-kondo --lint .") render-templates {:requires ([clojure.string :as str] [clojure.edn :as edn] @@ -42,4 +44,5 @@ :extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"} ring/ring-core {:mvn/version "1.12.1"}} - :task cognitect.test-runner/-main}}} + :task cognitect.test-runner/-main} + ,}} diff --git a/bin/launchpad b/bin/launchpad deleted file mode 100755 index d876e5a..0000000 --- a/bin/launchpad +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bb - -(require '[lambdaisland.launchpad :as launchpad]) - -(launchpad/main {}) - -;; (launchpad/main {:steps (into [(partial launchpad/ensure-java-version 17)] -;; launchpad/default-steps)}) \ No newline at end of file From d1edb2ae5e912dda37cd36007272f588d303435c Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 13:35:38 +0100 Subject: [PATCH 04/20] Remove Kaocha, one test runner is enough Kaocha has become heavily ingrained into my workflow through https://github.com/magnars/kaocha-runner.el. kaocha-runner requires that kaocha is on the classpath in order to work. Though that doesn't require that I put Kaocha into every project I work with. Clojure 1.12's add-lib to the rescue! --- bin/kaocha | 2 -- deps.edn | 5 +---- tests.edn | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) delete mode 100755 bin/kaocha delete mode 100644 tests.edn diff --git a/bin/kaocha b/bin/kaocha deleted file mode 100755 index 7e3a18e..0000000 --- a/bin/kaocha +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env sh -clojure -M:kaocha "$@" diff --git a/deps.edn b/deps.edn index bc03db0..369a8be 100644 --- a/deps.edn +++ b/deps.edn @@ -14,7 +14,4 @@ version-clj/version-clj {:mvn/version "2.0.2"}} :aliases {:neil {:project {:name babashka/bbin :version "0.2.4"}} - :dev {:extra-paths ["test" "test-resources" "dev"] - :extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}} - :kaocha {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}} - :main-opts ["-m" "kaocha.runner"]}}} + :dev {:extra-paths ["test" "test-resources" "dev"]}}} diff --git a/tests.edn b/tests.edn deleted file mode 100644 index 9d8d845..0000000 --- a/tests.edn +++ /dev/null @@ -1 +0,0 @@ -#kaocha/v1 {} From 042f58f08f1d234af8b930d8825b70a1243a378a Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 13:49:43 +0100 Subject: [PATCH 05/20] Also remove Launchpad The way I'd added Launchpad in a previous commit in this PR would be bad for all bbin users: they would all be forced to download Launchpad. I don't want that. Launchpad is a development helper, it shouldn't carry weight that influences bbin users badly. So I'm removing Launchpad. We could possibly get around shipping Launchpad to bbin users by loading launchpad dynamically in the `bb launchpad` task, but that's not worth it for me for now. --- bb.edn | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bb.edn b/bb.edn index b45ad9b..8da111e 100644 --- a/bb.edn +++ b/bb.edn @@ -3,8 +3,7 @@ :pods {org.babashka/fswatcher {:version "0.0.3"}} :deps {org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha" :git/sha "951b49b8c173244e66443b8188e3ff928a0a71e7"} - local/deps {:local/root "."} - com.lambdaisland/launchpad {:mvn/version "0.33.149-alpha"}} + local/deps {:local/root "."}} :bbin/bin {bbin {:main-opts ["-f" "bbin"]}} :tasks {bbin {:requires ([babashka.bbin.cli :as bbin]) :task (apply bbin/-main *command-line-args*)} @@ -23,8 +22,6 @@ {:mvn/version "1.5.0"}} :requires ([babashka.bbin.gen-script :as gen-script]) :task (gen-script/gen-script)} - launchpad {:requires ([lambdaisland.launchpad :as launchpad]) - :task (launchpad/main {})} lint (shell "clj-kondo --lint .") render-templates {:requires ([clojure.string :as str] [clojure.edn :as edn] From c7664c7368b9b02cf55b83936c72a4152c438b6c Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:14:02 +0100 Subject: [PATCH 06/20] Undo reordering of tasks in bb.edn We didn't end up adding either Launchpad or Kaocha, so we might as well leave bb.edn unchanged. --- bb.edn | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/bb.edn b/bb.edn index 8da111e..57a3e40 100644 --- a/bb.edn +++ b/bb.edn @@ -7,6 +7,9 @@ :bbin/bin {bbin {:main-opts ["-f" "bbin"]}} :tasks {bbin {:requires ([babashka.bbin.cli :as bbin]) :task (apply bbin/-main *command-line-args*)} + dev {:doc "Starts watcher to auto-build bbin script" + :requires ([babashka.bbin.dev :as dev]) + :task (dev/dev)} ci {:doc "Run all CI tasks locally" :requires ([taoensso.timbre :as log]) :task (do @@ -14,15 +17,17 @@ (run 'lint) (log/info "bb run test") (run 'test))} - dev {:doc "Starts watcher to auto-build bbin script" - :requires ([babashka.bbin.dev :as dev]) - :task (dev/dev)} + lint (shell "clj-kondo --lint .") + test {:depends [gen-script] + :extra-deps {io.github.cognitect-labs/test-runner + {:git/tag "v0.5.1" :git/sha "dfb30dd"} + ring/ring-core {:mvn/version "1.12.1"}} + :task cognitect.test-runner/-main} gen-script {:doc "Build the bbin script" :extra-deps {org.clojure/tools.namespace {:mvn/version "1.5.0"}} :requires ([babashka.bbin.gen-script :as gen-script]) :task (gen-script/gen-script)} - lint (shell "clj-kondo --lint .") render-templates {:requires ([clojure.string :as str] [clojure.edn :as edn] [selmer.parser :as p] @@ -36,10 +41,4 @@ (without-escaping (->> (p/render (slurp "templates/README.template.md") {:version version}) - (spit "README.md"))))} - test {:depends [gen-script] - :extra-deps {io.github.cognitect-labs/test-runner - {:git/tag "v0.5.1" :git/sha "dfb30dd"} - ring/ring-core {:mvn/version "1.12.1"}} - :task cognitect.test-runner/-main} - ,}} + (spit "README.md"))))}}} From 5ea4d80b754b468a72b1bad309ed1c04c5a22e47 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:15:29 +0100 Subject: [PATCH 07/20] Clean up after removing Launchpad --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index d9e5b14..27df335 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,3 @@ /checkouts /classes /target - -/deps.local.edn \ No newline at end of file From 9a029897de8f9f9df256691c4291a5e452da0d43 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:18:38 +0100 Subject: [PATCH 08/20] Remove unused code --- src/babashka/bbin/util.clj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/babashka/bbin/util.clj b/src/babashka/bbin/util.clj index 9c648a2..718d51d 100644 --- a/src/babashka/bbin/util.clj +++ b/src/babashka/bbin/util.clj @@ -323,8 +323,3 @@ (defmacro whenbb [& forms] (when (System/getProperty "babashka.version") `(do ~@forms))) - -(defmacro ifbb [then else] - (if (System/getProperty "babashka.version") - then - else)) From ffce005abdb031afcde538c0862b0800fd7d9b96 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:49:46 +0100 Subject: [PATCH 09/20] Run JVM tests with bb test:clj --- bb.edn | 10 +++++----- bbin | 8 +------- deps.edn | 9 +++++++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bb.edn b/bb.edn index 57a3e40..2f442f8 100644 --- a/bb.edn +++ b/bb.edn @@ -19,13 +19,13 @@ (run 'test))} lint (shell "clj-kondo --lint .") test {:depends [gen-script] - :extra-deps {io.github.cognitect-labs/test-runner - {:git/tag "v0.5.1" :git/sha "dfb30dd"} - ring/ring-core {:mvn/version "1.12.1"}} + :extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"} + http-kit/http-kit {:mvn/version "2.8.0"} + ring/ring-core {:mvn/version "1.13.0"}} :task cognitect.test-runner/-main} + test:clj (clojure "-M:test") gen-script {:doc "Build the bbin script" - :extra-deps {org.clojure/tools.namespace - {:mvn/version "1.5.0"}} + :extra-deps {org.clojure/tools.namespace {:mvn/version "1.5.0"}} :requires ([babashka.bbin.gen-script :as gen-script]) :task (gen-script/gen-script)} render-templates {:requires ([clojure.string :as str] diff --git a/bbin b/bbin index 694c75c..cb3c256 100755 --- a/bbin +++ b/bbin @@ -18,8 +18,7 @@ version-clj/version-clj {:mvn/version "2.0.2"}, babashka/fs {:mvn/version "0.3.17"}, ring/ring-core {:mvn/version "1.13.0"}, - org.babashka/json {:mvn/version "0.1.1"}, - http-kit/http-kit {:mvn/version "2.8.0"}}}) + org.babashka/json {:mvn/version "0.1.1"}}}) (ns babashka.bbin.meta) (def min-bb-version "This def was generated by the bbin build script." "0.9.162") @@ -746,11 +745,6 @@ WARNING: (We won't make any changes without asking you first.) (when (System/getProperty "babashka.version") `(do ~@forms))) -(defmacro ifbb [then else] - (if (System/getProperty "babashka.version") - then - else)) - (ns babashka.bbin.scripts.common (:require [babashka.bbin.deps :as bbin-deps] [babashka.bbin.dirs :as dirs] diff --git a/deps.edn b/deps.edn index 369a8be..16dc310 100644 --- a/deps.edn +++ b/deps.edn @@ -4,7 +4,6 @@ com.taoensso/timbre {:mvn/version "5.2.1"} expound/expound {:mvn/version "0.9.0"} fipp/fipp {:mvn/version "0.6.26"} - http-kit/http-kit {:mvn/version "2.8.0"} org.babashka/cli {:mvn/version "0.6.43"} org.babashka/http-client {:mvn/version "0.1.8"} org.babashka/json {:mvn/version "0.1.1"} @@ -14,4 +13,10 @@ version-clj/version-clj {:mvn/version "2.0.2"}} :aliases {:neil {:project {:name babashka/bbin :version "0.2.4"}} - :dev {:extra-paths ["test" "test-resources" "dev"]}}} + :dev {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}} + :extra-paths ["test" "test-resources" "dev"]} + :test {:extra-deps {http-kit/http-kit {:mvn/version "2.8.0"} + io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"} + ring/ring-core {:mvn/version "1.13.0"}} + :extra-paths ["test" "test-resources" "dev"] + :main-opts ["-m" "cognitect.test-runner"]}}} From 3deff005a83beadd231f53dc8bb8e550cfb4af16 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:50:34 +0100 Subject: [PATCH 10/20] Remove Kaocha (again) --- deps.edn | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deps.edn b/deps.edn index 16dc310..d53789c 100644 --- a/deps.edn +++ b/deps.edn @@ -13,8 +13,7 @@ version-clj/version-clj {:mvn/version "2.0.2"}} :aliases {:neil {:project {:name babashka/bbin :version "0.2.4"}} - :dev {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}} - :extra-paths ["test" "test-resources" "dev"]} + :dev {:extra-paths ["test" "test-resources" "dev"]} :test {:extra-deps {http-kit/http-kit {:mvn/version "2.8.0"} io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"} ring/ring-core {:mvn/version "1.13.0"}} From b92def354800b8df068615d847269f1c02da2409 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:51:54 +0100 Subject: [PATCH 11/20] Avoid shipping ring/ring-core to bbin users (It's only used for testing) --- bbin | 1 - deps.edn | 1 - 2 files changed, 2 deletions(-) diff --git a/bbin b/bbin index cb3c256..c0ccfbc 100755 --- a/bbin +++ b/bbin @@ -17,7 +17,6 @@ org.babashka/http-client {:mvn/version "0.1.8"}, version-clj/version-clj {:mvn/version "2.0.2"}, babashka/fs {:mvn/version "0.3.17"}, - ring/ring-core {:mvn/version "1.13.0"}, org.babashka/json {:mvn/version "0.1.1"}}}) (ns babashka.bbin.meta) diff --git a/deps.edn b/deps.edn index d53789c..97076cc 100644 --- a/deps.edn +++ b/deps.edn @@ -8,7 +8,6 @@ org.babashka/http-client {:mvn/version "0.1.8"} org.babashka/json {:mvn/version "0.1.1"} org.clojure/tools.gitlibs {:mvn/version "2.4.181"} - ring/ring-core {:mvn/version "1.13.0"} selmer/selmer {:mvn/version "1.12.55"} version-clj/version-clj {:mvn/version "2.0.2"}} :aliases {:neil {:project {:name babashka/bbin From 212794eee82e5f8bbe34b9d3d5f49e8457ae6b50 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:54:51 +0100 Subject: [PATCH 12/20] Delete commented-out code --- bbin | 1 - src/babashka/bbin/scripts/common.clj | 1 - 2 files changed, 2 deletions(-) diff --git a/bbin b/bbin index c0ccfbc..7c554df 100755 --- a/bbin +++ b/bbin @@ -749,7 +749,6 @@ WARNING: (We won't make any changes without asking you first.) [babashka.bbin.dirs :as dirs] [babashka.bbin.specs] [babashka.bbin.util :as util :refer [sh whenbb]] - ;; [babashka.deps :as deps] [babashka.fs :as fs] [clojure.edn :as edn] [clojure.main :as main] diff --git a/src/babashka/bbin/scripts/common.clj b/src/babashka/bbin/scripts/common.clj index cc01cc4..eed924b 100644 --- a/src/babashka/bbin/scripts/common.clj +++ b/src/babashka/bbin/scripts/common.clj @@ -3,7 +3,6 @@ [babashka.bbin.dirs :as dirs] [babashka.bbin.specs] [babashka.bbin.util :as util :refer [sh whenbb]] - ;; [babashka.deps :as deps] [babashka.fs :as fs] [clojure.edn :as edn] [clojure.main :as main] From f3f0ddc0171b109cdd33dc00f4b2228d51699d29 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 17:57:42 +0100 Subject: [PATCH 13/20] `bb test:clj`: allow passing command line arguments --- bb.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bb.edn b/bb.edn index 2f442f8..4a720ef 100644 --- a/bb.edn +++ b/bb.edn @@ -23,7 +23,7 @@ http-kit/http-kit {:mvn/version "2.8.0"} ring/ring-core {:mvn/version "1.13.0"}} :task cognitect.test-runner/-main} - test:clj (clojure "-M:test") + test:clj (apply clojure "-M:test" *command-line-args*) gen-script {:doc "Build the bbin script" :extra-deps {org.clojure/tools.namespace {:mvn/version "1.5.0"}} :requires ([babashka.bbin.gen-script :as gen-script]) From 0ec000d40dcf2eb055d56e24e27e703cf002fedc Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 18:01:27 +0100 Subject: [PATCH 14/20] Add test deps to :dev alias --- deps.edn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index 97076cc..30ad4c7 100644 --- a/deps.edn +++ b/deps.edn @@ -12,7 +12,10 @@ version-clj/version-clj {:mvn/version "2.0.2"}} :aliases {:neil {:project {:name babashka/bbin :version "0.2.4"}} - :dev {:extra-paths ["test" "test-resources" "dev"]} + :dev {:extra-deps {http-kit/http-kit {:mvn/version "2.8.0"} + io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"} + ring/ring-core {:mvn/version "1.13.0"}} + :extra-paths ["test" "test-resources" "dev"]} :test {:extra-deps {http-kit/http-kit {:mvn/version "2.8.0"} io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"} ring/ring-core {:mvn/version "1.13.0"}} From c5a6eb4ba33f756fbf3a06c671ce6f95aec8ae8d Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 18:09:13 +0100 Subject: [PATCH 15/20] Undo accidential code formatting --- dev/babashka/bbin/dev.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/babashka/bbin/dev.clj b/dev/babashka/bbin/dev.clj index 76e8958..ad44aef 100644 --- a/dev/babashka/bbin/dev.clj +++ b/dev/babashka/bbin/dev.clj @@ -1,6 +1,6 @@ (ns babashka.bbin.dev (:require [babashka.process :refer [sh]] - [clojure.core.async :as async :refer [ Date: Fri, 3 Jan 2025 18:22:56 +0100 Subject: [PATCH 16/20] upgrade-maven-jar-test runs on JVM after all! --- test/babashka/bbin/scripts/maven_jar_test.clj | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/test/babashka/bbin/scripts/maven_jar_test.clj b/test/babashka/bbin/scripts/maven_jar_test.clj index cde3c0f..0b2ebf9 100644 --- a/test/babashka/bbin/scripts/maven_jar_test.clj +++ b/test/babashka/bbin/scripts/maven_jar_test.clj @@ -31,17 +31,16 @@ (def upgraded-lib (assoc-in maven-lib [:coords :mvn/version] "0.1.13")) -(whenbb - (deftest upgrade-maven-jar-test - (testing "upgrade (maven jar)" - (tu/reset-test-dir) - (dirs/ensure-bbin-dirs {}) - (let [out (tu/run-install {:script/lib (str (:lib maven-lib)) - :mvn/version (-> maven-lib :coords :mvn/version)}) - out2 (tu/run-upgrade {:script/lib "http-server"})] - (is (= maven-lib out)) - (is (= upgraded-lib out2)) - (is (fs/exists? (fs/file (dirs/bin-dir nil) (name (:lib upgraded-lib))))) - (is (str/starts-with? (tu/run-bin-script (:lib upgraded-lib) "--help") - help-text)) - (is (= {'http-server upgraded-lib} (tu/run-ls))))))) +(deftest upgrade-maven-jar-test + (testing "upgrade (maven jar)" + (tu/reset-test-dir) + (dirs/ensure-bbin-dirs {}) + (let [out (tu/run-install {:script/lib (str (:lib maven-lib)) + :mvn/version (-> maven-lib :coords :mvn/version)}) + out2 (tu/run-upgrade {:script/lib "http-server"})] + (is (= maven-lib out)) + (is (= upgraded-lib out2)) + (is (fs/exists? (fs/file (dirs/bin-dir nil) (name (:lib upgraded-lib))))) + (is (str/starts-with? (tu/run-bin-script (:lib upgraded-lib) "--help") + help-text)) + (is (= {'http-server upgraded-lib} (tu/run-ls)))))) From 1f170e107c32f8b60fc4a0bfe1394e7fc4a357b8 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 18:27:18 +0100 Subject: [PATCH 17/20] invalid-bin-config-test also runs on clj --- test/babashka/bbin/scripts/local_dir_test.clj | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/test/babashka/bbin/scripts/local_dir_test.clj b/test/babashka/bbin/scripts/local_dir_test.clj index bca144f..acdd7e6 100644 --- a/test/babashka/bbin/scripts/local_dir_test.clj +++ b/test/babashka/bbin/scripts/local_dir_test.clj @@ -25,20 +25,19 @@ out)) (is (fs/exists? (fs/file (dirs/bin-dir nil) "foo"))))))) -(whenbb - (deftest invalid-bin-config-test - (testing "install */* --local/root * (invalid bin config)" - (tu/reset-test-dir) - (dirs/ensure-bbin-dirs {}) - (let [local-root (str (fs/file tu/test-dir "foo")) - invalid-config 123] - (fs/create-dir local-root) - (spit (fs/file local-root "bb.edn") (pr-str {:bbin/bin invalid-config})) - (spit (fs/file local-root "deps.edn") (pr-str {})) - (let [cli-opts {:script/lib "babashka/foo" - :local/root local-root}] - (is (thrown-with-msg? ExceptionInfo #"123 - failed: map\? spec: :bbin/bin" - (tu/run-install cli-opts)))))))) +(deftest invalid-bin-config-test + (testing "install */* --local/root * (invalid bin config)" + (tu/reset-test-dir) + (dirs/ensure-bbin-dirs {}) + (let [local-root (str (fs/file tu/test-dir "foo")) + invalid-config 123] + (fs/create-dir local-root) + (spit (fs/file local-root "bb.edn") (pr-str {:bbin/bin invalid-config})) + (spit (fs/file local-root "deps.edn") (pr-str {})) + (let [cli-opts {:script/lib "babashka/foo" + :local/root local-root}] + (is (thrown-with-msg? ExceptionInfo #"123 - failed: map\? spec: :bbin/bin" + (tu/run-install cli-opts))))))) (deftest install-from-no-lib-local-root-dir-test (testing "install ./" From d2298da53a451901dd38727f58720fdb90b88aba Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 18:28:36 +0100 Subject: [PATCH 18/20] Remove unused import --- test/babashka/bbin/scripts/local_dir_test.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/babashka/bbin/scripts/local_dir_test.clj b/test/babashka/bbin/scripts/local_dir_test.clj index acdd7e6..a92352e 100644 --- a/test/babashka/bbin/scripts/local_dir_test.clj +++ b/test/babashka/bbin/scripts/local_dir_test.clj @@ -1,7 +1,6 @@ (ns babashka.bbin.scripts.local-dir-test (:require [babashka.bbin.dirs :as dirs] [babashka.bbin.test-util :as tu] - [babashka.bbin.util :refer [whenbb]] [babashka.fs :as fs] [clojure.string :as str] [clojure.test :refer [deftest is testing use-fixtures]]) From 01335e4c630509433b6cf2c3dfa5670e3852b4cc Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 18:31:04 +0100 Subject: [PATCH 19/20] Remove unused import --- test/babashka/bbin/scripts/maven_jar_test.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/babashka/bbin/scripts/maven_jar_test.clj b/test/babashka/bbin/scripts/maven_jar_test.clj index 0b2ebf9..edd98f2 100644 --- a/test/babashka/bbin/scripts/maven_jar_test.clj +++ b/test/babashka/bbin/scripts/maven_jar_test.clj @@ -1,7 +1,6 @@ (ns babashka.bbin.scripts.maven-jar-test (:require [babashka.bbin.dirs :as dirs] [babashka.bbin.test-util :as tu] - [babashka.bbin.util :refer [whenbb]] [babashka.fs :as fs] [clojure.string :as str] [clojure.test :refer [deftest is testing use-fixtures]])) From 1181287359252fa0c9ba5e22811f9a55a08f81a1 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Fri, 3 Jan 2025 18:34:23 +0100 Subject: [PATCH 20/20] Run clj tests on CI too --- .github/workflows/ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d49b230..baa7c23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,21 @@ jobs: run: | bb run test + clj-run-test-linux: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + bb-version: [1.3.190, latest] + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Install clojure tools + uses: DeLaGuardo/setup-clojure@9.4 + with: + bb: ${{ matrix.bb-version }} + - run: bb run test:clj + bb-run-lint: runs-on: ubuntu-latest strategy: