Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move test-containers dependency to test deps #233

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
## [Unreleased] - 2022-09-21

- Remove test-containers dependency, and move it to test profile

## [Unreleased] - 2022-08-25
- Use clj-tools for
- test
- build
- install
- release

- Use clj-tools for
- test
- build
- install
- release
- Remove `project.clj`
- Fix kibit complaints

## [Unreleased] - 2022-06-26

- Added new `prune-get-request-bodies` interceptor

Breaking changes:
- refactor database migration system, use patched migratus (Flexiana/migratus), removed seed module and rewrite data migration tool
Breaking changes:

- refactor database migration system, use patched migratus (Flexiana/migratus), removed seed module and rewrite data
migration tool

## 0.5-rc2
Breaking changes:

Breaking changes:

- removed monands (`funcool.cats` library), related code and docs
removed `xiana.interceptor.wrap/interceptor`
- changed interceptors behaviour making them similar to pedestal and sieppari
Expand All @@ -23,4 +33,5 @@ Breaking changes:
- a bunch of other small fixes.

## 0.5-rc1

Breaking change: rename almost all namespaces from `framework..` to `xiana..`).
57 changes: 28 additions & 29 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/core.async {:mvn/version "1.5.648"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
org.clojure/data.json {:mvn/version "2.4.0"},
org.clojure/data.xml {:mvn/version "0.0.8"},
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/core.async {:mvn/version "1.5.648"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
org.clojure/data.json {:mvn/version "2.4.0"},
org.clojure/data.xml {:mvn/version "0.0.8"},

com.draines/postal {:mvn/version "2.0.5"},
com.flexiana/tiny-rbac {:mvn/version "0.1.1"},
com.taoensso/timbre {:mvn/version "5.2.1"},
crypto-password/crypto-password {:mvn/version "0.3.0"},
funcool/cuerdas {:mvn/version "2.2.1"},
info.sunng/ring-jetty9-adapter {:mvn/version "0.17.5"},
metosin/malli {:mvn/version "0.8.4"},
metosin/reitit {:mvn/version "0.5.18"},
com.draines/postal {:mvn/version "2.0.5"},
com.flexiana/tiny-rbac {:mvn/version "0.1.1"},
com.taoensso/timbre {:mvn/version "5.2.1"},
crypto-password/crypto-password {:mvn/version "0.3.0"},
funcool/cuerdas {:mvn/version "2.2.1"},
info.sunng/ring-jetty9-adapter {:mvn/version "0.17.5"},
metosin/malli {:mvn/version "0.8.4"},
metosin/reitit {:mvn/version "0.5.18"},
;; migratus/migratus {:mvn/version "1.3.7"},
migratus/migratus {:git/url "https://github.com/Flexiana/migratus"
:sha "fba4aa9d57da6cc6a1d6e8c4a2b4198ad5a44315"}
nilenso/honeysql-postgres {:mvn/version "0.4.112"},
org.clojure/java.jdbc {:mvn/version "0.7.12"},
clj-test-containers/clj-test-containers {:mvn/version "0.7.2"},
org.postgresql/postgresql {:mvn/version "42.3.3"},
piotr-yuxuan/closeable-map {:mvn/version "0.35.0"},
seancorfield/next.jdbc {:mvn/version "1.2.659"},
yogthos/config {:mvn/version "1.2.0"}}
migratus/migratus {:git/url "https://github.com/Flexiana/migratus"
:sha "fba4aa9d57da6cc6a1d6e8c4a2b4198ad5a44315"}
nilenso/honeysql-postgres {:mvn/version "0.4.112"},
org.clojure/java.jdbc {:mvn/version "0.7.12"},
org.postgresql/postgresql {:mvn/version "42.3.3"},
piotr-yuxuan/closeable-map {:mvn/version "0.35.0"},
seancorfield/next.jdbc {:mvn/version "1.2.659"},
yogthos/config {:mvn/version "1.2.0"}}

