2021-08-13 02:20:02 +00:00
|
|
|
(ns build
|
|
|
|
|
"HoneySQL's build script.
|
|
|
|
|
|
|
|
|
|
clojure -T:build run-tests
|
|
|
|
|
clojure -T:build run-tests :aliases '[:master]'
|
|
|
|
|
|
|
|
|
|
clojure -T:build ci
|
|
|
|
|
|
|
|
|
|
For more information, run:
|
|
|
|
|
|
|
|
|
|
clojure -A:deps -T:build help/doc"
|
2021-08-28 21:04:36 +00:00
|
|
|
|
2021-08-27 22:16:18 +00:00
|
|
|
(:require [babashka.fs :as fs]
|
|
|
|
|
[clojure.tools.build.api :as b]
|
2021-08-28 21:04:36 +00:00
|
|
|
[org.corfield.build :as bb]
|
2021-08-27 22:16:18 +00:00
|
|
|
[lread.test-doc-blocks :as tdb]))
|
2021-08-13 02:20:02 +00:00
|
|
|
|
|
|
|
|
(def lib 'com.github.seancorfield/honeysql)
|
|
|
|
|
(def version (format "2.0.%s" (b/git-count-revs nil)))
|
|
|
|
|
|
2021-08-28 05:51:49 +00:00
|
|
|
(defn eastwood "Run Eastwood." [opts]
|
|
|
|
|
(-> opts (bb/run-task [:eastwood])))
|
2021-08-13 02:20:02 +00:00
|
|
|
|
2021-08-27 22:16:18 +00:00
|
|
|
(defn gen-doc-tests "Generate tests from doc code blocks" [opts]
|
2021-08-30 21:56:42 +00:00
|
|
|
(let [target "target/test-doc-blocks"
|
|
|
|
|
success-marker (fs/file target "SUCCESS")
|
|
|
|
|
docs ["README.md"
|
2021-08-27 22:16:18 +00:00
|
|
|
"doc/clause-reference.md"
|
|
|
|
|
"doc/differences-from-1-x.md"
|
|
|
|
|
"doc/extending-honeysql.md"
|
|
|
|
|
"doc/general-reference.md"
|
|
|
|
|
"doc/getting-started.md"
|
|
|
|
|
"doc/postgresql.md"
|
|
|
|
|
"doc/special-syntax.md"]
|
2021-08-30 21:56:42 +00:00
|
|
|
regen-reason (if (not (fs/exists? success-marker))
|
|
|
|
|
"a previous successful gen result not found"
|
|
|
|
|
(let [newer-thans (fs/modified-since target
|
|
|
|
|
(concat docs
|
|
|
|
|
["build.clj" "deps.edn"]
|
|
|
|
|
(fs/glob "src" "**/*.*")))]
|
|
|
|
|
(when (seq newer-thans)
|
|
|
|
|
(str "found files newer than last gen: " (mapv str newer-thans)))))]
|
|
|
|
|
(if regen-reason
|
2021-08-27 22:16:18 +00:00
|
|
|
(do
|
2021-08-30 21:56:42 +00:00
|
|
|
(fs/delete-if-exists success-marker)
|
|
|
|
|
(println "gen-doc-tests: Regenerating:" regen-reason)
|
|
|
|
|
(tdb/gen-tests {:docs docs})
|
|
|
|
|
(spit success-marker "SUCCESS"))
|
|
|
|
|
(println "gen-doc-tests: Tests already successfully generated")))
|
2021-08-27 22:16:18 +00:00
|
|
|
opts)
|
2021-08-13 02:20:02 +00:00
|
|
|
|
2021-08-27 22:16:18 +00:00
|
|
|
(defn run-doc-tests
|
2021-08-28 21:04:36 +00:00
|
|
|
"Generate and run doc tests.
|
2021-08-27 22:16:18 +00:00
|
|
|
|
2021-08-28 21:04:36 +00:00
|
|
|
Optionally specify :plaftorm:
|
2021-08-27 22:16:18 +00:00
|
|
|
:1.9 -- test against Clojure 1.9 (the default)
|
|
|
|
|
:1.10 -- test against Clojure 1.10.3
|
|
|
|
|
:master -- test against Clojure 1.11 master snapshot
|
|
|
|
|
:cljs -- test against ClojureScript"
|
|
|
|
|
[{:keys [platform] :or {platform :1.9} :as opts}]
|
|
|
|
|
(gen-doc-tests opts)
|
2021-08-28 21:04:36 +00:00
|
|
|
(bb/run-tests (assoc opts :aliases
|
|
|
|
|
(conj [:test-doc platform]
|
|
|
|
|
(if (= :cljs platform)
|
|
|
|
|
:test-doc-cljs
|
|
|
|
|
:test-doc-clj)))))
|
2021-08-27 22:16:18 +00:00
|
|
|
|
2021-08-13 02:20:02 +00:00
|
|
|
(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
|
|
|
|
|
(-> opts
|
2021-08-28 21:04:36 +00:00
|
|
|
(bb/clean)
|
2021-08-28 05:51:49 +00:00
|
|
|
(assoc :lib lib :version version)
|
2021-08-27 22:16:18 +00:00
|
|
|
(as-> opts
|
2021-08-28 21:04:36 +00:00
|
|
|
(reduce (fn [opts platform]
|
|
|
|
|
(run-doc-tests (assoc opts :platform platform)))
|
|
|
|
|
opts
|
|
|
|
|
[:cljs :1.9 :1.10 :master]))
|
2021-08-13 02:20:02 +00:00
|
|
|
(eastwood)
|
|
|
|
|
(as-> opts
|
|
|
|
|
(reduce (fn [opts alias]
|
2021-08-28 05:51:49 +00:00
|
|
|
(bb/run-tests (assoc opts :aliases [alias])))
|
2021-08-13 02:20:02 +00:00
|
|
|
opts
|
2021-08-13 02:21:35 +00:00
|
|
|
[:cljs :1.9 :1.10 :master]))
|
2021-08-28 05:51:49 +00:00
|
|
|
(bb/clean)
|
|
|
|
|
(bb/jar)))
|
2021-08-23 02:30:04 +00:00
|
|
|
|
|
|
|
|
(defn deploy "Deploy the JAR to Clojars." [opts]
|
2021-08-28 05:51:49 +00:00
|
|
|
(-> opts
|
|
|
|
|
(assoc :lib lib :version version)
|
|
|
|
|
(bb/deploy)))
|