Skip to content

Commit

Permalink
Remove namespace from API (#460)
Browse files Browse the repository at this point in the history
Issue #431
* Exclude namespace from the API.
* Update portal to the latest library version.
* Remove Funnel from list of production systems (they have stopped using Clojure).
* Add link from :test in Configuration to Test runners page.
* Only show 'with' in ws and test, if :test-configs is configured in workspace.edn.
* Added merge-test-config test.
* Bump djblue/portal to 0.54.2.
* 0.2.20-SNAPSHOT #14
  • Loading branch information
tengstrand authored Apr 10, 2024
1 parent 84f4e92 commit 973fd8c
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 40 deletions.
3 changes: 2 additions & 1 deletion components/help/src/polylith/clj/core/help/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"\n"
" " (s/key "with:CONFIG" cm) " Merges the " (s/key "CONFIG" cm) " configuration snippet(s) from " (s/key ":test-configs" cm) "\n"
" in workspace.edn to the " (s/key ":test" cm) " key. More than one " (s/key "CONFIG" cm) " can be\n"
" selected.\n"
" selected. See https://github.com/polyfy/polylith/blob/master/\n"
" examples/test-runners/workspace.edn as example.\n"
"\n"
"\n"
" To also execute the brick tests from the development project, pass in :dev:\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,3 @@
(sort (set/difference
test-configs
(set (shared/args groups group)))))))

;(defn selectx [{:keys [group]} groups {:keys [settings projects]}]
; (let [color-mode (:color-mode settings)]
; (mapv #(c/fn-explorer-child % :project color-mode true group #'select)
; (sort (set/difference
; (set (concat ["development"]
; (map :name (filter #(or (-> % :bricks-to-test seq)
; (-> % :projects-to-test seq)) projects))))
; (set (shared/args groups group)))))))
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@
(def test-all (c/flag "all" :test))
(def test-with (c/fn-explorer "with" :test #'with-test-configs/select))

(defn test [profiles current-ws? all?]
(defn test [profiles current-ws? has-test-configs? all?]
(when current-ws?
(c/single-txt "test" :test
(vec (concat [test-all test-all-bricks test-brick test-loc test-verbose
test-dev test-project test-project-flag test-since test-with]
test-dev test-project test-project-flag test-since]
(when has-test-configs? [test-with])
(when all? [test-skip])
profiles)))))

Expand Down Expand Up @@ -193,11 +194,12 @@
(def ws-with (c/fn-explorer "with" :ws #'with-test-configs/select))

;; ws
(defn ws [profiles all?]
(defn ws [profiles has-test-configs? all?]
(c/single-txt "ws" :ws
(vec (concat [ws-project ws-brick ws-project-flag ws-dev ws-latest-sha
ws-loc ws-all-bricks ws-all ws-get ws-out ws-since ws-with]
ws-loc ws-all-bricks ws-all ws-get ws-out ws-since]
profiles
(when has-test-configs? [ws-with])
(when all? [ws-branch ws-outdated ws-replace ws-no-changes ws-color-mode])))))

;; switch-ws
Expand All @@ -218,12 +220,13 @@
(map #(c/group-arg (str "+" %) group-id (str "+" %))
profile-keys)))))

(defn candidates [{:keys [profiles user-input]}]
(defn candidates [{:keys [configs profiles user-input]}]
(let [{:keys [ws-dir ws-file is-all is-local]} user-input
ws-shortcuts (user-config/ws-shortcuts-paths)
info-profiles (->profiles :info profiles is-all)
test-profiles (->profiles :test profiles is-all)
ws-profiles (->profiles :ws profiles is-all)
has-test-configs? (seq (-> configs :workspace :test-configs))
current-ws? (or (nil? ws-file)
(or (nil? ws-dir)
(= "." ws-dir)))]
Expand All @@ -237,8 +240,8 @@
(help is-all)
(info info-profiles is-all system/extended?)
(libs is-all system/extended?)
(test test-profiles current-ws? is-all)
(ws ws-profiles is-all)
(test test-profiles current-ws? has-test-configs? is-all)
(ws ws-profiles has-test-configs? is-all)
(when system/extended? overview)]))))

(def create-outside-ws-root (c/single-txt "create" [create-workspace]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,19 @@
(candidates "libs" :next ""))))

