diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 649a08c..9dcec3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: restore-keys: cljdeps- - name: Run clj tests - run: bb test:clj + run: bb test:clj :clj-all - name: Run bb tests run: bb test:bb diff --git a/CHANGELOG.md b/CHANGELOG.md index 1369a5f..e78b524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog -Babashka [http-client](https://github.com/babashka/http-client): HTTP client for Clojure and babashka built on java.net.http +Babashka [http-client](https://github.com/babashka/http-client): HTTP client for Clojure and babashka built on java.net.http + +## Unreleased + +- [#60](https://github.com/babashka/http-client/issues/60): Minimum Clojure version is now 1.10 +([@lread](https://github.com/lread)) ## 0.4.19 (2024-04-24) diff --git a/README.md b/README.md index 999671a..4fa3918 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ See [API.md](API.md). > NOTE: The `babashka.http-client` library is built-in as of babashka version 1.1.171. +> TIP: We test and support `babashka.http-client` on Clojure v1.10 and above. + ## Stability The `babashka.http-client` namespace can be considered stable. The diff --git a/bb.edn b/bb.edn index aa9a19d..fa8bee1 100644 --- a/bb.edn +++ b/bb.edn @@ -1,5 +1,7 @@ -{:tasks - {test:clj (apply clojure "-M:test" *command-line-args*) +{:paths ["script"] + :tasks + {test:clj {:doc "Run jvm tests, optionally specify clj-version (ex. :clj-1.10 :clj-1.11(default) or :clj-all)" + :task test-clj/-main} test:bb {:extra-paths ["src" "test"] :extra-deps {io.github.cognitect-labs/test-runner diff --git a/deps.edn b/deps.edn index 3e00372..f6b6222 100644 --- a/deps.edn +++ b/deps.edn @@ -2,6 +2,10 @@ :aliases {:neil {:project {:name org.babashka/http-client :version "0.4.19"}} + :clj-1.10 {:extra-deps {org.clojure/clojure {:mvn/version "1.10.3"}}} + :clj-1.11 {:extra-deps {org.clojure/clojure {:mvn/version "1.11.4"}}} + :clj-1.12 {:extra-deps {org.clojure/clojure {:mvn/version "1.12.0-rc1"}}} + :repl {:extra-deps {cheshire/cheshire {:mvn/version "5.11.0"} io.github.borkdude/deflet {:mvn/version "0.1.0"} babashka/fs {:mvn/version "0.2.16"}}} diff --git a/script/test_clj.clj b/script/test_clj.clj new file mode 100644 index 0000000..9d53e1c --- /dev/null +++ b/script/test_clj.clj @@ -0,0 +1,41 @@ +#!/usr/bin/env bb + +(ns test-clj + (:require + [babashka.tasks :as tasks] + [clojure.edn :as edn] + [clojure.string :as str])) + +(defn -main[& args] + (let [farg (first *command-line-args*) + ;; allow for missing leading colon + farg (if (and farg (str/starts-with? farg "clj-")) + (str ":" farg) + farg) + clj-version-aliases (->> "deps.edn" + slurp + edn/read-string + :aliases + keys + (map str) + (filter (fn [a] (-> a name (str/starts-with? ":clj-")))) + sort + (into [])) + [aliases args] (cond + (nil? farg) [[":clj-1.11"] []] + + (= ":clj-all" farg) [clj-version-aliases (rest args)] + + (and (str/starts-with? farg ":clj-") + (not (some #{farg} clj-version-aliases))) + (throw (ex-info (format "%s not recognized, valid clj- args are: %s or \":clj-all\"" farg clj-version-aliases) {})) + + (some #{farg} clj-version-aliases) [[farg] (rest args)] + + :else [[":clj-1.11"] args])] + (doseq [alias aliases] + (println (format "-[Running jvm tests for %s]-" alias)) + (apply tasks/clojure (str "-M:test" alias) args)))) + +(when (= *file* (System/getProperty "babashka.file")) + (apply -main *command-line-args*)) diff --git a/src/babashka/http_client/internal/multipart.clj b/src/babashka/http_client/internal/multipart.clj index 68dfbd6..14e727e 100644 --- a/src/babashka/http_client/internal/multipart.clj +++ b/src/babashka/http_client/internal/multipart.clj @@ -42,7 +42,7 @@ See https://www.ietf.org/rfc/rfc2046.txt" [] - (str "babashka_http_client_Boundary" (random-uuid))) + (str "babashka_http_client_Boundary" (java.util.UUID/randomUUID))) (defn concat-streams [^InputStream is1 ^InputStream is2 & more] (let [is (new java.io.SequenceInputStream is1 is2)] diff --git a/test/babashka/http_client_test.clj b/test/babashka/http_client_test.clj index 26b8afc..3a498e2 100644 --- a/test/babashka/http_client_test.clj +++ b/test/babashka/http_client_test.clj @@ -21,7 +21,7 @@ (let [server (server/run-server (fn [{:keys [uri body] :as req}] - (let [status (parse-long (subs uri 1)) + (let [status (Long/valueOf (subs uri 1)) json? (some-> req :headers (get "accept") (str/includes? "application/json"))] (case status 200 (let [body (if json? @@ -423,7 +423,7 @@ :code))))))) (deftest multipart-test - (let [uuid (.toString (random-uuid)) + (let [uuid (.toString (java.util.UUID/randomUUID)) _ (spit (doto (io/file ".test-data") (.deleteOnExit)) uuid) resp (http/post "https://postman-echo.com/post"