:aliases
{:dev
Expand All @@ -39,13 +38,13 @@
{:extra-deps {clj-kondo/clj-kondo {:mvn/version "2022.05.31"}}
:main-opts ["-m" "clj-kondo.main" "--lint" "src"]}

:codox {:extra-deps {codox/codox {:mvn/version "0.10.8"}}
:codox {:extra-deps {codox/codox {:mvn/version "0.10.8"}}
:extra-paths ["resources"]
:exec-fn codox.main/generate-docs
:exec-args {:output-path "docs/new/"
:themes [:default :xiana]
:source-paths ["src"]
:doc-files ["doc/getting-started.md", "doc/How-To.md", "doc/Development-Guide.md"]}}
:exec-fn codox.main/generate-docs
:exec-args {:output-path "docs/new/"
:themes [:default :xiana]
:source-paths ["src"]
:doc-files ["doc/getting-started.md", "doc/How-To.md", "doc/Development-Guide.md"]}}

:kibit
{:extra-deps {tvaughan/kibit-runner {:mvn/version "1.0.1"}}
Expand All @@ -62,7 +61,7 @@

:test
{:extra-paths ["config/test" "test"]
:extra-deps {clj-test-containers/clj-test-containers {:mvn/version "0.5.0"}
:extra-deps {clj-test-containers/clj-test-containers {:mvn/version "0.7.2"}
clj-http/clj-http {:mvn/version "3.12.3"}
http.async.client/http.async.client {:mvn/version "1.3.1"}
com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner"
Expand Down
1 change: 1 addition & 0 deletions examples/acl/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
:prod {:resource-paths ["config/prod"]}
:test {:resource-paths ["config/test"]
:dependencies [[clj-http "3.12.3"]
[clj-test-containers "0.7.2"]
[mvxcvi/cljstyle "0.15.0"
:exclusions [org.clojure/clojure]]]}}
:aliases {"check-style" ["with-profile" "+test" "run" "-m" "cljstyle.main" "check"]
Expand Down
27 changes: 24 additions & 3 deletions examples/acl/test/acl_fixture.clj
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
(ns acl-fixture
(:require
[acl]
[xiana.config :as config]
[xiana.db :as db]))
[clj-test-containers.core :as tc]
[xiana.config :as config]))

(defn docker-postgres!
[{pg-config :xiana/postgresql :as config}]
(let [{:keys [dbname user password image-name]} pg-config
container (tc/start!
(tc/create
{:image-name image-name
:exposed-ports [5432]
:env-vars {"POSTGRES_DB" dbname
"POSTGRES_USER" user
"POSTGRES_PASSWORD" password}}))

port (get (:mapped-ports container) 5432)
pg-config (assoc
pg-config
:port port
:embedded container
:subname (str "//localhost:" port "/" dbname))]
(tc/wait {:wait-strategy :log
:message "accept connections"} (:container container))
(assoc config :xiana/postgresql pg-config)))

(defn std-system-fixture
[f]
(with-open [_ (-> (config/config)
(merge acl/app-cfg)
db/docker-postgres!
docker-postgres!
acl/->system)]
(f)))
1 change: 1 addition & 0 deletions examples/cli-chat/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
:prod {:resource-paths ["config/prod"]}
:test {:resource-paths ["config/test"]
:dependencies [[clj-http "3.12.3"]
[clj-test-containers "0.7.2"]
[http.async.client "1.3.1"]
[mvxcvi/cljstyle "0.15.0"
:exclusions [org.clojure/clojure]]]}}
Expand Down
24 changes: 23 additions & 1 deletion examples/cli-chat/test/cli_chat_fixture.clj
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
(ns cli-chat-fixture
(:require
[cli-chat.core :refer [->system]]
[clj-test-containers.core :as tc]
[xiana.config :as config]
[xiana.db :as db]))

(defn docker-postgres!
[{pg-config :xiana/postgresql :as config}]
(let [{:keys [dbname user password image-name]} pg-config
container (tc/start!
(tc/create
{:image-name image-name
:exposed-ports [5432]
:env-vars {"POSTGRES_DB" dbname
"POSTGRES_USER" user
"POSTGRES_PASSWORD" password}}))

port (get (:mapped-ports container) 5432)
pg-config (assoc
pg-config
:port port
:embedded container
:subname (str "//localhost:" port "/" dbname))]
(tc/wait {:wait-strategy :log
:message "accept connections"} (:container container))
(assoc config :xiana/postgresql pg-config)))

(defn std-system-fixture
[app-cfg f]
(with-open [_ (-> (config/config)
(merge app-cfg)
db/docker-postgres!
docker-postgres!
->system)]
(f)))
1 change: 1 addition & 0 deletions examples/controllers/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:prod {:resource-paths ["config/prod"]}
:test {:resource-paths ["config/test"]
:dependencies [[clj-http "3.12.3"]
[clj-test-containers "0.7.2"]
[mvxcvi/cljstyle "0.15.0"
:exclusions [org.clojure/clojure]]]}}
:jvm-opts ["-Dmalli.registry/type=custom"]
Expand Down
3 changes: 2 additions & 1 deletion examples/frames/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
:local {:resource-paths ["config/local" "resources"]}
:prod {:resource-paths ["config/prod" "resources"]}
:test {:resource-paths ["config/test" "resources"]
:dependencies [[mvxcvi/cljstyle "0.15.0"
:dependencies [[clj-test-containers "0.7.2"]
[mvxcvi/cljstyle "0.15.0"
:exclusions [org.clojure/clojure]]]}}
:shadow-cljs {:nrepl {:port 8777}

Expand Down
1 change: 1 addition & 0 deletions examples/sessions/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:prod {:resource-paths ["config/prod"]}
:test {:resource-paths ["config/test"]
:dependencies [[clj-http "3.12.3"]
[clj-test-containers "0.7.2"]
[mvxcvi/cljstyle "0.15.0"
:exclusions [org.clojure/clojure]]]}}
:shadow-cljs {:nrepl {:port 8777}
Expand Down
24 changes: 23 additions & 1 deletion examples/sessions/test/integration_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[app.core :as app]
[clj-http.client :as http]
[clj-test-containers.core :as tc]
[clojure.test :refer [deftest is use-fixtures]]
[jsonista.core :as json]
[next.jdbc :as jdbc]
Expand All @@ -12,6 +13,27 @@
(java.util
UUID)))

(defn docker-postgres!
[{pg-config :xiana/postgresql :as config}]
(let [{:keys [dbname user password image-name]} pg-config
container (tc/start!
(tc/create
{:image-name image-name
:exposed-ports [5432]
:env-vars {"POSTGRES_DB" dbname
"POSTGRES_USER" user
"POSTGRES_PASSWORD" password}}))

port (get (:mapped-ports container) 5432)
pg-config (assoc
pg-config
:port port
:embedded container
:subname (str "//localhost:" port "/" dbname))]
(tc/wait {:wait-strategy :log
:message "accept connections"} (:container container))
(assoc config :xiana/postgresql pg-config)))

(defn merge-connection
[config]
(update-in config
Expand All @@ -24,7 +46,7 @@
(with-open [system (-> (config/config app/app-cfg)
(assoc :xiana/postgresql (:xiana/session-backend (config/config)))
(assoc-in [:xiana/postgresql :image-name] "postgres:14-alpine")
db/docker-postgres!
docker-postgres!
db/connect
merge-connection
app/->system)]
Expand Down
1 change: 1 addition & 0 deletions examples/state-events/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:prod {:resource-paths ["config/prod"]}
:test {:resource-paths ["config/test"]
:dependencies [[clj-http "3.12.3"]
[clj-test-containers "0.7.2"]
[cheshire "5.10.2"]
[mvxcvi/cljstyle "0.15.0"
:exclusions [org.clojure/clojure]]]}}
Expand Down
34 changes: 28 additions & 6 deletions examples/state-events/src/backend/state_events/core.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns state-events.core
(:require
[clj-test-containers.core :as tc]
[piotr-yuxuan.closeable-map :refer [closeable-map]]
[reitit.ring :as ring]
[state-events.controller-behaviors.sse :as sseb]
Expand Down Expand Up @@ -50,20 +51,41 @@
[["/" {:action index/handle-index}]
["/re-frame" {:action re-frame/handle-index}]
["/assets/*" {:action resource-handler}]
["/person" {:put {:action event/create-resource
:interceptors event-interceptors}
:post {:action event/modify
:interceptors event-interceptors}
["/person" {:put {:action event/create-resource
:interceptors event-interceptors}
:post {:action event/modify
:interceptors event-interceptors}
:delete {:action event/delete
:interceptors event-interceptors}
:get {:action event/persons}}]
:get {:action event/persons}}]
["/events" {:get {:action event/raw}}]
["/sse" {:ws-action sse/sse-action}]])

(defn docker-postgres!
[{pg-config :xiana/postgresql :as config}]
(let [{:keys [dbname user password image-name]} pg-config
container (tc/start!
(tc/create
{:image-name image-name
:exposed-ports [5432]
:env-vars {"POSTGRES_DB" dbname
"POSTGRES_USER" user
"POSTGRES_PASSWORD" password}}))

port (get (:mapped-ports container) 5432)
pg-config (assoc
pg-config
:port port
:embedded container
:subname (str "//localhost:" port "/" dbname))]
(tc/wait {:wait-strategy :log
:message "accept connections"} (:container container))
(assoc config :xiana/postgresql pg-config)))

(defn docker?
[state]
(if (get-in state [:xiana/postgresql :image-name])
(db/docker-postgres! state)
(docker-postgres! state)
state))

(defn ->system
Expand Down
2 changes: 1 addition & 1 deletion script/auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ _setup ()

_tests ()
{
env FRAMEWORK_EDN_CONFIG=${_CONFIG} clj -M:test
env XIANA_CONFIG=${_CONFIG} clj -M:test
}

_stops ()
Expand Down
22 changes: 0 additions & 22 deletions src/xiana/db.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns xiana.db
"Data source builder"
(:require
[clj-test-containers.core :as tc]
[honeysql-postgres.format]
[honeysql.core :as sql]
[jsonista.core :as json]
Expand Down Expand Up @@ -95,27 +94,6 @@
(get-datasource config (inc count))
(throw e)))))))

(defn docker-postgres!
[{pg-config :xiana/postgresql :as config}]
(let [{:keys [dbname user password image-name]} pg-config
container (tc/start!
(tc/create
{:image-name image-name
:exposed-ports [5432]
:env-vars {"POSTGRES_DB" dbname
"POSTGRES_USER" user
"POSTGRES_PASSWORD" password}}))

port (get (:mapped-ports container) 5432)
pg-config (assoc
pg-config
:port port
:embedded container
:subname (str "//localhost:" port "/" dbname))]
(tc/wait {:wait-strategy :log
:message "accept connections"} (:container container))
(assoc config :xiana/postgresql pg-config)))

(defn migrate!
([config]
(migrate! config 0))
Expand Down
Loading