diff --git a/.circleci/config.yml b/.circleci/config.yml index 163818f2b..1ccaa95e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -138,13 +138,39 @@ jobs: - attach_workspace: at: /home/circleci - run: - name: Run unittests for hitchhiker-tree index + name: Run unittests with specs activated command: bb test specs no_output_timeout: 5m - save_cache: key: deps-{{ checksum "deps.edn" }} paths: - /home/circleci/.m2 + clj-1-10-test: + executor: tools/clojurecli + steps: + - attach_workspace: + at: /home/circleci + - run: + name: Run unittests with clojure 1.10.0 + command: bb test clj :1.10 + no_output_timeout: 5m + - save_cache: + key: deps-{{ checksum "deps.edn" }} + paths: + - /home/circleci/.m2 + clj-1-9-test: + executor: tools/clojurecli + steps: + - attach_workspace: + at: /home/circleci + - run: + name: Run unittests with clojure 1.9.0 + command: bb test clj :1.9 + no_output_timeout: 5m + - save_cache: + key: deps-{{ checksum "deps.edn" }} + paths: + - /home/circleci/.m2 native-image-test: executor: tools/clojurecli steps: @@ -243,6 +269,18 @@ workflows: context: dockerhub-deploy requires: - build + - spec-test: + context: dockerhub-deploy + requires: + - build + - clj-1-10-test: + context: dockerhub-deploy + requires: + - build + - clj-1-9-test: + context: dockerhub-deploy + requires: + - build - native-image-test: context: dockerhub-deploy requires: @@ -268,6 +306,9 @@ workflows: - format - persistent-set-test - hitchhiker-tree-test + - spec-test + - clj-1-10-test + - clj-1-9-test - backward-compatibility-test - native-image-test - integration-test diff --git a/bb/src/tools/test.clj b/bb/src/tools/test.clj index 22a54712b..b3f03c78f 100644 --- a/bb/src/tools/test.clj +++ b/bb/src/tools/test.clj @@ -2,15 +2,12 @@ (:refer-clojure :exclude [test]) (:require [babashka.fs :as fs] [babashka.process :as p] + [clojure.string :as str] [tools.build :as build])) (defn clj [opts & args] (apply p/shell opts "clojure" args)) (defn git [opts & args] (apply p/shell opts "git" args)) -(defn kaocha [& args] - (apply clj {:extra-env {"TIMBRE_LEVEL" ":warn"}} - "-M:test" "-m" "kaocha.runner" args)) - (defn back-compat [config] (println "Testing backwards compatibility") (let [old-version-dir "datahike-old" @@ -49,12 +46,27 @@ (p/shell "./bb/resources/native-image-tests/run-native-image-tests") (println "Native image cli missing. Please run 'bb ni-cli' and try again."))) +(defn kaocha-with-aliases [aliases & args] + (apply clj {:extra-env {"TIMBRE_LEVEL" ":warn"}} + (str "-M:test" (str/join (map #(str ":" (name %)) aliases))) + "-m" "kaocha.runner" args)) + +(defn kaocha [& args] + (apply kaocha-with-aliases [] args)) + (defn specs [] (kaocha "--focus" "specs" "--plugin" "kaocha.plugin/orchestra")) +(defn clj-back-compat + "version-alias must be defined in deps.edn" + [version-alias & args] + (apply kaocha-with-aliases [version-alias] args)) + (defn all [config] (kaocha "--skip" "specs") (specs) + (clj-back-compat :1.10) + (clj-back-compat :1.9) (back-compat config) (native-image)) @@ -63,6 +75,7 @@ (case (first args) "native-image" (native-image) "back-compat" (back-compat config) + "clj" (apply clj-back-compat (rest args)) "specs" (specs) (apply kaocha "--focus" args)) (all config))) diff --git a/src/datahike/query_stats.cljc b/src/datahike/query_stats.cljc index f45734d93..f1ad0de61 100644 --- a/src/datahike/query_stats.cljc +++ b/src/datahike/query_stats.cljc @@ -1,4 +1,5 @@ (ns datahike.query-stats + (:refer-clojure :exclude [abs]) (:require [clojure.set :as set] [datahike.tools :as dt])) @@ -7,6 +8,11 @@ :cljs (let [y (Math/pow 10 precision)] (/ (.round js/Math (* y x)) y)))) +(defn abs + "Only available since Clojure 1.11 and ClojureScript 1.11.10 in core namespaces." + [x] + (Math/abs x)) + (defn get-stats [context] {:rels (mapv (fn [rel] {:rows (count (:tuples rel)) :bound (set (keys (:attrs rel)))})