Merge remote-tracking branch 'upstream/develop' into lread-issue-290
Adapt to build changes. * upstream/develop: Switch to build-clj lib
This commit is contained in:
commit
4eb9eca147
2 changed files with 29 additions and 80 deletions
93
build.clj
93
build.clj
|
|
@ -9,49 +9,17 @@
|
|||
For more information, run:
|
||||
|
||||
clojure -A:deps -T:build help/doc"
|
||||
|
||||
(:require [babashka.fs :as fs]
|
||||
[clojure.tools.build.api :as b]
|
||||
[clojure.tools.deps.alpha :as t]
|
||||
[deps-deploy.deps-deploy :as dd]
|
||||
[org.corfield.build :as bb]
|
||||
[lread.test-doc-blocks :as tdb]))
|
||||
|
||||
(def lib 'com.github.seancorfield/honeysql)
|
||||
(def version (format "2.0.%s" (b/git-count-revs nil)))
|
||||
(def class-dir "target/classes")
|
||||
(def basis (b/create-basis {:project "deps.edn"}))
|
||||
(def jar-file (format "target/%s-%s.jar" (name lib) version))
|
||||
|
||||
(defn clean "Remove the target folder." [_]
|
||||
(println "\nCleaning target...")
|
||||
(b/delete {:path "target"}))
|
||||
|
||||
(defn jar "Build the library JAR file." [_]
|
||||
(println "\nWriting pom.xml...")
|
||||
(b/write-pom {:class-dir class-dir
|
||||
:lib lib
|
||||
:version version
|
||||
:scm {:tag (str "v" version)}
|
||||
:basis basis
|
||||
:src-dirs ["src"]})
|
||||
(println "Copying src...")
|
||||
(b/copy-dir {:src-dirs ["src"]
|
||||
:target-dir class-dir})
|
||||
(println (str "Building jar " jar-file "..."))
|
||||
(b/jar {:class-dir class-dir
|
||||
:jar-file jar-file}))
|
||||
|
||||
(defn- run-task
|
||||
[aliases]
|
||||
(println "\nRunning task for:" aliases)
|
||||
(let [basis (b/create-basis {:aliases aliases})
|
||||
combined (t/combine-aliases basis aliases)
|
||||
cmds (b/java-command {:basis basis
|
||||
:java-opts (:jvm-opts combined)
|
||||
:main 'clojure.main
|
||||
:main-args (:main-opts combined)})
|
||||
{:keys [exit]} (b/process cmds)]
|
||||
(when-not (zero? exit)
|
||||
(throw (ex-info (str "Task failed for: " aliases) {})))))
|
||||
(defn eastwood "Run Eastwood." [opts]
|
||||
(-> opts (bb/run-task [:eastwood])))
|
||||
|
||||
(defn gen-doc-tests "Generate tests from doc code blocks" [opts]
|
||||
(let [docs ["README.md"
|
||||
|
|
@ -70,56 +38,41 @@
|
|||
(println "gen-doc-tests: Tests already generated")))
|
||||
opts)
|
||||
|
||||
(defn eastwood "Run Eastwood." [opts] (run-task [:eastwood]) opts)
|
||||
|
||||
(defn run-tests
|
||||
"Run regular tests.
|
||||
|
||||
Optionally specify :aliases:
|
||||
[: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 [aliases] :as opts}]
|
||||
(run-task (into [:test] aliases))
|
||||
opts)
|
||||
|
||||
(defn run-doc-tests
|
||||
"Run generated doc tests.
|
||||
"Generate and run doc tests.
|
||||
|
||||
Optionally specify :platform:
|
||||
Optionally specify :plaftorm:
|
||||
: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)
|
||||
(let [aliases (case platform
|
||||
:cljs [platform :test-doc :test-doc-cljs]
|
||||
[platform :runner :test-doc :test-doc-clj])]
|
||||
(run-task aliases))
|
||||
opts)
|
||||
(bb/run-tests (assoc opts :aliases
|
||||
(conj [:test-doc platform]
|
||||
(if (= :cljs platform)
|
||||
:test-doc-cljs
|
||||
:test-doc-clj)))))
|
||||
|
||||
(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
|
||||
(-> opts
|
||||
(clean)
|
||||
(bb/clean)
|
||||
(assoc :lib lib :version version)
|
||||
(as-> opts
|
||||
(reduce (fn [opts platform]
|
||||
(run-doc-tests (assoc opts :platform platform)))
|
||||
opts
|
||||
[:cljs :1.9 :1.10 :master]))
|
||||
(reduce (fn [opts platform]
|
||||
(run-doc-tests (assoc opts :platform platform)))
|
||||
opts
|
||||
[:cljs :1.9 :1.10 :master]))
|
||||
(eastwood)
|
||||
(as-> opts
|
||||
(reduce (fn [opts alias]
|
||||
(run-tests (assoc opts :aliases (cond-> [alias]
|
||||
(not= :cljs alias)
|
||||
(conj :runner)))))
|
||||
(bb/run-tests (assoc opts :aliases [alias])))
|
||||
opts
|
||||
[:cljs :1.9 :1.10 :master]))
|
||||
(clean)
|
||||
(jar)))
|
||||
(bb/clean)
|
||||
(bb/jar)))
|
||||
|
||||
(defn deploy "Deploy the JAR to Clojars." [opts]
|
||||
(dd/deploy (merge {:installer :remote :artifact jar-file
|
||||
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}
|
||||
opts)))
|
||||
(-> opts
|
||||
(assoc :lib lib :version version)
|
||||
(bb/deploy)))
|
||||
|
|
|
|||
16
deps.edn
16
deps.edn
|
|
@ -5,8 +5,7 @@
|
|||
{;; for help: clojure -A:deps -T:build help/doc
|
||||
:build {:deps {babashka/fs {:mvn/version "0.0.5"}
|
||||
com.github.lread/test-doc-blocks {:mvn/version "1.0.137-alpha"}
|
||||
io.github.clojure/tools.build {:git/tag "v0.1.9" :git/sha "6736c83"}
|
||||
io.github.slipset/deps-deploy {:sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}}
|
||||
io.github.seancorfield/build-clj {:git/tag "v0.1.0" :git/sha "fe2d586"}}
|
||||
:ns-default build}
|
||||
|
||||
;; versions to test against:
|
||||
|
|
@ -15,20 +14,17 @@
|
|||
:master {:override-deps {org.clojure/clojure {:mvn/version "1.11.1-master-SNAPSHOT"}}}
|
||||
|
||||
;; running tests/checks of various kinds:
|
||||
|
||||
:test {:extra-paths ["test"]}
|
||||
|
||||
:runner ; can also run clojure -X:test
|
||||
{:extra-deps {io.github.cognitect-labs/test-runner
|
||||
:test
|
||||
{:extra-paths ["test"]
|
||||
:extra-deps {io.github.cognitect-labs/test-runner
|
||||
{:git/tag "v0.4.0" :git/sha "334f2e2"}}
|
||||
:main-opts ["-m" "cognitect.test-runner"]
|
||||
:exec-fn cognitect.test-runner.api/test}
|
||||
|
||||
;; various "runners" for tests/CI:
|
||||
;; various "runners" for tests/CI:
|
||||
:cljs {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}}
|
||||
:main-opts ["-m" "cljs-test-runner.main"]}
|
||||
|
||||
:test-doc {:extra-paths ["target/test-doc-blocks/test"]}
|
||||
:test-doc {:replace-paths ["src" "target/test-doc-blocks/test"]}
|
||||
:test-doc-clj {:main-opts ["-m" "cognitect.test-runner"
|
||||
"-d" "target/test-doc-blocks/test"]}
|
||||
:test-doc-cljs {:main-opts ["-m" "cljs-test-runner.main"
|
||||
|
|
|
|||
Loading…
Reference in a new issue