(deftest test
(is (= [":all" ":all-bricks" ":dev" ":loc" ":project" ":verbose" "brick" "project" "since" "with"]
(is (= [":all" ":all-bricks" ":dev" ":loc" ":project" ":verbose" "brick" "project" "since"]
(candidates "test"))))

(deftest test-:project-
(is (= [":all" ":all-bricks" ":dev" ":loc" ":verbose" "brick" "project" "since" "with"]
(is (= [":all" ":all-bricks" ":dev" ":loc" ":verbose" "brick" "project" "since"]
(candidates "test" :next ":project" :next ""))))

(deftest test-project-
(is (= [":all" ":all-bricks" ":dev" ":loc" ":project" ":verbose" "brick" "since" "with"]
(is (= [":all" ":all-bricks" ":dev" ":loc" ":project" ":verbose" "brick" "since"]
(candidates "test" :next "project" "poly" :next ""))))

(deftest test-loc-
(is (= [":all" ":all-bricks" ":dev" ":project" ":verbose" "brick" "project" "since" "with"]
(is (= [":all" ":all-bricks" ":dev" ":project" ":verbose" "brick" "project" "since"]
(candidates "test" :next "loc" :next ""))))

(deftest version
Expand All @@ -328,12 +328,12 @@

(deftest ws
(is (= [":all" ":all-bricks" ":dev" ":latest-sha" ":loc" ":project"
"brick" "get" "out" "project" "since" "with"]
"brick" "get" "out" "project" "since"]
(candidates "ws"))))

(deftest ws-
(is (= [":all" ":all-bricks" ":dev" ":latest-sha" ":loc" ":project"
"brick" "get" "out" "project" "since" "with"]
"brick" "get" "out" "project" "since"]
(candidates "ws" :next ""))))

(deftest ws-get
Expand Down Expand Up @@ -373,7 +373,8 @@

(deftest ws-out-components-next-
(is (= [":all" ":all-bricks" ":dev" ":latest-sha" ":loc" ":project"
"brick" "get" "project" "since" "with"]
"brick" "get" "project" "since"
]
(candidates "ws" :next "out" "components" :next ""))))

(deftest ws-out-parentdir-
Expand Down
2 changes: 1 addition & 1 deletion components/tap/deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:paths ["src"]
:deps {djblue/portal {:mvn/version "0.53.0"}}
:deps {djblue/portal {:mvn/version "0.54.2"}}
:aliases {:test {:extra-paths []
:extra-deps {}}}}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(def minor 2)
(def patch 20)
(def revision SNAPSHOT) ;; Set to SNAPSHOT or RELEASE.
(def snapshot 13) ;; Increase by one for every snapshot release, or set to 0 if a release.
(def snapshot 14) ;; Increase by one for every snapshot release, or set to 0 if a release.
;; Also update :snapshot-version: at the top of readme.adoc.
(def snapshot? (= SNAPSHOT revision))

Expand All @@ -37,7 +37,7 @@

(def tool (if system/extended? "polyx" "poly"))

(def date "2024-03-31")
(def date "2024-04-10")

;; Execute 'poly doc version' to see when different changes was introduced.
(def api-version {:breaking 1, :non-breaking 0})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns polylith.clj.core.workspace.enrich.test-configs)
(ns ^:no-doc polylith.clj.core.workspace.enrich.test-configs)

(declare merge-data)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(ns polylith.clj.core.workspace.enrich.test-configs-test
(:require [clojure.test :refer :all]
[polylith.clj.core.workspace.enrich.test-configs :as test-configs]))

(deftest merge-vector-values-if-both-are-vectors
(is (= {:a [1 2]}
(test-configs/merge-data {:a [1]} [{:a [2]} []]))))

(deftest merge-vector-values-if-both-are-vectors-multi-levels
(is (= {:a {:b [1 2]}}
(test-configs/merge-data {:a {:b [1]}} [{:a {:b [2]}} []]))))

(deftest replace-with-value-if-not-both-are-vectors
(is (= {:a [2]}
(test-configs/merge-data {:a 1} [{:a [2]} []]))))

(deftest merge-multiple-values
(is (= {:a 2
:b {:c 4
:e 5
:f 6}
:d [:i :j]
:x 123}
(test-configs/merge-data {:a 1
:b {:c 3
:f 6}
:d [:i]}
[{:a 2
:b {:c 4
:e 5}
:d [:j]
:x 123}
[]]))))
3 changes: 3 additions & 0 deletions doc/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ a| Specifies the https://docs.oracle.com/javase/8/docs/api/java/util/regex/Patte
As explained in xref:tagging.adoc[Tagging], `poly` uses this pattern to calculate the latest committed sha that is considered the _latest stable point in time_. +
*Default:* `+{:stable "stable-*" :release "v[0-9]*"}+`

a| `:test`
a| See xref:test-runners.adoc#test-configuration[Test configuration].

a| `:top-namespace`
a| The top namespace used throughout the workspace in components and bases, specified by you when you create your xref:workspace.adoc[workspace]. +
*Default:* none, must be specified
Expand Down
9 changes: 0 additions & 9 deletions doc/production-systems.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ http://scrintal.com[Scrintal's] first commit dates back to April 2019 and the wo
Polylith enabled us to experiment fast locally and ship features easily.
The complete buy-in to Polylith paid off when we started pivoting our product at the end of 2020, as even though we are changing it to a completely new product, most bricks can be shared and reused across all our products.

== Funnel

image::images/production-systems/funnel.png[link="images/production-systems/funnel.png"]

https://funnel.io/[Funnel] helps companies collect, prepare and analyze all their marketing data with ease.
The company was founded in 2014, has 1000+ customers, and integrates with 500+ marketing apps and platforms.
The tech stack differs from team to team. Python, Typescript, Rust, and Clojure are all languages in use.
The Clojure adopters chose Polylith in order to get a smooth development experience and to be able to separate how services are deployed and run from how functionality is developed and re-used.

== World Singles Networks

image::images/production-systems/world-singles-networks.png[link="images/production-systems/world-singles-networks.png"]
Expand Down
3 changes: 2 additions & 1 deletion doc/test-runners.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ a| A map of changes since the last stable point in time.

|===

[[test-configuration]]
== Test configuration

If you create your own test runner or use one from the community, it can be useful to add snippets of test configuration when running the xref:commands.adoc#test[test] command.
Expand Down Expand Up @@ -274,7 +275,7 @@ The old `org.corfield.external-test-runner.interface/create` value was replaced

If the old value instead was set to `[org.corfield.external-test-runner.interface/create]` then the two vectors would instead been merged into `[org.corfield.external-test-runner.interface/create :defalt]`.

When we have two vectors, they will be merged:
Both `default-test-runner` and `kaocha-test-runner` store their values in a vector, and if we select both, the result will be merged:

[source,shell]
----
Expand Down
11 changes: 10 additions & 1 deletion projects/poly/test/project/poly/poly_workspace_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
" borkdude/edamame 1.4.25 maven 24 x x x - - . . x . . . . . ."
" clj-commons/fs 1.6.311 maven 12 x x x - - . . x . . . . . ."
" com.github.liquidz/antq 2.8.1185 maven 52 x x x - - x . . . . . . . ."
" djblue/portal 0.53.0 maven 1,870 x x x - - . . . . . x . . ."
" djblue/portal 0.54.2 maven 1,873 x x x - - . . . . . x . . ."
" metosin/malli 0.15.0 maven 89 x x x - - . . . . . . x . ."
" mvxcvi/puget 1.3.4 maven 15 x x x - - . . . . . . . . x"
" org.clojure/clojure 1.11.2 maven 4,009 x x x - - . . . . . . . . ."
Expand Down Expand Up @@ -1526,3 +1526,12 @@
(run-cmd-plain "examples/multiple-workspaces2/backend"
"ws"
"get:components:hello::interface-deps")))))

(deftest merge-test-configs
(is (= {:create-test-runner [:default]
:org.corfield/external-test-runner {:focus {:exclude [:integration :dummy]}}}
(read-string
(run-cmd-plain "examples/test-runners"
"ws"
"get:settings:test"
"with:default-test-runner:exclude-integration:exclude-dummy")))))
2 changes: 1 addition & 1 deletion readme.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
image::doc/images/logo.png[width=400]
:snapshot-version: 13
:snapshot-version: 14
:cljdoc-doc-url: https://cljdoc.org/d/polylith/clj-poly/CURRENT/doc

https://cljdoc.org/d/polylith/clj-poly/0.2.19/doc/readme[image:https://badgen.net/badge/doc/0.2.19/blue[]]
Expand Down

0 comments on commit 973fd8c

Please sign in to comment.