Skip to content
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

Having Fallback Dirs Checked for SwiftLint Binary #156

Open
Blackjacx opened this issue Dec 15, 2020 · 2 comments
Open

Having Fallback Dirs Checked for SwiftLint Binary #156

Blackjacx opened this issue Dec 15, 2020 · 2 comments

Comments

@Blackjacx
Copy link

Blackjacx commented Dec 15, 2020

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

File.expand_path(File.join(File.dirname(__FILE__), 'bin', 'swiftlint'))

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
Copy link
Owner

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:

desc 'Download and install swiftlint tool'
task :install do
next if ENV['DANGER_SKIP_SWIFTLINT_INSTALL'] == 'YES'
REPO = 'https://github.com/realm/SwiftLint'
VERSION = ENV['SWIFTLINT_VERSION'] || DangerSwiftlint::SWIFTLINT_VERSION
ASSET = 'portable_swiftlint.zip'
URL = "#{REPO}/releases/download/#{VERSION}/#{ASSET}"
DESTINATION = File.expand_path(File.join(File.dirname(__FILE__), 'bin'))
puts "Downloading swiftlint@#{VERSION}"
sh [
"mkdir -p '#{DESTINATION}'",
"curl -s -L #{URL} -o #{ASSET}",
"unzip -q #{ASSET} -d '#{DESTINATION}'",
"rm #{ASSET}"
].join(' && ')
end

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

@swiftlint_path || default_swiftlint_path

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
Copy link
Author

Blackjacx commented Dec 28, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants