Skip to content
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

Ensure support for Clojure 1.10 and above #65

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 34 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
{:tasks
{test:clj (apply clojure "-M:test" *command-line-args*)
{test:clj {:doc "Run jvm tests, optionally specify clj-version (ex. :clj-1.10 :clj-1.11(default) or :clj-all)"
:requires ([clojure.string :as str]
[clojure.edn :as edn])
:task (let [args *command-line-args*
lread marked this conversation as resolved.
Show resolved Hide resolved
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]
(do
(println (format "-[Running jvm tests for %s]-" alias))
(apply clojure (str "-M:test" alias) args))))}

test:bb {:extra-paths ["src" "test"]
:extra-deps {io.github.cognitect-labs/test-runner
Expand Down
4 changes: 4 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}
Expand Down
2 changes: 1 addition & 1 deletion src/babashka/http_client/internal/multipart.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions test/babashka/http_client_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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"
Expand Down