-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Eastwood #188
Upgrade Eastwood #188
Conversation
@@ -9,7 +9,7 @@ commands: | |||
- v2-dependencies-{{ checksum "project.clj" }} | |||
# fallback to using the latest cache if no exact match is found | |||
- v2-dependencies- | |||
- run: lein with-profile -dev,+ci,+test,+refactor-nrepl deps | |||
- run: lein with-profile -user,-dev,+ci,+test,+refactor-nrepl deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added -user
everywhere, lately I've realised that this makes commands more reproducible. It saves time that people can copy-paste commands into their terminal, resting assured that ~/.lein won't interfere.
We use this in e.g. all the important https://github.com/clojure-emacs projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea, for all my 'reproducible' commands (lein test
-aliases and such) I include -user
too :)
@@ -70,6 +70,8 @@ jobs: | |||
command: << parameters.lein_test_command >> | |||
- run: | |||
command: .circleci/e2e.sh | |||
- run: | |||
command: lein with-profile -user,+test eastwood |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to self-lint. It's not very formatting-stacky to lint all files, but it's a good idea (self-reference tends to be logically weak)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change, but i'd rather implement it in terms of formatting-stack. I did some work to support cli invocation.
But i'd be fine with replacing this CI step when that's ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest having both for the hinted reason: using f-s to lint f-s is somewhat weak. It can self-report being OK while it's not.
One would run the self-linting before Eastwood though, for fast feedback.
This could be an entire sequence:
- f-s self-lint (kondo + eastwood, git diff only)
- clj-kondo, whole project
- eastwood, whole project
Maybe a little annoying for our standards of fast CI linting, but it could catch an issue the test suite didn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my suggestion it'd run the linter across the entire project as well. But we'll cross that bridge when we get there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be an issue in strategies, in reporting, in interaction with a given linter impl... bunch of things that can go wrong
@@ -131,14 +134,12 @@ | |||
;; (and shipped with this refactor-nrepl): | |||
:plugins [[cider/cider-nrepl "0.24.0"]]} | |||
|
|||
:parallel-eastwood {:jvm-opts ["-Dformatting-stack.eastwood.parallelize-linters=true"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eastwood already parallelizes linters now
(f-s' own testing aided that decision!)
@@ -5,45 +5,6 @@ | |||
[formatting-stack.protocols.spec :as protocols.spec] | |||
[nedap.speced.def :as speced])) | |||
|
|||
(speced/defn ^boolean? contains-dynamic-assertions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix made its way into Eastwood ~1y ago
(-> f | ||
Thread. | ||
;; Important - daemonize this thread, otherwise under certain conditions it can prevent the JVM from exiting. | ||
;; (We exercise this implicitly via `lein eastwood` in CI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comment hints, the thing being fixed here is that a non-daemonized thread can leave the JVM hanging forever.
I certainly have experieced that with f-s a bunch of times, it's very annoying.
@@ -24,10 +24,10 @@ | |||
(apply list runner-choice body)) | |||
|
|||
;; Use kondo's official default config dir, so that we don't bloat consumers' project layouts: | |||
(def cache-parent-dir ".clj-kondo") | |||
(def ^String cache-parent-dir ".clj-kondo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes found by Eastwood
@@ -27,11 +27,11 @@ | |||
|
|||
"test-resources/eastwood_warning.clj" | |||
(matchers/in-any-order | |||
[{:source :eastwood/warn-on-reflection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the linter rename is a breaking change
OTOH any Eastwood upgrade can bring new warning types (e.g. :eastwood/boxed-math
) so it to be expected that types can appear/disappear over time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it would if we had silencing / blacklisting implemented (see #132). So I think this'll be fine :)
@@ -53,8 +45,7 @@ | |||
:filename (if (string? uri-or-file-name) | |||
uri-or-file-name | |||
(-> ^File uri-or-file-name .getCanonicalPath))))) | |||
(concat (impl/warnings->reports output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like that the output-parsing is gone now 😬 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes to self, will fix along any feedback
cbbbf20
to
79397ba
Compare
Amended to use |
Removed the redundant config file. Strangely that revealed an unrelated failing test. I got to fix it by moving it to a different ns, prevening the git-cloning fixture from being run for it. |
Yeah I looked into this for a bit and am not sure what is actually happening. Moving the test out of this test-ns works but doesn't fix the root cause (maybe the |
The fixture was making
whereas they were expected to be like this:
...so it seems to me that |
That makes sense; the test-fixture sets a different CWD to make sure the git-commands run in the right CWD; but that obviously doesn't work for the refresh dirs. I'm currently checking why the test succeeded before a805eb0 edit: it seems to have found specifically Anyway; I'm not a big fan of the test being moved out of the 'idiomatic' namespace, we could just set diff --git a/test/integration/formatting_stack/strategies.clj b/test/integration/formatting_stack/strategies.clj
index 01d0dbc..b7be982 100644
--- a/test/integration/formatting_stack/strategies.clj
+++ b/test/integration/formatting_stack/strategies.clj
@@ -5,6 +5,7 @@
[clojure.set :as set]
[clojure.string :as string]
[clojure.test :refer [deftest is testing use-fixtures]]
+ [clojure.tools.namespace.repl :refer [refresh-dirs]]
[formatting-stack.strategies :as sut]
[formatting-stack.test-helpers :as test-helpers :refer [git-integration-dir]]
[formatting-stack.util :refer [rcomp]]
@@ -231,16 +232,18 @@
(cleanup-testing-repo!)))))
(deftest namespaces-within-refresh-dirs-only
- (speced/let [^{::speced/spec (rcomp count (partial < 100))}
- all-files (sut/all-files :files [])
- result (sut/namespaces-within-refresh-dirs-only :files all-files)]
- (is (seq result)
- "Returns non-empty results (since f-s itself has namespaces within `src`, `test`, etc)")
-
- (is (< (count result)
- (count all-files))
- "Doesn't include files outside the refresh dirs")
-
- (is (set/subset? (set result)
- (set all-files))
- "Is a subtractive (and not additive) mechanism")))
+ (with-redefs [refresh-dirs [(str (io/file git-integration-dir "src"))
+ (str (io/file git-integration-dir "test"))]]
+ (speced/let [^{::speced/spec (rcomp count (partial < 100))}
+ all-files (sut/all-files :files [])
+ result (sut/namespaces-within-refresh-dirs-only :files all-files)]
+ (is (seq result)
+ "Returns non-empty results (since f-s itself has namespaces within `src`, `test`, etc)")
+
+ (is (< (count result)
+ (count all-files))
+ "Doesn't include files outside the refresh dirs")
+
+ (is (set/subset? (set result)
+ (set all-files))
+ "Is a subtractive (and not additive) mechanism"))))
|
655b8ef
to
85d5e9f
Compare
Rebased and added a minor commit |
Context: nedap#188 (comment)
85d5e9f
to
613bef6
Compare
Added a commit following PR feedback, and removed the old one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me! Left 2 comments but nothing mayor.
(catch Exception e | ||
(swap! exceptions conj e)))))] | ||
exceptions (atom nil)] | ||
(with-out-str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting-stack.util/silence
might be helpful here, since you're not capturing the output:
(defmacro silence |
@@ -12,36 +12,22 @@ | |||
(java.io File))) | |||
|
|||
(def default-eastwood-options | |||
;; Avoid false positives or undesired checks: | |||
(let [linters (remove #{:suspicious-test :unused-ret-vals :constant-test :wrong-tag} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these linters currently disabled by default in eastwood? What if they'll be re-enabled in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these linters currently disabled by default in eastwood? What if they'll be re-enabled in the future?
They've been fixed upstream (i.e. they shouldn't give false positives) so there's no further need of disabling them.
(Which is why QAing a few large projects is recommended)
613bef6
to
165edfb
Compare
Rebased again, now we have 3 commits. The first one includes the |
Thanks a lot for the patience and the work! |
Brief
Long due one!
Some of the changes in Eastwood that are most relevant to f-s:
QA plan
For the Eastwood changes, I'd recommend linting large projects and verifying/fixing that the newly enabled linters aren't being problematic. Please report any false positives.
For the
runner
change, one can(formatting-stack.core/format)
and observe that the background runner keeps doing its job.Author checklist
runner
change is "breaking" (changed a type from Future to Thread), at the same that ns is quite clearly not an APIrunner
Reviewer checklist