Skip to content

Commit

Permalink
maint: bump deps (#596)
Browse files Browse the repository at this point in the history
* maint: bump deps + some other tweaks

* Bump to clojure used for REPL to 1.11.3

Jvm nrepl no longer works with clojure 1.9

* Adapt to small change in wikipedia

Our docs introduce Etaoin with a trip to wikipedia.
Our docs are tested with test-doc-blocks.
Wikipedia changed a wee bit.
Which made our doc tests fail.
Adapt.

* ci debug: always upload any saved screenshots as artifact

To support debugging. 

* ci: test-matrix: natural sort by job description

Small thing, but sorts jdk8 before jdk11 which makes github actions workflow
job listing easier to follow.
  • Loading branch information
lread authored Jun 21, 2024
1 parent 116f4a2 commit c5054aa
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 21 deletions.
62 changes: 62 additions & 0 deletions .clj-kondo/potemkin/potemkin/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{:lint-as {potemkin.collections/compile-if clojure.core/if
potemkin.collections/reify-map-type clojure.core/reify
potemkin.collections/def-map-type clj-kondo.lint-as/def-catch-all
potemkin.collections/def-derived-map clj-kondo.lint-as/def-catch-all

potemkin.types/reify+ clojure.core/reify
potemkin.types/defprotocol+ clojure.core/defprotocol
potemkin.types/deftype+ clojure.core/deftype
potemkin.types/defrecord+ clojure.core/defrecord
potemkin.types/definterface+ clojure.core/defprotocol
potemkin.types/extend-protocol+ clojure.core/extend-protocol
potemkin.types/def-abstract-type clj-kondo.lint-as/def-catch-all

potemkin.utils/doit clojure.core/doseq
potemkin.utils/doary clojure.core/doseq
potemkin.utils/condp-case clojure.core/condp
potemkin.utils/fast-bound-fn clojure.core/bound-fn

potemkin.walk/prewalk clojure.walk/prewalk
potemkin.walk/postwalk clojure.walk/postwalk
potemkin.walk/walk clojure.walk/walk

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; top-level from import-vars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Have hooks
;;potemkin/import-fn potemkin.namespaces/import-fn
;;potemkin/import-macro potemkin.namespaces/import-macro
;;potemkin/import-def potemkin.namespaces/import-def

;; Internal, not transitive
;;potemkin/unify-gensyms potemkin.macros/unify-gensyms
;;potemkin/normalize-gensyms potemkin.macros/normalize-gensyms
;;potemkin/equivalent? potemkin.macros/equivalent?

potemkin/condp-case clojure.core/condp
potemkin/doit potemkin.utils/doit
potemkin/doary potemkin.utils/doary

potemkin/def-abstract-type clj-kondo.lint-as/def-catch-all
potemkin/reify+ clojure.core/reify
potemkin/defprotocol+ clojure.core/defprotocol
potemkin/deftype+ clojure.core/deftype
potemkin/defrecord+ clojure.core/defrecord
potemkin/definterface+ clojure.core/defprotocol
potemkin/extend-protocol+ clojure.core/extend-protocol

potemkin/reify-map-type clojure.core/reify
potemkin/def-derived-map clj-kondo.lint-as/def-catch-all
potemkin/def-map-type clj-kondo.lint-as/def-catch-all}

;; leave import-vars alone, kondo special-cases it
:hooks {:macroexpand {#_#_potemkin.namespaces/import-vars potemkin.namespaces/import-vars
potemkin.namespaces/import-fn potemkin.namespaces/import-fn
potemkin.namespaces/import-macro potemkin.namespaces/import-macro
potemkin.namespaces/import-def potemkin.namespaces/import-def

#_#_potemkin/import-vars potemkin.namespaces/import-vars
potemkin/import-fn potemkin.namespaces/import-fn
potemkin/import-macro potemkin.namespaces/import-macro
potemkin/import-def potemkin.namespaces/import-def}}}
56 changes: 56 additions & 0 deletions .clj-kondo/potemkin/potemkin/potemkin/namespaces.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(ns potemkin.namespaces
(:require [clj-kondo.hooks-api :as api]))

(defn import-macro*
([sym]
`(def ~(-> sym name symbol) ~sym))
([sym name]
`(def ~name ~sym)))

(defmacro import-fn
([sym]
(import-macro* sym))
([sym name]
(import-macro* sym name)))

(defmacro import-macro
([sym]
(import-macro* sym))
([sym name]
(import-macro* sym name)))

(defmacro import-def
([sym]
(import-macro* sym))
([sym name]
(import-macro* sym name)))

#_
(defmacro import-vars
"Imports a list of vars from other namespaces."
[& syms]
(let [unravel (fn unravel [x]
(if (sequential? x)
(->> x
rest
(mapcat unravel)
(map
#(symbol
(str (first x)
(when-let [n (namespace %)]
(str "." n)))
(name %))))
[x]))
syms (mapcat unravel syms)
result `(do
~@(map
(fn [sym]
(let [vr (resolve sym)
m (meta vr)]
(cond
(nil? vr) `(throw (ex-info (format "`%s` does not exist" '~sym) {}))
(:macro m) `(def ~(-> sym name symbol) ~sym)
(:arglists m) `(def ~(-> sym name symbol) ~sym)
:else `(def ~(-> sym name symbol) ~sym))))
syms))]
result))
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,11 @@ jobs:

- name: Run Tests
run: ${{ matrix.cmd }}

- name: Upload test debug output
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.id }}-debug-screenshots
path: target/debug-screenshots/*
if-no-files-found: ignore
33 changes: 17 additions & 16 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.9.0"} ;; min clojure version
babashka/fs {:mvn/version "0.5.20"}
babashka/fs {:mvn/version "0.5.21"}
babashka/process {:mvn/version "0.5.22"}
clj-http/clj-http {:mvn/version "3.12.3"} ;; for jvm use
clj-http/clj-http {:mvn/version "3.13.0"} ;; for jvm use
org.clj-commons/clj-http-lite {:mvn/version "1.0.13"} ;; for babashka use
slingshot/slingshot {:mvn/version "0.12.2"}
cheshire/cheshire {:mvn/version "5.12.0"}
cheshire/cheshire {:mvn/version "5.13.0"}
org.clojure/tools.cli {:mvn/version "1.1.230"}
org.clojure/tools.logging {:mvn/version "1.3.0"}
lambdaisland/uri {:mvn/version "1.19.155"}}
:aliases
{:1.11 {:replace-deps {org.clojure/clojure {:mvn/version "1.11.2"}}}
:1.12 {:replace-deps {org.clojure/clojure {:mvn/version "1.12.0-alpha9"}}}
{:1.11 {:replace-deps {org.clojure/clojure {:mvn/version "1.11.3"}}}
:1.12 {:replace-deps {org.clojure/clojure {:mvn/version "1.12.0-beta1"}}}
:debug {:extra-paths ["env/dev/resources"]}
:test {:extra-paths ["test" "env/test/resources" "build"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
org.babashka/cli {:mvn/version "0.8.58"}
org.babashka/cli {:mvn/version "0.8.59"}
ch.qos.logback/logback-classic {:mvn/version "1.3.14"}
;; for http-client which uses apache http client 4.x which uses commons logging
org.slf4j/jcl-over-slf4j {:mvn/version "2.0.12"}}
org.slf4j/jcl-over-slf4j {:mvn/version "2.0.13"}}
:exec-fn build-shared/test
:org.babashka/cli {:coerce {:nses [:symbol]
:patterns [:string]
Expand All @@ -27,15 +27,15 @@
:script {:extra-paths ["script"]}

;; test-doc-blocks - gen tests
:test-doc-blocks {:replace-deps {org.clojure/clojure {:mvn/version "1.11.2"}
com.github.lread/test-doc-blocks {:mvn/version "1.1.19"}}
:test-doc-blocks {:replace-deps {org.clojure/clojure {:mvn/version "1.11.3"}
com.github.lread/test-doc-blocks {:mvn/version "1.1.20"}}
:replace-paths []
:ns-default lread.test-doc-blocks
:exec-args {:docs ["doc/01-user-guide.adoc"]}}

;; test-doc-blocks - run tests
;; usage: test:test-docs
:test-docs {:override-deps {org.clojure/clojure {:mvn/version "1.11.2"}}
:test-docs {:override-deps {org.clojure/clojure {:mvn/version "1.11.3"}}
:extra-paths ["target/test-doc-blocks/test"]
:exec-fn cognitect.test-runner.api/test
:exec-args {:dirs ["target/test-doc-blocks/test"]}
Expand All @@ -45,7 +45,7 @@
:main-opts ["-m" "babashka.cli.exec"]}

;; for consistent linting we use a specific version of clj-kondo through the jvm
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2024.03.13"}}
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2024.05.24"}}
:main-opts ["-m" "clj-kondo.main"]}

:eastwood {:extra-deps {jonase/eastwood {:mvn/version "1.4.2"}}
Expand All @@ -55,25 +55,26 @@
:add-linters [:performance]
:exclude-linters [:local-shadows-var]}]}

:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.0"}}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.4"}}
:ns-default build}

;; keep deploy deps separate from build deps to avoid download-deps issues
;; caused by, I think, conflicting maven deps
:deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.2"}}}

:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "2.8.1185"}
:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "2.8.1201"}
org.clojure/clojure {:mvn/version "1.11.1"}
org.slf4j/slf4j-simple {:mvn/version "2.0.12"} ;; to rid ourselves of logger warnings
org.slf4j/slf4j-simple {:mvn/version "2.0.13"} ;; to rid ourselves of logger warnings
}
:main-opts ["-m" "antq.core"
"--exclude=ch.qos.logback/[email protected]" ;; requires min jdk 11, we are currently jdk8 compatible
"--exclude=ch.qos.logback/[email protected]" ;; requires min jdk 11, we are currently jdk8 compatible
]}

:repl/cider
{:extra-deps {nrepl/nrepl {:mvn/version "1.1.1"}
cider/cider-nrepl {:mvn/version "0.47.0"}
{:extra-deps {org.clojure/clojure {:mvn/version "1.11.3"}
nrepl/nrepl {:mvn/version "1.2.0"}
cider/cider-nrepl {:mvn/version "0.49.0"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.10.0"}}
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
:main-opts ["-m" "nrepl.cmdline"
Expand Down
9 changes: 7 additions & 2 deletions doc/01-user-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ endif::[]
;; navigate to wikipedia
(e/go driver "https://en.wikipedia.org/")
;; make sure we aren't using large screen layout
(e/set-window-size driver {:width 1280 :height 800})
;; wait for the search input to load
(e/wait-visible driver [{:id :simpleSearch} {:tag :input :name :search}])
(e/wait-visible driver [{:tag :input :name :search}])
;; search for something interesting
(e/fill driver {:tag :input :name :search} "Clojure programming language")
Expand Down Expand Up @@ -325,7 +329,8 @@ A portion of the above rewritten with `doto`:
(doto driver
(e/go "https://en.wikipedia.org/")
(e/wait-visible [{:id :simpleSearch} {:tag :input :name :search}])
(e/set-window-size {:width 1280 :height 800})
(e/wait-visible [{:tag :input :name :search}])
(e/fill {:tag :input :name :search} "Clojure programming language")
(e/wait 1)
(e/fill {:tag :input :name :search} k/enter)
Expand Down
28 changes: 28 additions & 0 deletions script/helper/natural_sort.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;; Thanks to https://gist.github.com/wilkerlucio/db54dc83a9664124f3febf6356f04509
(ns helper.natural-sort
(:refer-clojure :exclude [sort sort-by])
(:require [clojure.string]))

(defn vector-compare [[value1 & rest1] [value2 & rest2]]
(let [result (compare value1 value2)]
(cond
(not (zero? result)) result
(nil? value1) 0
:else (recur rest1 rest2))))

(defn prepare-string [s]
(let [s (or s "")
parts (vec (clojure.string/split s #"\d+"))
numbers (->> (re-seq #"\d+" s)
(map parse-long)
(vec))]
(vec (interleave (conj parts "") (conj numbers -1)))))

(defn natural-compare [a b]
(vector-compare (prepare-string a)
(prepare-string b)))

(defn sort [coll] (clojure.core/sort natural-compare coll))

(defn sort-by [keyfn coll]
(clojure.core/sort-by keyfn natural-compare coll))
8 changes: 5 additions & 3 deletions script/test_matrix.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[cheshire.core :as json]
[clojure.string :as string]
[doric.core :as doric]
[helper.natural-sort :as natural-sort]
[helper.main :as main]
[lread.status-line :as status]))

Expand Down Expand Up @@ -76,8 +77,9 @@
(for [jdk-version (get os-jdks "ubuntu")
:when (not= jdk-version (:jdk-version default-opts))]
(test-doc {:jdk-version jdk-version :os "ubuntu"})))
(sort-by (juxt #(parse-long (:jdk-version %)) :desc))
(into [(merge default-opts {:os "ubuntu" :cmd "bb lint" :desc "lint"})]))))
(natural-sort/sort-by :desc)
(into [(merge default-opts {:os "ubuntu" :cmd "bb lint" :desc "lint"})])
(mapv #(assoc % :id (string/replace (:desc %) " " "-"))))))

(def valid-formats ["json" "table"])
(def cli-spec {:help {:desc "This usage help"}
Expand Down Expand Up @@ -107,7 +109,7 @@
(status/line :detail
(if (= "json" (:format opts))
(json/generate-string matrix)
(doric/table [:os :jdk-version :cmd :needs :desc] matrix)))))))
(doric/table [:os :jdk-version :cmd :needs :desc :id] matrix)))))))

(main/when-invoked-as-script
(apply -main *command-line-args*))

0 comments on commit c5054aa

Please sign in to comment.