diff --git a/.circleci/config.yml b/.circleci/config.yml index 466468f..5486a6f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,129 +1,38 @@ version: 2.1 -executors: - leiningen: - docker: - - image: circleci/clojure:openjdk-8-lein-2.9.3 - environment: - LEIN_ROOT: nbd - JVM_OPTS: -Xmx3200m - working_directory: /home/circleci/datahike-jdbc - -jobs: - setup: - executor: leiningen - steps: - - restore_cache: - keys: - - source-{{ .Branch }}-{{ .Revision }} - - source-{{ .Branch }} - - source- - - checkout - - save_cache: - key: source-{{ .Branch }}-{{ .Revision }} - paths: - - .git - - restore_cache: - keys: - - deps-{{ checksum "project.clj" }} - - deps- - - run: lein deps - - save_cache: - key: deps-{{ checksum "project.clj" }} - paths: - - /home/circleci/.m2 - - /home/circleci/.lein - - persist_to_workspace: - root: /home/circleci/ - paths: - - .m2 - - datahike-jdbc - - bin - - integrationtest: - executor: leiningen - docker: - - image: circleci/clojure:openjdk-8-lein-2.9.3 - - image: circleci/postgres:11-alpine - environment: - POSTGRES_USER: alice - POSTGRES_PASSWORD: foo - POSTGRES_DB: config-test - - image: circleci/mariadb:10.4 - environment: - MYSQL_USER: alice - MYSQL_PASSWORD: foo - MYSQL_DATABASE: config-test - MYSQL_RANDOM_ROOT_PASSWORD: true - steps: - - attach_workspace: - at: /home/circleci - - run: - name: Run Integrationtests - command: lein test - no_output_timeout: 5m - - build: - executor: leiningen - steps: - - attach_workspace: - at: /home/circleci - - run: - name: Build - command: lein uberjar - no_output_timeout: 5m - - deploy-snapshot: - executor: leiningen - steps: - - attach_workspace: - at: /home/circleci - - run: - command: | - VERSION=$(head -n 1 project.clj | awk '{print $3}' | tr -d \") - if [[ ${VERSION} =~ .*-SNAPSHOT ]]; then - lein deploy clojars - else - exit 0 - fi - deploy-release: - executor: leiningen - steps: - - attach_workspace: - at: /home/circleci - - run: - name: Deploy Release to Clojars - command: | - VERSION=$(head -n 1 project.clj | awk '{print $3}' | tr -d \") - if [[ ${VERSION} =~ .*-SNAPSHOT ]]; then - exit 0 - else - lein deploy clojars - fi +orbs: + lein: replikativ/clj-lein@0 workflows: - build_and_test: + build-test-and-deploy: jobs: - - setup - - integrationtest: + - lein/setup + - lein/format: + requires: + - lein/setup + - lein/integrationtest-postgresql-mariadb: requires: - - setup - - build: + - lein/setup + - lein/build: requires: - - setup - - deploy-snapshot: + - lein/setup + - lein/deploy-snapshot: + context: clojars-deploy filters: branches: only: development requires: - - setup - - integrationtest - - build - - deploy-release: + - lein/setup + - lein/format + - lein/build + - lein/integrationtest-postgresql-mariadb + - lein/deploy-release: + context: clojars-deploy filters: branches: only: master requires: - - setup - - integrationtest - - build + - lein/setup + - lein/format + - lein/build + - lein/integrationtest-postgresql-mariadb diff --git a/.gitignore b/.gitignore index 8df535f..1493d95 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ pom.xml.asc .nrepl-port .cpcache/ temp/ +datahike.mv.db diff --git a/README.md b/README.md index b62d891..a310d33 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ DATAHIKE_STORE_BACKEND=jdbc DATAHIKE_STORE_CONFIG='{:dbtype "postgresql" :user "datahike" :password "datahike" :dbname "datahike"}' ``` +It is also possible to pass a configuration url via `:jdbcUrl` like it is mentioned in the underlying library [next.jdbc](https://cljdoc.org/d/seancorfield/next.jdbc/1.0.462/doc/getting-started#the-db-spec-hash-map). The Url can pass additional arguments in the query part or you can combine the url with arguments passed as key-value-pairs. + +Arguments not mentioned will be passed downstream to the corresponding jdbc-driver so every configuration option available should be working. + ## Prerequisites For this backend to work you need to choose a database that is supported by JDBC. Please have a look at the docs for [clojure.java.jdbc](https://github.com/clojure/java.jdbc/). For the sake diff --git a/bin/run-integration-tests b/bin/run-integrationtests similarity index 89% rename from bin/run-integration-tests rename to bin/run-integrationtests index c46fdfd..aba3c9d 100755 --- a/bin/run-integration-tests +++ b/bin/run-integrationtests @@ -7,7 +7,7 @@ trap teardown EXIT function setup_PG() { if [ -z ${CIRCLECI} ]; then - echo $(docker run --detach --publish 5432:5432 --env POSTGRES_DB=config-test --env POSTGRES_USER=alice --env POSTGRES_PASSWORD=foo postgres:11-alpine) + echo $(docker run --detach --publish 5432:5432 --env POSTGRES_DB=config-test --env POSTGRES_USER=alice --env POSTGRES_PASSWORD=foo postgres:12-alpine) fi } @@ -29,4 +29,4 @@ MARIA_NAME=$(setup_MARIA) sleep 5 -TIMBRE_LEVEL=':warn' DATAHIKE_STORE_BACKEND=jdbc DATAHIKE_STORE_CONFIG='{:dbtype "h2:mem" :dbname "datahike"}' lein test +TIMBRE_LEVEL=':warn' DATAHIKE_STORE_BACKEND=jdbc DATAHIKE_STORE_CONFIG='{:dbtype "h2" :dbname "datahike"}' lein test diff --git a/src/datahike_jdbc/core.clj b/src/datahike_jdbc/core.clj index 133e751..521b41b 100644 --- a/src/datahike_jdbc/core.clj +++ b/src/datahike_jdbc/core.clj @@ -3,9 +3,7 @@ [datahike.config :refer [map-from-env]] [hitchhiker.tree.bootstrap.konserve :as kons] [konserve-jdbc.core :as k] - [environ.core :refer [env]] [clojure.spec.alpha :as s] - [clojure.edn :as edn] [superv.async :refer [