Skip to content

Commit

Permalink
Issue 205 (#317)
Browse files Browse the repository at this point in the history
Solves issue #205, #312, and #313:
* use tools.build instead of seancorfield/build-clj, issue 312.
* Handle dollar sign correctly in namespace names in imports, issue 313.
* Added :workspace as to the 'help deps' intellisense. Bumped the portal library.
* Print detailed error (row, column, message) if a file couldn't be read.
* Extend autocomplete in the shell if starting a shell with :all: +, changed-files, :color-mode, :no-changes, skip
* Only show the workspace structure in the portal window, when starting a shell with 'poly :tap'.
* Added support for creating an image from the output from the info, deps, and libs commands, by passing in out:FILENAME, where FILENAME ends with e.g. .png (.txt will generate a text file).
* Added the overview command, that generates an image of the info/deps/libs tables.
* Exclude license files when building an uberjar.
* Don't show the tag in the info command if fake-sha is passed in.
* Build with circleci/clojure:tools-deps-1.11.1 in circleci.
* Don't include tools.deps when creating a project.
* Refactored projects-from-disk, by reading paths and libs separately.
* Fixed an edge case in the function that calculates bricks to test.
* Removed :all as parameter from the brick-project-deps table.
* Updated the help for info, deps, libs, and overview + the summary.
* Removed the :all parameter for the libs command.
* The output from the libs command no looks good when passing in skip:dev.
* Show overview in the help for polyx.
* Show size as - in the libs command if the size is zero bytes.
* Only tap the workspace + timing info.
* Use the :local/root for bricks in the development environment, now when issue 2554 for Cursive is fixed!
* If a library doesn't exist on disk, don't include the :size key in the libs structure.
* Renamed warning 206 to "Unreadable namespace...".
* Improved warning 206 and 207.
* Store the vector of the circular deps in error 104.
* Added the Out and Polyx sections to the create example script. Removed io.github.seancorfield/build-clj from ./deps.edn. 
* Fixed a bug in the workspace function in the api component.
* Added polyx as alias in workspace.edn.
* Let build.sh build poly, and build-extended.sh build polyx. 
* Added an :all section to the help overview.
* Fixed a bug in the create example script (save exit code correctly).
* Commented out the test polylith-libs-outdated so that tests don't start to fail when a new version of a library is released.
* Also store :type in error 110.
* Store the :test-runner-api attribute to the :version key in the workspace structure.
  • Loading branch information
tengstrand authored Jul 22, 2023
1 parent 21cf93d commit 9053b19
Show file tree
Hide file tree
Showing 209 changed files with 3,322 additions and 3,185 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.0
jobs:
check:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- checkout
Expand Down Expand Up @@ -31,7 +31,7 @@ jobs:

check-build:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- checkout
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:

info:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:

info-build:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:

test:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand All @@ -137,7 +137,7 @@ jobs:

test-build:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand All @@ -159,7 +159,7 @@ jobs:

mark-as-stable:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand All @@ -182,7 +182,7 @@ jobs:

deploy:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand All @@ -195,7 +195,7 @@ jobs:

create-artifacts:
docker:
- image: circleci/clojure:tools-deps-1.10.3.933
- image: cimg/clojure:1.11.1
working_directory: ~/polylith
steps:
- attach_workspace:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@

artifacts
projects/**/pom.xml
/scripts/images/**
/scripts/output/example/**
/examples/doc-example/.idea/**
/examples/local-dep/.idea/**ZZ
/examples/local-dep-old-format/.idea/**
/scripts/output/info.png
/scripts/output/overview.png

# clojure-lsp
.lsp/sqlite*.db
Expand Down
2 changes: 2 additions & 0 deletions .idea/clojure-deps.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bases/poly-cli/src/polylith/clj/core/poly_cli/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
(-main "ws" "get:components:account:namespaces:src:core:file-path" "ws-file:../sandbox/furkan.edn" ":no-exit")
(-main "ws" "get:components:api:namespaces:src:core:file-path" "ws-dir:../../Downloads/polylith-0.1.0-alpha9/" ":no-exit")
(-main "check" ":no-exit")
(-main "overview" ":no-exit")
(-main "check" "ws-dir:examples/local-dep" ":no-exit")
(-main "ws" "get:components:without-src:non-top-namespaces" "ws-dir:examples/local-dep" ":no-exit")
(-main "check" "ws-dir:examples/local-dep-old-format" ":no-exit")
Expand Down
5 changes: 5 additions & 0 deletions build-extended.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo "#### Build poly(x) uberjar"
clojure -T:build uberjar :project polyx
sudo cp projects/polyx/target/polyx.jar /usr/local/polylith/poly.jar
4 changes: 3 additions & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@
:compile-opts {:direct-linking true}
:main main
:ns-compile [main]
:uber-file uber-file})]
:uber-file uber-file
:exclude [#"(?i)^META-INF/license/.*"
#"^license/.*"]})]
(b/delete {:path class-dir})
;; no src or resources to copy
(println "\nCompiling" (str main "..."))
Expand Down
30 changes: 14 additions & 16 deletions components/api/src/polylith/clj/core/api/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@
and a list of keywords, strings, or numbers as the second argument.
:keys and :count are also valid keys to send in. If keys are empty,
returns the whole workspace."
([keys]
(workspace :stable keys))
([since keys]
(let [keys-str (map key->str keys)
since-str (str "since:" (key->str since))
args (if-not (empty keys-str)
["ws" since-str (str "get:" (str/join ":" keys-str))]
["ws" since-str])
user-input (user-input/extract-params args)
workspace (-> user-input
ws-clj/workspace-from-disk
ws/enrich-workspace
change/with-changes)]
(if (empty? keys-str)
workspace
(ws-explorer/extract workspace keys-str)))))
[since keys]
(let [keys-str (map key->str keys)
since-str (str "since:" (key->str since))
args (if (empty? keys-str)
["ws" since-str]
["ws" since-str (str "get:" (str/join ":" keys-str))])
user-input (user-input/extract-params args)
workspace (-> user-input
ws-clj/workspace-from-disk
ws/enrich-workspace
change/with-changes)]
(if (empty? keys-str)
workspace
(ws-explorer/extract workspace keys-str))))
60 changes: 34 additions & 26 deletions components/change/src/polylith/clj/core/change/bricks_to_test.clj
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
(ns polylith.clj.core.change.bricks-to-test
(:require [clojure.set :as set]))

(defn include-and-exclude-bricks
"If the :test key is given for a project in workspace.edn, then only include and/or exclude
the specified bricks, otherwise, run tests for all bricks that have tests."
[brick-name all-brick-names settings]
(let [included (if-let [bricks (get-in settings [:projects brick-name :test :include])]
(set/intersection all-brick-names (set bricks))
all-brick-names)]
(if-let [bricks (get-in settings [:projects brick-name :test :exclude])]
(set/difference included (set bricks))
included)))
(:require [clojure.set :as set]
[polylith.clj.core.common.interface :as common]))

(defn bricks-to-test-for-project [{:keys [is-dev alias name base-names component-names]}
source
settings
changed-projects
changed-components
changed-bases
changed-bricks-for-source
project-to-indirect-changes
selected-bricks
selected-projects
Expand All @@ -28,31 +18,49 @@
(or (not is-dev)
is-dev-user-input)))
project-has-changed? (contains? (set changed-projects) name)
all-brick-names (into #{} (mapcat :test) [base-names component-names])
included-bricks (include-and-exclude-bricks name all-brick-names settings)
bricks-for-source (if (= :test source)
;; Make sure we only select bricks that are included in the project from the :test context.
(into #{} (mapcat :test) [base-names component-names])
;; Also make sure the bricks are included in the :src context for the project
;; when checking for changes for the :src context.
;; If a brick is included in the project via its deps.edn as :local/root
;; from :aliases > :test > :extra-deps, then it will only be included in :test
;; in base-names/component-names (not :src).
(set/intersection (into #{} (mapcat :src) [base-names component-names])
(into #{} (mapcat :test) [base-names component-names])))
;; If the :test > :include or :test > :exclude keys are given for a project in workspace.edn,
;; then only include the specified bricks, otherwise, run tests for all bricks.
included-bricks (common/brick-names-to-test settings name bricks-for-source)
selected-bricks (if selected-bricks
(set selected-bricks)
all-brick-names)
bricks-for-source)
changed-bricks (if include-project?
(if (or is-run-all-brick-tests project-has-changed?)
;; if we pass in :all or :all-bricks or if the project has changed
;; then always run all brick tests.
;; if we pass in :all or :all-bricks or if the project has changed then always run all brick tests.
included-bricks
(set/intersection included-bricks
selected-bricks
(into #{} cat
[changed-components
changed-bases
(-> name project-to-indirect-changes :src)
(-> name project-to-indirect-changes :test)])))
[changed-bricks-for-source
(-> name project-to-indirect-changes source)])))
#{})
;; And finally, if brick:BRICK is given, also filter on that, which means that if we
;; pass in both brick:BRICK and :all, we will run the tests for all these bricks,
;; whether they have changed or not (directly or indirectly).
bricks-to-test (set/intersection changed-bricks selected-bricks)]
[name (-> bricks-to-test sort vec)]))
[name (-> bricks-to-test sort set)]))

(defn project-to-bricks-to-test [changed-projects projects settings changed-components changed-bases project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests]
(defn project-to-bricks-to-test-for-source [source changed-projects projects settings changed-bricks project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests]
(into (sorted-map)
(map #(bricks-to-test-for-project % settings changed-projects changed-components changed-bases project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests))
(map #(bricks-to-test-for-project % source settings changed-projects changed-bricks project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests))
projects))

(defn as-vec-val [[k v]]
[k (-> v sort vec)])

(defn as-vec [m]
(into {} (map as-vec-val m)))

(defn project-to-bricks-to-test [changed-projects projects settings changed-bricks-src changed-bricks-test project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests]
(as-vec (merge-with into (project-to-bricks-to-test-for-source :src changed-projects projects settings changed-bricks-src project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests)
(project-to-bricks-to-test-for-source :test changed-projects projects settings changed-bricks-test project-to-indirect-changes selected-bricks selected-projects is-dev-user-input is-run-all-brick-tests))))
5 changes: 2 additions & 3 deletions components/change/src/polylith/clj/core/change/interface.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns polylith.clj.core.change.interface
(:require [polylith.clj.core.change.core :as core]
[polylith.clj.core.util.interface.time :as time-util]))
(:require [polylith.clj.core.change.core :as core]))

(defn with-changes [workspace]
(time-util/tap-seconds "#with-changes" (core/with-changes workspace)))
(core/with-changes workspace))
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,6 @@
"user"]
"development" []})))

(deftest project-to-bricks-to-test--inlude-two-bricks-exclude-one--returns-one-brick
(is (= (test {:changed-projects []
:settings {:projects {"core" {:test {:include ["tag" "user"]
:exclude ["user"]}}}}
:changed-components ["article" "comment" "rest-api" "tag" "user"]
:changed-bases []
:project-to-indirect-changes {}
:selected-bricks nil
:selected-projects #{}
:is-dev-user-input false
:is-run-all-brick-tests false})
{"core" ["tag"]
"development" []})))

(deftest project-to-bricks-to-test--when-the-project-itself-has-changed--return-all-bricks-for-that-project
(is (= (test {:changed-projects ["core"]
:settings {}
Expand Down
Loading

0 comments on commit 9053b19

Please sign in to comment.