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

Bump Honey SQL version & Use JVM Kondo #177

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions .clj-kondo/com.github.seancorfield/next.jdbc/config.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{:hooks
{:analyze-call
{next.jdbc/with-transaction
hooks.com.github.seancorfield.next-jdbc/with-transaction}}
:lint-as {next.jdbc/on-connection clojure.core/with-open}}
hooks.com.github.seancorfield.next-jdbc/with-transaction
next.jdbc/with-transaction+options
hooks.com.github.seancorfield.next-jdbc/with-transaction+options}}
:lint-as {next.jdbc/on-connection clojure.core/with-open
next.jdbc/on-connection+options clojure.core/with-open}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(ns hooks.com.github.seancorfield.next-jdbc
(:require [clj-kondo.hooks-api :as api]))

(defn with-transaction
"Expands (with-transaction [tx expr opts] body)
to (let [tx expr] opts body) per clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))

(defn with-transaction+options
"Expands (with-transaction+options [tx expr opts] body)
to (let [tx expr] opts body) per clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))
24 changes: 3 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,23 @@ jobs:
kondo:
runs-on: ubuntu-20.04
timeout-minutes: 10
env:
CLJ_KONDO_VERSION: "2023.09.07"
DOWNLOAD_URL: https://github.com/clj-kondo/clj-kondo/releases/download
steps:
- uses: actions/checkout@v4.1.7
- name: Setup Java & Clojure
uses: ./.github/actions/setup
with:
cache-key: kondo
- name: Install clj-kondo
run: |
curl -OL ${DOWNLOAD_URL}/v${CLJ_KONDO_VERSION}/clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip
curl -OL ${DOWNLOAD_URL}/v${CLJ_KONDO_VERSION}/clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip.sha256
cat clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip.sha256 >> SHA256sum.txt
echo " clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip" >> SHA256sum.txt
sha256sum -c SHA256sum.txt
unzip -d /usr/local/bin clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip
- run: clj-kondo --version
- name: Copy Kondo config from deps
run: >-
clj-kondo
clojure -M:kondo
--copy-configs
--dependencies
--lint "$(clojure -A:dev -Spath)"
--skip-lint
--parallel
- name: Run clj-kondo
run: >-
clj-kondo
--parallel
--lint
src
test
toucan1/src
toucan1/test
clojure -M:kondo:kondo/all

tests-postgres:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -139,7 +121,7 @@ jobs:
- run: clojure -X:dev:test-h2:cloverage
name: Run tests with Cloverage
- name: Upload results to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4.5.0
with:
files: ./target/coverage/codecov.json

Expand Down
29 changes: 27 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:deps
{better-cond/better-cond {:mvn/version "2.1.5"}
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
com.github.seancorfield/honeysql {:mvn/version "2.4.1066"} ; don't upgrade yet because of https://github.com/seancorfield/honeysql/issues/537
com.github.seancorfield/honeysql {:mvn/version "2.6.1147"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.939"}
environ/environ {:mvn/version "1.2.0"}
methodical/methodical {:mvn/version "1.0.123"}
Expand Down Expand Up @@ -59,6 +59,28 @@
:exec-args {:paths ["deps.edn" "src" "test" "toucan1/src" "toucan1/test" ".github" "docs"]
:include-patterns ["\\.clj[cs]?$" "\\.edn$" "\\.yaml$" "\\.sql$" "\\.md$"]}}

;; Run Kondo
;;
;; clojure -M:kondo --lint ...
;;
;; Copy configs
;;
;; clojure -M:kondo --copy-configs --dependencies --lint "$(clojure -A:dev -Spath)" --skip-lint --parallel
:kondo
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.09.07" #_"2024.08.01"}}
:main-opts ["-m" "clj-kondo.main"]}

;; lint everything with Kondo
;;
;; clojure -M:kondo:kondo/all
:kondo/all
{:main-opts ["-m" "clj-kondo.main"
"--lint"
"src"
"test"
"toucan1/src"
"toucan1/test"]}

;; Run tests against the value of `TEST_DBS`, by default `postgres,h2,mariadb`.
;;
;; clojure -X:dev:test
Expand Down Expand Up @@ -102,7 +124,10 @@

;; clj -X:dev:cloverage
:cloverage
{:extra-deps {cloverage/cloverage {:mvn/version "1.2.4"}}
{:extra-deps
{cloverage/cloverage {:mvn/version "1.2.4"}
com.github.seancorfield/honeysql {:sha "bf34a23e6874c0c7c03b81e69b9eaddf06c2caa9"}} ; override pinned version with fix for https://github.com/seancorfield/honeysql/issues/537 which is not released yet

:exec-fn toucan2.cloverage-runner/run-project
:exec-args {:codecov? true

Expand Down
Loading