Fork me on GitHub
#leiningen
<
2020-01-29
>
Matthew Davidson (kingmob)16:01:43

What is the purpose of lein check? Does it catch anything that would be missed by compile or uberjar?

mikerod16:01:42

@kingmob compile only compiles explicit :aot classes

mikerod16:01:10

so if you have a project that doesn’t use :aot (typical), then you haven’t necessarily ensured all your source files can compile

mikerod16:01:38

also, lein check will always enable *warn-on-reflection* it seems

mikerod16:01:03

and lastly, lein check will try to gather up all failures in one pass I believe. so it won’t necessarily stop after one and wait for a fix there, then have to rerun it for next one, etc

mikerod16:01:17

since you mentioned uberjar above, it maybe the case you are using lein uberjar with something like :aot :all - which in that case the compile prep-tasks that is ran (by default) would catch most of the things lein check would - but it’s only due to you having more things happening in that profile setup in this case.

mikerod16:01:49

and it’s still a potentially slower way, and more step-by-step failing way, to get similar info you’d get by lein check

Matthew Davidson (kingmob)16:01:21

Thanks @mikerod. We’re calling lein check as part of our CICD process, and I’m wondering if lein check is redundant with all the later steps (compile, uberjar, etc)

mikerod17:01:53

if you are using uberjar + :aot :all or some sort of :aot that includes all your relevant source files you want to ensure can compile, eg :aot [my.top.level.ns], then it is somewhat redundant for those cases

🙏 4
mikerod17:01:09

with the exception that you won’t get *warn-on-reflection* for “free” if that matters to you

mikerod17:01:45

you can set :global-vars {*warn-on-reflection* true} in the project.clj as well though to get similar even without necessarily using lein check (I think it’ll be used during compile as well this way)

noisesmith18:01:46

I like having check as a separate step, because there's information in that failure (your code isn't loadable as it sits in the repo), while uberjar has other kinds of potential failure

noisesmith18:01:05

I have a custom version of check which also looks at test files

noisesmith18:01:02

@kingmob for a use case example: I'm doing a big whole-project refactor and as I iterate I want to ensure I don't break the codebase, so I do one part of the change at a time, and ensure lein check passes

noisesmith18:01:24

I don't need to make uberjars or compile classes - that's unrelated to my task

mikerod19:01:58

@noisesmith you can get lein check to check more ns’s by adding them to :source-paths - like in a profile

mikerod19:01:07

but yeah, I do like the seprate step in many situations too