switch to tools.build for ci

This commit is contained in:
Sean Corfield 2021-08-12 19:43:04 -07:00
parent 237ff37988
commit 4b50f19e39
5 changed files with 33 additions and 14 deletions

View file

@ -10,10 +10,10 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
key: next-jdbc-{{ checksum "deps.edn" }} key: next-jdbc-{{ checksum "deps.edn" }}
- run: clojure -P -A:test - run: clojure -P -M:build:test
- save_cache: - save_cache:
paths: paths:
- ~/.m2 - ~/.m2
- ~/.gitlibs - ~/.gitlibs
key: next-jdbc-{{ checksum "deps.edn" }} key: next-jdbc-{{ checksum "deps.edn" }}
- run: clojure -X:test - run: clojure -T:build ci

View file

@ -19,7 +19,7 @@ jobs:
with: with:
tools-deps: '1.10.3.933' tools-deps: '1.10.3.933'
- name: Run Tests - name: Run Tests
run: clojure -X:test run: clojure -T:build ci
build-graalvm-old: build-graalvm-old:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -39,7 +39,7 @@ jobs:
with: with:
tools-deps: '1.10.3.933' tools-deps: '1.10.3.933'
- name: Run Tests - name: Run Tests
run: clojure -X:test run: clojure -T:build ci
build-graalvm-new: build-graalvm-new:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -59,4 +59,4 @@ jobs:
with: with:
tools-deps: '1.10.3.933' tools-deps: '1.10.3.933'
- name: Run Tests - name: Run Tests
run: clojure -X:test run: clojure -T:build ci

View file

@ -2,6 +2,9 @@
Only accretive/fixative changes will be made from now on. Only accretive/fixative changes will be made from now on.
* 1.2.next in progress
* Switch to `tools.build` for running tests and JAR building etc.
* 1.2.689 -- 2021-08-01 * 1.2.689 -- 2021-08-01
* Address #173 by extending `DatafiableRow` to `ResultSet` so there's a public method to call on (rows of) a JDBC result set directly. * Address #173 by extending `DatafiableRow` to `ResultSet` so there's a public method to call on (rows of) a JDBC result set directly.
* Address #171 by clarifying that you cannot use `clojure.java.jdbc` functions inside `next.jdbc/with-transaction` and discuss how to migrate transaction-based code in the **Migration** guide. * Address #171 by clarifying that you cannot use `clojure.java.jdbc` functions inside `next.jdbc/with-transaction` and discuss how to migrate transaction-based code in the **Migration** guide.

View file

@ -1,4 +1,13 @@
(ns build (ns build
"next.jdbc's build script.
clojure -T:build run-tests
clojure -T:build ci
For more information, run:
clojure -A:deps -T:build help/doc"
(:require [clojure.tools.build.api :as b] (:require [clojure.tools.build.api :as b]
[clojure.tools.deps.alpha :as t])) [clojure.tools.deps.alpha :as t]))
@ -8,11 +17,11 @@
(def basis (b/create-basis {:project "deps.edn"})) (def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version)) (def jar-file (format "target/%s-%s.jar" (name lib) version))
(defn clean [_] (defn clean "Remove the target folder." [_]
(println "\nCleaning target...") (println "\nCleaning target...")
(b/delete {:path "target"})) (b/delete {:path "target"}))
(defn jar [_] (defn jar "Build the library JAR file." [_]
(println "\nWriting pom.xml...") (println "\nWriting pom.xml...")
(b/write-pom {:class-dir class-dir (b/write-pom {:class-dir class-dir
:lib lib :lib lib
@ -26,8 +35,7 @@
(b/jar {:class-dir class-dir (b/jar {:class-dir class-dir
:jar-file jar-file})) :jar-file jar-file}))
(defn run-tests (defn run-tests "Run regular tests." [_]
[_]
(let [basis (b/create-basis {:aliases [:test]}) (let [basis (b/create-basis {:aliases [:test]})
combined (t/combine-aliases basis [:test]) combined (t/combine-aliases basis [:test])
cmds (b/java-command {:basis basis cmds (b/java-command {:basis basis
@ -38,5 +46,5 @@
(when-not (zero? exit) (when-not (zero? exit)
(throw (ex-info "Tests failed" {}))))) (throw (ex-info "Tests failed" {})))))
(defn ci [opts] (defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
(-> opts (run-tests) (clean) (jar))) (-> opts (run-tests) (clean) (jar)))

View file

@ -4,8 +4,11 @@
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}} camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}}
:aliases :aliases
{:build {:deps {io.github.clojure/tools.build {:git/tag "v0.1.7" :git/sha "8a3abc2"}} {;; for help: clojure -A:deps -T:build help/doc
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.1.7" :git/sha "8a3abc2"}}
:ns-default build} :ns-default build}
;; running tests/checks of various kinds:
:test {:extra-paths ["test"] :test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"} :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
io.github.cognitect-labs/test-runner io.github.cognitect-labs/test-runner
@ -40,9 +43,14 @@
org.apache.logging.log4j/log4j-jul {:mvn/version "2.14.1"} org.apache.logging.log4j/log4j-jul {:mvn/version "2.14.1"}
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.14.1"}} org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.14.1"}}
:jvm-opts ["-Dlog4j2.configurationFile=log4j2-info.properties"] :jvm-opts ["-Dlog4j2.configurationFile=log4j2-info.properties"]
:exec-fn cognitect.test-runner.api/test} ;; so we can run both ways:
:exec-fn cognitect.test-runner.api/test
:main-opts ["-m" "cognitect.test-runner"]}
;; first run: clojure -T:build ci
;; then: clojure -T:deploy target/n<TAB>
:deploy :deploy
{:replace-deps {slipset/deps-deploy {:git/url "https://github.com/slipset/deps-deploy" {:deps {slipset/deps-deploy {:git/url "https://github.com/slipset/deps-deploy"
:sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}} :sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}}
:exec-fn deps-deploy.deps-deploy/deploy :exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote :exec-args {:installer :remote