diff --git a/.circleci/config.yml b/.circleci/config.yml index 704ab90..380624e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,42 +9,36 @@ workflows: - tools/setup: context: dockerhub-deploy setup_cljs: false - - tools/format: + - tools/build: context: dockerhub-deploy + build_cljs: false requires: - tools/setup - - tools/integrationtest-postgresql-mysql-mssql: + - tools/format: context: dockerhub-deploy requires: - tools/setup - - tools/build: - jarname: "datahike-jdbc" + - tools/integrationtest-postgresql-mysql-mssql: context: dockerhub-deploy requires: - - tools/setup - - tools/deploy-snapshot: - jarname: "datahike-jdbc" + - tools/format + - tools/build + - tools/deploy: context: - clojars-deploy - dockerhub-deploy filters: branches: - only: development + only: main requires: - - tools/setup - - tools/format - tools/integrationtest-postgresql-mysql-mssql - - tools/build - - tools/deploy-release: - jarname: "datahike-jdbc" + - tools/release: context: - - clojars-deploy + - github-token - dockerhub-deploy filters: branches: - only: master + only: main requires: - - tools/setup - - tools/format - - tools/integrationtest-postgresql-mysql-mssql - - tools/build + - tools/deploy + diff --git a/.github/FUNDING.yaml b/.github/FUNDING.yaml new file mode 100644 index 0000000..bbeb446 --- /dev/null +++ b/.github/FUNDING.yaml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: replikativ diff --git a/bin/run-integrationtests b/bin/run-integrationtests index 7398ec9..2846a66 100755 --- a/bin/run-integrationtests +++ b/bin/run-integrationtests @@ -5,36 +5,18 @@ set -o pipefail trap teardown EXIT -function setup_PG() { +function setup() { if [ -z ${CIRCLECI} ]; then - echo $(docker run --detach --publish 5432:5432 --env POSTGRES_DB=config-test --env POSTGRES_USER=alice --env POSTGRES_PASSWORD=foo docker.io/postgres:15) - fi -} - -function setup_MYSQL() { - if [ -z ${CIRCLECI} ]; then - echo $(docker run --detach --publish 3306:3306 --env MYSQL_RANDOM_ROOT_PASSWORD=true --env MYSQL_DATABASE=config-test --env MYSQL_USER=alice --env MYSQL_PASSWORD=foo docker.io/mysql:8) - fi -} - -function setup_MSSQL() { - if [ -z ${CIRCLECI} ]; then - echo $(docker run --detach --publish 1433:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD=passwordA1! --env MSSQL_PID=Developer --env MSSQL_TCP_PORT=1433 mcr.microsoft.com/mssql/server:2019-latest) + echo $(docker-compose -f ./docker-compose.yml up --detach) fi } function teardown() { if [ -z ${CIRCLECI} ]; then - docker rm -f ${PG_NAME} - docker rm -f ${MYSQL_NAME} - docker rm -f ${MSSQL_NAME} + docker-compose -f ./docker-compose.yml down fi } -PG_NAME=$(setup_PG) -MYSQL_NAME=$(setup_MYSQL) -MSSQL_NAME=$(setup_MSSQL) - -sleep 5 +setup TIMBRE_LEVEL=':warn' DATAHIKE_STORE_BACKEND=jdbc DATAHIKE_STORE_CONFIG='{:dbtype "h2" :dbname "datahike"}' clojure -M:test diff --git a/build.clj b/build.clj new file mode 100644 index 0000000..1c4d98b --- /dev/null +++ b/build.clj @@ -0,0 +1,83 @@ +(ns build + (:refer-clojure :exclude [test]) + (:require [clojure.tools.build.api :as b] + [borkdude.gh-release-artifact :as gh] + [deps-deploy.deps-deploy :as dd]) + (:import [clojure.lang ExceptionInfo])) + +(def org "replikativ") +(def lib 'io.replikativ/datahike-jdbc) +(def current-commit (b/git-process {:git-args "rev-parse HEAD"})) +(def version (format "0.1.%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 + [_] + (b/delete {:path "target"})) + +(defn jar + [_] + (b/write-pom {:class-dir class-dir + :src-pom "./template/pom.xml" + :lib lib + :version version + :basis basis + :src-dirs ["src"]}) + (b/copy-dir {:src-dirs ["src" "resources"] + :target-dir class-dir}) + (b/jar {:class-dir class-dir + :jar-file jar-file})) + +(defn deploy + "Don't forget to set CLOJARS_USERNAME and CLOJARS_PASSWORD env vars." + [_] + (dd/deploy {:installer :remote :artifact jar-file + :pom-file (b/pom-path {:lib lib :class-dir class-dir})})) + +(defn fib [a b] + (lazy-seq (cons a (fib b (+ a b))))) + +(defn retry-with-fib-backoff [retries exec-fn test-fn] + (loop [idle-times (take retries (fib 1 2))] + (let [result (exec-fn)] + (if (test-fn result) + (do (println "Returned: " result) + (if-let [sleep-ms (first idle-times)] + (do (println "Retrying with remaining back-off times (in s): " idle-times) + (Thread/sleep (* 1000 sleep-ms)) + (recur (rest idle-times))) + result)) + result)))) + +(defn try-release [] + (try (gh/overwrite-asset {:org org + :repo (name lib) + :tag version + :commit current-commit + :file jar-file + :content-type "application/java-archive" + :draft false}) + (catch ExceptionInfo e + (assoc (ex-data e) :failure? true)))) + +(defn release + [_] + (println "Trying to release artifact...") + (let [ret (retry-with-fib-backoff 10 try-release :failure?)] + (if (:failure? ret) + (do (println "GitHub release failed!") + (System/exit 1)) + (println (:url ret))))) + +(defn install + [_] + (clean nil) + (jar nil) + (b/install {:basis (b/create-basis {}) + :lib lib + :version version + :jar-file jar-file + :class-dir class-dir})) + diff --git a/deps.edn b/deps.edn index e9a9c3c..916e098 100644 --- a/deps.edn +++ b/deps.edn @@ -1,29 +1,21 @@ -{:deps {org.clojure/clojure {:mvn/version "1.11.1" :scope "provided"} - io.replikativ/konserve-jdbc {:mvn/version "0.1.1"}} +{:deps {org.clojure/clojure {:mvn/version "1.11.1" :scope "provided"} + io.replikativ/konserve-jdbc {:mvn/version "0.1.79"}} :paths ["src"] :aliases {:test {:extra-paths ["test"] - :extra-deps {lambdaisland/kaocha {:mvn/version "1.60.977"} - io.replikativ/datahike {:mvn/version "RELEASE"}} + :extra-deps {lambdaisland/kaocha {:mvn/version "1.84.1335"} + io.replikativ/datahike {:mvn/version "0.6.1541"}} :main-opts ["-m" "kaocha.runner"]} - :repl {:extra-deps {cider/cider-nrepl {:mvn/version "0.27.4"} - nrepl/nrepl {:mvn/version "0.9.0"} - org.clojure/tools.namespace {:mvn/version "1.2.0"}} - :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]} - - :jar {:extra-deps {com.github.seancorfield/depstar {:mvn/version "1.1.136"}} - :main-opts ["-m" "hf.depstar.jar" "replikativ-konserve-jdbc.jar"]} - - :deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.0"}} - :main-opts ["-m" "deps-deploy.deps-deploy" "deploy" "replikativ-datahike-jdbc.jar"]} - - :install {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.0"}} - :exec-fn deps-deploy.deps-deploy/deploy - :exec-args {:installer :local - :artifact "replikativ-datahike-jdbc.jar"}} - - :format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}} + :format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.9.2"}} :main-opts ["-m" "cljfmt.main" "check"]} - :ffix {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}} - :main-opts ["-m" "cljfmt.main" "fix"]}}} + :ffix {:extra-deps {cljfmt/cljfmt {:mvn/version "0.9.2"}} + :main-opts ["-m" "cljfmt.main" "fix"]} + + :build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.3"} + slipset/deps-deploy {:mvn/version "0.2.0"} + io.github.borkdude/gh-release-artifact {:git/sha "05f8d8659e6805d513c59447ff41dc8497878462"} + babashka/babashka.curl {:mvn/version "0.1.2"} + babashka/fs {:mvn/version "0.1.6"} + cheshire/cheshire {:mvn/version "5.10.2"}} + :ns-default build}}} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..777630d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3.3' + +services: + mysql: + image: docker.io/mysql:8 + restart: always + command: --max_allowed_packet=32505856 + environment: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: config-test + MYSQL_USER: alice + MYSQL_PASSWORD: foo + ports: + - 3306:3306 + + postgres: + image: docker.io/postgres:14 + restart: always + environment: + POSTGRES_DB: config-test + POSTGRES_USER: alice + POSTGRES_PASSWORD: foo + ports: + - "5432:5432" + + mssql: + image: mcr.microsoft.com/mssql/server:2019-latest + restart: always + environment: + ACCEPT_EULA: Y + SA_PASSWORD: passwordA1! + MSSQL_PID: Developer + MSSQL_TCP_PORT: 1433 + ports: + - 1433:1433 diff --git a/pom.xml b/template/pom.xml similarity index 66% rename from pom.xml rename to template/pom.xml index f725dce..700380f 100644 --- a/pom.xml +++ b/template/pom.xml @@ -1,12 +1,11 @@ 4.0.0 - io.replikativ + org.clojars.timokramer datahike-jdbc jar datahike-jdbc A JDBC backend for Datahike - 0.1.2 https://datahike.io @@ -19,23 +18,6 @@ scm:git:git@github.com/replikativ/datahike-jdbc.git https://github.com/replikativ/datahike-jdbc - - - org.clojure - clojure - 1.10.3 - - - io.replikativ - konserve-jdbc - 0.1.1 - - - io.replikativ - superv.async - 0.2.11 - - src