-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
linkage_checker: add a check for extraneous dependencies #3103
Conversation
I'm not sure I'm reading this right but is an extraneous dependency any where there's no linkage? If so, this will need to be an optional flag as there will be a lot of false positives otherwise (i.e. anything that calls an executable from a dependency rather than linking against it, most scripting language dependencies, etc.) |
A lot of false positives could be eliminated by ignoring any keg that has a |
I agree: false positives are a possibility.
reports |
Those interested in testing this, try the following "one-liner" to check your installed formulae: for formula in $(brew list); do echo "* Formula: $formula"; brew linkage $formula | sed -n '/^Possible/,/^[^ ]/p;'; done |
@ilovezfs identified that roughly half of |
@sjackman there could still be a need for |
I just took a quick look at some of the packages in Maybe these types of header-only dependencies that the linkage test can't see could be marked with https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/audit.rb#L499-L507 |
Given we're running this in CI for everything in Homebrew/homebrew-core: we really don't want false positives here.
I agree. Having this as an optional flag which is always run for new formulae in |
Please suggest test-cases or directions how to improve the code |
@maxim-belkin Use |
@MikeMcQuaid The output of |
It doesn't affect the exit status or output of https://github.com/Homebrew/homebrew-test-bot/blob/80333911e7130b9542a6fe2b94c1311b52cef319/cmd/brew-test-bot.rb#L664 ? That's what we need to avoid. |
Sorry, I wrote too quickly and didn't engage brain. I had meant to say… |
Things that are known to give a lot of false positives aren't great even for --new-formula. We keep getting contributors asking, "Will my formula still qualify if those audits are failing?" and it's getting pretty old explaining that yes CI is bright red but no that doesn't matter because it will go away next time after it's merged. |
This test will not affect the exit status of |
@sjackman in that case: how does anyone notice that output and make changes as a result? |
I'm guessing it prints console messages but doesn't affect the exit status, which is what CI cares about. |
Same as with the existing |
Just an FYI: I've prepared a version with |
Ah, I had forgotten that + test "brew", "linkage", dependent.name
test "brew", "linkage", "--test", dependent.name https://github.com/Homebrew/homebrew-test-bot/blob/master/cmd/brew-test-bot.rb#L664 |
Or |
that's a possibility. |
The current output of
|
This seems sensible. That said: how are people going to notice this for formulae in CI or is this intended to just be manually run by maintainers? I'm trying to understand the use case. |
Of 47 formulae that depend on |
|
That seems like a good workflow but I guess I'm just wondering if this is reliant on individual developers to manually do this: is it going to be useful? I see no harm in this PR as-is being merged, to be clear, I'm just trying to figure out if there's some better workflow. |
unnecessary
As long as the exit code isn't modified I'm happy as-is. It does seem like it would be useful to have this under |
@maxim-belkin I'd suggest |
If it were possible to eliminate all the false positives, then it could affect the We could add a tickbox to |
@@ -77,6 +78,11 @@ def check_undeclared_deps | |||
a <=> b | |||
end | |||
end | |||
extraneous_deps = declared_dep_names.reject do |full_name| | |||
name = full_name.split("/").last | |||
Formula[name].bin.directory? || @brewed_dylibs.keys.map { |x| x.split("/").last }.include?(name) |
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.
next true if Formula[name].bin.directory?
and put the map
on a new line so it is a little shorter.
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.
perhaps next true unless ...?
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.
nope, next true if...
:)
Let's go for this and then we can merge as-is if it's useful to you like that. |
I'd suggest also renaming the code |
Sure, will do once I get to it. Should be today (evening).
|
In my second implementation of this PR (which I'm abandoning), I had to factor out I can do that here too, if it seems reasonable/necessary. |
I wonder if we should report possible unnecessary dependencies (PUDs) with |
I think the |
can someone reinitiate the build? I think there was an intermittent issue |
Those errors are currently affecting most things 🙈 |
💩 |
Could someone have a look at the following lines of this PR more closely: line 8 and 125 through 127. |
@maxim-belkin you need to rebase the PR or it will keep failing. |
it did not fail - it did not run one of the tests. but I'll rebase the PR. |
- rename 'extraneous' to 'unnecessary' - add the report under `linkage --test`
756a3ad
to
f2531d1
Compare
any suggestion how to improve test fix "codecov/patch"? |
Looks good to me, nice work @maxim-belkin! |
Glad to contribute! |
brew tests
with your changes locally?Detect extraneous dependencies in formulae. Might be useful for new formulae.
brew tests
fail for some other tests