Fork me on GitHub
#polylith
<
2021-10-28
>
hugod10:10:07

I’ve been converting some projects to use polylith and am appreciating the approach. What’s the recommended way of running things like clj-kondo or cloverage?

Stefan17:10:41

I have the same question :) Another example: running outdated checks (antq) or known vulnerabilities scanning (nvd).

seancorfield19:10:38

Here's the script we use to run antq over our monorepo -- for both legacy subprojects and for the bases, components, and projects in the migrated-to-Polylith piece:

#!/bin/sh

root=/var/www/worldsingles

cd ${root}/clojure

echo '| Dependency | Current | Latest |'
${root}/build/clojure/bin/clojure -Sdeps '{:deps {antq/antq {:mvn/version "0.11.1"}}}' -M -m antq.core \
	--skip=pom \
	--error-format="| {{name}} | {{version}} | {{latest-version}} |" \
	--reporter=format -d .:`ls -d * bases/* components/* projects/* | tr '\n' ':'` 2> /dev/null | sort -u

# antq exits with 1 if any deps are outdated -- we want a 0 exit:
exit 0

🙏 1
seancorfield19:10:51

For clj-kondo, you can pass in the classpath, as I recall, so in addition to our :dev and :test aliases for Polylith, we have :everything and :runner for our legacy subprojects and tests respectively, so we do clojure -Spath -A:dev:test:everything:runner

hugod22:10:05

It might be interesting if we could have something like the ‘poly test’ command that could invoke an arbitrary alias on all (or possibly just modified) bricks, especially if you could configure the alias in the dev deps.edn and use it everywhere. This might also allow using test runners such as kaocha.

seancorfield22:10:33

The test running machinery in poly is pretty sophisticated and includes pre/post-project test suite hooks. It replaces something like Kaocha to be honest.

seancorfield22:10:46

You can get a list of changed bricks from the poly tool -- so you could use that, via a script for example, to create a list of things that Kaocha should run tests for (assuming Kaocha's API allows you to specify that directly).

seancorfield22:10:13

Under the hood, once poly test has computed the classpath for the project context and created an isolated classloader, it just calls clojure.test directly, for the bricks that need to be tested. Does Kaocha support independent classpaths for test execution?

hugod01:10:07

I see an “api” project -is there an official api for polylith? could that be used to get a list of the changed bricks?

seancorfield04:10:23

@tengstrand is be better placed to answer questions about that.

seancorfield04:10:28

I would just run the poly tool in a subprocess and capture the output. That's what build.clj does (in the Polylith project).

hugod19:10:36

I would like to avoid the extra process if possible

Casey10:10:45

I'm just getting started with polylith after watching a few videos, I'm following the instructions in the gitbook, and am stuck at https://polylith.gitbook.io/poly/architecture/workspace Here's the issue when I run the create workspace command just as its given in the docs:

$ clojure -T:poly  create workspace name:example top-ns:se.example
Key is missing value: top-ns:se.example

# or from 
$ clojure -Tpoly create workspace name next-gen top-ns com.my-company 
Key is missing value: com.my-company

Casey10:10:13

I just switched to running the jar instead of the cli tool and I'm off to the races

furkan3ayraktar12:10:06

Polylith’s way of passing arguments does not work well when using it as a Clojure CLI Tool. It’s explained here: https://polylith.gitbook.io/poly/workflow/clojure-cli-tool

👍 1
Casey12:10:48

The second command in my paste is from that page, but it produces the same error

tengstrand12:10:10

Okay, thanks for reporting this. I will have a look.

furkan3ayraktar12:10:00

You might need to quote the namespace

furkan3ayraktar12:10:24

'"com.my-company"'

seancorfield19:10:21

The docs are wrong.

clojure -Tpoly create w next-gen top-ns com.my-company
☝️:skin-tone-2: That should work but the full equivalent should be this
clojure -Tpoly create entity '"workspace"' name next-gen top-ns com.my-company
Two things to note: w sym is short for entity workspace name sym but entities need to be strings, not symbols, so '"workspace"' is required there. I think the latter is a bug in the poly tool code: the entity argument should support symbols.

1
tengstrand03:10:30

I’m not sure if I got it right, but feel free to update the https://github.com/polyfy/polylith/issues/154 I created @U04V70XH6.

seancorfield04:10:40

Sounds good. Did you update the docs or are you waiting until this issue is fixed too?

tengstrand04:10:48

Feel free to update it for now @U04V70XH6. I guess we will change it again when the issue is fixed.

seancorfield04:10:07

I'll try to remember when I'm next at a computer but that might be Tuesday. I'm in vacation.

tengstrand05:10:33

Okay, then I can update it, and you can just check later if I got it right!

1
seancorfield20:10:07

I submitted a change request for that section of the docs (with a note about poly allowing symbols instead of strings in the future).

tengstrand06:10:26

Thanks. Now it’s merged.

1
Karol Wójcik16:10:43

@furkan3ayraktar @tengstrand May I fork the following https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app? I would like to provide a Real World example of AWS Lambda proxy for Ring, and show how easily it's to develop regular applications for it.

winsome16:10:25

Ooh, I'd be interested in seeing that. The license is MIT, btw, so I think it's fair to say they've already blessed forking : )

tengstrand17:10:10

That should be fine! It’s @furkan3ayraktar’s repo, but as @U028BUU1P3R says, the license allow you to fork it!

tengstrand17:10:57

I’m looking forward to the result!

Karol Wójcik17:10:40

May I change the name of the repo as well? Thanks! 🙂

winsome18:10:16

I think MIT's only restriction is that you keep the copyright attribution: > The above copyright notice and this permission notice shall be included in all > copies or substantial portions of the Software. (from the LICENSE file) Otherwise you can do whatever you want :thumbsup:

Karol Wójcik18:10:42

Right. But still it's better to ask the author if he would accept it 😄

furkan3ayraktar19:10:52

Hahaha, thanks for being so kind! Go for it and use however you like it! The repo didn’t even have a license file until yesterday, someone actually emailed and asked me about that 😂

furkan3ayraktar19:10:06

If you keep the same api, you should be able to submit it to be displayed here: https://codebase.show/projects/realworld

seancorfield19:10:21

The docs are wrong.

clojure -Tpoly create w next-gen top-ns com.my-company
☝️:skin-tone-2: That should work but the full equivalent should be this
clojure -Tpoly create entity '"workspace"' name next-gen top-ns com.my-company
Two things to note: w sym is short for entity workspace name sym but entities need to be strings, not symbols, so '"workspace"' is required there. I think the latter is a bug in the poly tool code: the entity argument should support symbols.

1