Skip to content

Commit 49b566a

Browse files
authored
Merge pull request #87 from clj-commons/lread/maint-2025-12-12
maintenance
2 parents 30bb8a1 + 1a68c55 commit 49b566a

File tree

10 files changed

+99
-30
lines changed

10 files changed

+99
-30
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(ns babashka.fs
2+
(:require [clj-kondo.hooks-api :as api]))
3+
4+
(defn- symbol-node? [node]
5+
(and (api/token-node? node)
6+
(symbol? (api/sexpr node))))
7+
8+
(defn with-temp-dir
9+
[{:keys [node]}]
10+
(let [args (rest (:children node))
11+
binding-like-vector (first args)
12+
body (rest args)]
13+
(when-not (zero? (count args)) ;; let clj-kondo report on arity
14+
(if-not (api/vector-node? binding-like-vector)
15+
(api/reg-finding! (assoc (meta binding-like-vector)
16+
:message "babashka.fs/with-temp-dir requires a vector for first arg"
17+
:type :babashka-fs/with-temp-dir-first-arg-not-vector))
18+
(let [[binding-sym options & rest-in-vec] (:children binding-like-vector)]
19+
(when (not (symbol-node? binding-sym))
20+
(api/reg-finding! (assoc (meta (or binding-sym binding-like-vector))
21+
:message "babashka.fs/with-temp-dir vector arg requires binding-name symbol as first value"
22+
:type :babashka-fs/with-temp-dir-vector-arg-needs-binding-symbol)))
23+
(doseq [extra-vector-arg rest-in-vec]
24+
(api/reg-finding! (assoc (meta extra-vector-arg)
25+
:message "babashka.fs/with-temp-dir vector arg accepts at most 2 values"
26+
:type :babashka-fs/with-temp-dir-vector-arg-extra-value)))
27+
28+
(when binding-sym
29+
{:node (api/list-node
30+
;; satisfy linter by creating binding for for binding-sym
31+
(list*
32+
(api/token-node 'let)
33+
;; it doesn't really matter what we bind to, so long as it is bound
34+
(api/vector-node [binding-sym (api/token-node nil)])
35+
options ;; avoid unused binding when options is a binding
36+
body))}))))))
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
{:lint-as {babashka.fs/with-temp-dir clojure.core/let}}
1+
{:linters {:babashka-fs/with-temp-dir-first-arg-not-vector {:level :error}
2+
:babashka-fs/with-temp-dir-vector-arg-needs-binding-symbol {:level :error}
3+
:babashka-fs/with-temp-dir-vector-arg-extra-value {:level :error}}
4+
:hooks {:analyze-call {babashka.fs/with-temp-dir babashka.fs/with-temp-dir}}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{:linters
2+
{:unresolved-symbol
3+
{:exclude [(cljs.test/is [match? thrown-match?])
4+
(clojure.test/is [match? thrown-match?])]}}}

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v5
18+
uses: actions/checkout@v6
1919

2020
- name: Setup
2121
uses: ./.github/workflows/shared-setup

.github/workflows/shared-setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414

1515
steps:
1616
- name: Clojure deps cache
17-
uses: actions/cache@v4
17+
uses: actions/cache@v5
1818
with:
1919
path: |
2020
~/.m2/repository

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v5
16+
uses: actions/checkout@v6
1717

1818
- name: Setup
1919
uses: ./.github/workflows/shared-setup
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: Checkout
39-
uses: actions/checkout@v5
39+
uses: actions/checkout@v6
4040

4141
- name: Setup
4242
uses: ./.github/workflows/shared-setup
@@ -58,7 +58,7 @@ jobs:
5858

5959
steps:
6060
- name: Checkout
61-
uses: actions/checkout@v5
61+
uses: actions/checkout@v6
6262

6363
- name: Setup
6464
uses: ./.github/workflows/shared-setup

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ aws.clj
2727
.cpcache
2828
.idea
2929
*.iml
30+
.nrepl-port

bb.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
{:doc "Runs tests under babashka Clojure (recognizes cognitect test-runner args)"
2929
:extra-paths ["src" "test" "test-resources"]
3030
:extra-deps {io.github.cognitect-labs/test-runner
31-
{:git/tag "v0.5.1" :git/sha "dfb30dd"}}
31+
{:git/tag "v0.5.1" :git/sha "dfb30dd"}
32+
nubank/matcher-combinators {:mvn/version "3.9.2"}}
3233
:requires ([cognitect.test-runner :as tr])
3334
:task (apply tr/-main *command-line-args*)}
3435
lint

deps.edn

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
:1.9 {:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}}
1010
:1.10 {:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}}
1111
:1.11 {:override-deps {org.clojure/clojure {:mvn/version "1.11.4"}}}
12-
:1.12 {:override-deps {org.clojure/clojure {:mvn/version "1.12.3"}}}
12+
:1.12 {:override-deps {org.clojure/clojure {:mvn/version "1.12.4"}}}
1313
:build
1414
{:extra-paths ["build"]
15-
:deps {io.github.clojure/tools.build {:mvn/version "0.10.10"}
15+
:deps {io.github.clojure/tools.build {:mvn/version "0.10.11"}
1616
slipset/deps-deploy {:mvn/version "0.2.2"}}
1717
:ns-default build}
1818
:http-server ;; used for to support integration tests
1919
{:extra-paths ["test" "test-resources"]
2020
:override-deps {org.clojure/clojure {:mvn/version "1.12.3"}}
21-
:extra-deps {babashka/fs {:mvn/version "0.5.27"}
21+
:extra-deps {babashka/fs {:mvn/version "0.5.30"}
2222
ring/ring-jetty-adapter {:mvn/version "1.10.0"} ;; stick with version that works on jdk8
23-
ch.qos.logback/logback-classic {:mvn/version "1.3.15"
23+
ch.qos.logback/logback-classic {:mvn/version "1.3.16"
2424
:exclusions [org.slf4j/slf4j-api]}
2525
org.slf4j/jcl-over-slf4j {:mvn/version "2.0.17"}
2626
org.slf4j/jul-to-slf4j {:mvn/version "2.0.17"}
@@ -29,10 +29,12 @@
2929
:test
3030
{:extra-paths ["test"]
3131
:extra-deps {io.github.cognitect-labs/test-runner
32-
{:git/tag "v0.5.1" :git/sha "dfb30dd"}}
32+
{:git/tag "v0.5.1" :git/sha "dfb30dd"}
33+
cheshire/cheshire {:mvn/version "6.1.0"}
34+
nubank/matcher-combinators {:mvn/version "3.9.2"}}
3335
:main-opts ["-m" "cognitect.test-runner"]}
3436
;; for consistent linting we use a specific version of clj-kondo through the jvm
35-
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2025.09.22"}}
37+
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2025.10.23"}}
3638
:override-deps {org.clojure/clojure {:mvn/version "1.12.3"}}
3739
:main-opts ["-m" "clj-kondo.main"]}
3840
:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "2.11.1276"}
Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,53 @@
11
(ns clj-http.lite.client-sanity-test
2-
"A small subset of tests suitable for sanity testing.
3-
Used by babashka libs tests."
2+
"A small subset of tests suitable for sanity testing."
43
(:require [clj-http.lite.client :as client]
4+
[cheshire.core :as json]
5+
[matcher-combinators.test]
6+
[matcher-combinators.matchers :as m]
57
[clojure.test :as t :refer [deftest is]]))
68

79
(deftest client-test
810
(is (= 200 (:status (client/get "https://www.clojure.org" {:throw-exceptions false}))))
911

10-
(is (= 200 (:status (client/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2" {:throw-exceptions false}))))
12+
(is (match? {:status 200
13+
:body (m/via json/decode {"method" "GET"
14+
"args" {"foo1" ["bar1"]
15+
"foo2" ["bar2"]}})}
16+
(client/get "https://httpbingo.org/get?foo1=bar1&foo2=bar2" {:throw-exceptions false})))
1117

12-
(is (= 200 (:status (client/post "https://postman-echo.com/post" {:throw-exceptions false}))))
18+
(is (match? {:status 200
19+
:body (m/via json/decode {"method" "POST"
20+
"headers" {"Content-Type" m/absent}
21+
"args" {}
22+
"data" ""})}
23+
(client/post "https://httpbingo.org/post" {:throw-exceptions false})))
1324

14-
(is (= 200 (:status (client/post "https://postman-echo.com/post"
15-
{:body "{\"a\": 1}"
16-
:headers {"X-Hasura-Role" "admin"}
17-
:content-type :json
18-
:accept :json
19-
:throw-exceptions false}))))
25+
(is (match? {:status 200
26+
:body (m/via json/decode {"method" "POST"
27+
"headers" {"Content-Type" ["application/json; charset=UTF-8"]
28+
"X-Hasura-Role" ["admin"]}
29+
"data" "{\"a\": 1}"})}
30+
(client/post "https://httpbingo.org/post"
31+
{:body "{\"a\": 1}"
32+
:headers {"X-Hasura-Role" "admin"}
33+
:content-type :json
34+
:accept :json
35+
:throw-exceptions false})))
2036

21-
(is (= 200 (:status (client/put "https://postman-echo.com/put"
22-
{:body "{\"a\": 1}"
23-
:headers {"X-Hasura-Role" "admin"}
24-
:content-type :json
25-
:accept :json
26-
:throw-exceptions false})))))
37+
(is (match? {:status 200
38+
:body (m/via json/decode {"method" "PUT"
39+
"headers" {"Content-Type" ["application/json; charset=UTF-8"]
40+
"X-Hasura-Role" ["admin"]}
41+
"data" "{\"a\": 1}"})}
42+
(client/put "https://httpbingo.org/put"
43+
{:body "{\"a\": 1}"
44+
:headers {"X-Hasura-Role" "admin"}
45+
:content-type :json
46+
:accept :json
47+
:throw-exceptions false}))))
2748

2849
(deftest exception-test
29-
(try (client/get "https://httpbin.org/status/404")
50+
(try (client/get "https://httpbingo.org/status/404")
3051
(is false "should not reach here")
3152
(catch Exception e
3253
(is (:headers (ex-data e))))))
@@ -37,3 +58,4 @@
3758
(is (= 200 (:status (client/get "https://expired.badssl.com" {:insecure? true}))))
3859
(is (thrown? Exception
3960
(client/get "https://expired.badssl.com"))))
61+

0 commit comments

Comments
 (0)