ashfurrow / danger-ruby-swiftlint

A Danger plugin for SwiftLint.
https://rubygems.org/gems/danger-swiftlint
MIT License
203 stars 81 forks source link

Having Fallback Dirs Checked for SwiftLint Binary #156

Open Blackjacx opened 3 years ago

Blackjacx commented 3 years ago

I'm not a ruby expert but as it looks like the plugin searches in the plugin/gem directory for the swiftlint binary:

https://github.com/ashfurrow/danger-ruby-swiftlint/blob/d1ac19bbe5a518b7bd5f343aeea84c5df6e2e2c3/ext/swiftlint/swiftlint.rb#L66

Usually people install the binary using Homebrew or Mint. In both cases the binary will be stored/linked in /usr/local/bin. What if we implement a list of paths that get checked for the binary. The one with a match is returned. We could prioritize the current default path if desired, so that all the current implementations don't have to change anything. As second option I would like to check /user/local/bin.

What do you think?

ashfurrow commented 3 years ago

That would complicate things slightly, and it's already a bit complex 😅 We actually install the swiftlint binary for users when the gem is installed on CI:

https://github.com/ashfurrow/danger-ruby-swiftlint/blob/d1ac19bbe5a518b7bd5f343aeea84c5df6e2e2c3/ext/swiftlint/Rakefile#L6-L23

But we also allow users to specify a path to their own installation:

https://github.com/ashfurrow/danger-ruby-swiftlint/blob/d1ac19bbe5a518b7bd5f343aeea84c5df6e2e2c3/ext/swiftlint/swiftlint.rb#L37

I think that your suggestion, of having a list of paths to check for a swiftlint installation, would make sense if this gem weren't already installing it for you. It feels like "install this automatically by default" and "look for the binary automatically by default" are at odds, if that makes sense?

Blackjacx commented 3 years ago

Ahhh thats maybe the reason. In our case the GEMs are cached on Bitrise CI... Maybe that prevents the installation. The thing is on our CI this tool is not found under /usr/local/bin.But not sure.

The reason might also be that Bitrise hasn't have swiftlint installed by default. At the moment we install gems first and then swiftlint after that via mint. Could that be the reason 🤔

The reason for all of this is that this suddenly stopped working recently and we had a hard time then to manually install it.