Fork me on GitHub
#polylith
<
2022-11-17
>
Jungin Kwon13:11:44

After reading https://polylith.gitbook.io/poly/workflow/profile, I am making a polylith example. https://github.com/yyna/polylith-example is my repository and when the dependency is not specified https://github.com/yyna/polylith-example/blob/main/deps.edn#L9-L10, an error that cannot find the library occurs when the project is executed. Can anyone help?

; Evaluating file: core.clj
; Execution error (FileNotFoundException) at greenlabs.rest-api.core/eval5716$loading (core.clj:1).
; Could not locate muuntaja/core__init.class, muuntaja/core.clj or muuntaja/core.cljc on classpath.
; Evaluation of file core.clj failed: class clojure.lang.Compiler$CompilerException

seancorfield13:11:20

The only reason to use paths in :dev is to workaround a bug in Cursive, and that also means you need to duplicate all the bricks' dependencies in that alias too. Which is terrible. If you use :extra-deps with :local/root instead (as intended), the bricks' deps will work.

seancorfield13:11:38

There's a long-standing bug open against Cursive to fix this. Your example should do things properly and perhaps just warn people about the problem with Cursive.

Jungin Kwon13:11:03

I use Calva! calva switched from Cursive because of that bug.

1
👍 1
Jungin Kwon13:11:50

I use local/root well in my company project. It doesn’t work for this project only, so I’m wondering.

seancorfield13:11:55

You're using paths, not deps, in :dev.

seancorfield13:11:19

Switch to deps and it should work

Jungin Kwon14:11:02

you mean this?

Jungin Kwon14:11:15

This is not working, either.

seancorfield14:11:40

I can take a look at the repo when I get to work (on my phone right now), but that looks like it should work...

❤️ 1
seancorfield14:11:20

You'd need to switch your profiles too

seancorfield14:11:31

And the rest-api dep needs to be pulled out to a default profile I think?

👀 1
seancorfield14:11:39

Hmm, it's a base in dev but you are depending on projects in the profiles which doesn't seem right?

seancorfield14:11:47

Hard to read on the phone - will take a better look when I get to my desk. Is there a default sms component? I only see that in the two profile aliases...

Jungin Kwon14:11:13

No hurry 😁

Jungin Kwon14:11:41

Please take a look at your convenience.

seancorfield17:11:52

I created https://github.com/yyna/polylith-example/pull/1 to show what changes I was suggesting and what tests/REPLs work for me. Hope that helps?

Jungin Kwon23:11:51

Thank you so much for taking time for this. ❤️🙏

Jungin Kwon23:11:24

I tried the way you suggested. Project tests are executed even though project tests are not specified in deps.edn. When I see the example from the polylith document, it has projects/{name}/test folder in their extra-paths. This is location of the example code. https://github.com/polyfy/polylith/blob/master/examples/doc-example/deps.edn

Jungin Kwon23:11:42

BTW, it’s so nice that deps.edn has been compacted.

seancorfield00:11:06

Sounds like that doc-example might need some updating...? @tengstrand first off, the example assumes Cursive-compatible (paths vs deps, and duplication of bricks' deps into :dev alias); second, are the project tests on the :extra-paths for the :test alias purely for some sort of reachability in the REPL in :dev:test mode? Since I work by eval'ing files from my editor into my connected REPL, I can load any source (or test!) file and eval it, without it needing to be on the classpath, so it had never occurred to me that projects/*/test might need to be in the :test alias... Perhaps the example deps.edn needs more comments around why folks might or might not do that? cc @james @furkan3ayraktar (not sure how involved you've been in the doc examples?)

🙏 1
furkan3ayraktar12:11:01

Since we all use Cursive for Polylith projects, the examples followed the Cursive setup by default. What do you think about it @tengstrand ?

tengstrand12:11:20

One idea is to add a comment block in these config files, showing how to configure using the :local/root syntax.

👍 2
seancorfield17:11:58

I think it would be better to show the non-Cursive setup by default and then have the Cursive setup in a comment -- or as a separate, clearly-labeled example. Whilst Cursive is popular, more people use other editors (Emacs, VS Code, vim, etc) which do not have the shortcoming that Cursive has here -- and the docs end up giving mixed messages on, for example, library dependencies in bricks because of this (b/c you shouldn't need to duplicate them into :dev -- that's just an unfortunate workaround for the bug in Cursive). That's the same line of thinking that has nearly all projects showing command-line instructions for macOS/Linux and then a footnote for Windows where the quoting has to be different.

👍 1
☝️ 1
seancorfield17:11:53

(I think Polylith docs should encourage people to avoid Cursive until that bug is fixed, but that's a separate argument)

tengstrand08:11:44

My hope was that the Cursive https://github.com/cursive-ide/cursive/issues/2554 would have been solved by now. The other idea is to use Calva in the examples, as described in https://github.com/polyfy/polylith/issues/123 issue.

1
bringe22:11:25

I’m curious how others approach writing tests for components in terms of interface vs implementation tests. If you have a component with function foo in its interface, do you write tests against the interface foo or the implementation foo? I guess my main question is: considering interface functions are pass through functions (should be, at least), does it matter?

seancorfield23:11:23

I mostly try to write tests against the interface because that's the public face of the component that other code will interact with. I may also have some implementation tests if I feel the need to test parts of the implementation logic.

seancorfield23:11:35

We have a number of components where the interface functions are not pure pass-through -- we have some variadic interface functions that map to a non-variadic implementation function, for example, or multiple interface functions with expressive naming that map to a generic implementation function that is passed one or more arguments that indicate what behavior is needed (our HTTP client component exposes get, post, etc but our implementation has request that takes a method argument).

seancorfield23:11:17

(and we have a few interface functions that just have the logic inline for... reasons... 🙂 )

bringe00:11:42

Ahh I see. Thanks. Yeah we use some components specifically for schemas and for those we put the schemas directly in the interface.

Hukka08:11:58

While we don't do that consistently, testing against the interface would make sure that even if the interface is passthrough, there are no omissions when doing changes like changing parameter order, changing arity etc.

bringe17:11:41

Yeah, that’s been my thinking.

seancorfield00:11:06

Sounds like that doc-example might need some updating...? @tengstrand first off, the example assumes Cursive-compatible (paths vs deps, and duplication of bricks' deps into :dev alias); second, are the project tests on the :extra-paths for the :test alias purely for some sort of reachability in the REPL in :dev:test mode? Since I work by eval'ing files from my editor into my connected REPL, I can load any source (or test!) file and eval it, without it needing to be on the classpath, so it had never occurred to me that projects/*/test might need to be in the :test alias... Perhaps the example deps.edn needs more comments around why folks might or might not do that? cc @james @furkan3ayraktar (not sure how involved you've been in the doc examples?)

🙏 1