ashfurrow / danger-ruby-swiftlint

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

Danger-Swiftlint (0.9) isn't working with Danger (5.4.1) #56

Closed nikhilsh closed 7 years ago

nikhilsh commented 7 years ago

Running swiftlint locally runs fine and generates expected output. However, running bundle exec danger local with swiftlint.lint_files has no output from swiftlint, just the danger commands.

Danger - 5.4.1 Danger-swiftlint - 0.9 Swiftlint - 0.22.0

ashfurrow commented 7 years ago

Hmm, sorry to hear about that. Can you provide output? I have some time this weekend I can take a look.

nikhilsh commented 7 years ago

Yeah I understand it's hard to debug this. I don't see any output though so I'm not too sure how to provide it. Are there any logs somewhere I could check?

Using pry I am able to see this:

[1] pry(#<Danger::Dangerfile>)> swiftlint
=> #<Danger::DangerSwiftlint:0x007f9685506108
 @core_plugins=nil,
 @danger=nil,
 @defined_in_file=nil,
 @env=nil,
 @git=nil,
 @github=nil,
 @messaging=nil,
 @plugins=nil,
 @slather=nil,
 @swiftlint=nil,
 @ui=nil,
 @verbose=nil>
[2] pry(#<Danger::Dangerfile>)> slather.show_coverage
=> ["## Code coverage\n" + "### Total coverage: **`14.70%`**\n" + "> Powered by [Slather](https://github.com/SlatherOrg/slather)"]
[3] pry(#<Danger::Dangerfile>)> swiftlint.lint_files
=> nil

Where the DangerSwiftlint plugin seems to be initialised. I tried running the slather plugin as slather.show_coverage and got expected output, but when i ran the swiftlint.lint_files, nil was returned. Any thing else I should try?

ashfurrow commented 7 years ago

Thanks! Hmm. I'll take a look this weekend, maybe get some advice on testing plugins from @orta.

orta commented 7 years ago

You're probably going to need to run through some of the code blocks in lint_files inside pry to check what data it's running against, testing wise this repo looks pretty fine to me, maybe there's some edge cases specific to your PR? If it's OSS then it's possible for ash to emulate it with danger pr xxx also

nikhilsh commented 7 years ago

Sadly it’s not OSS. I’ll try to create a sample project and work through it with my company’s GitHub Enterprise + Jenkins set up and see if that throws any issues.

I can’t give a sample project this weekend though as I’m overseas away from my work com. If the versions I listed in the original comment above work for everyone else then I think @ashfurrow, there isn’t much you can do and I’ll look into it first thing when I’m back at work next week. Thanks guys

ashfurrow commented 7 years ago

Okay, so I did look into this using Moya and a testbed. I originally just changed some swift files locally and tried danger local but was surprised by the result. Instead of running Danger against my local changes, it ran Danger against the last pull request on the repo. I asked Orta and this is expected – danger local is for testing changes to your Dangerfile, not for running the Dangerfile against your locally checked out code.

I was able to run bundle exec danger pr https://github.com/Moya/Moya/pull/1237 to run the plugin against a PR in Moya known to have SwiftLint violations and it worked as expected (using the versions of Danger/danger-swiftlint` that you specified). This is, I think, non-obvious behaviour from Danger, so I've opened an issue to discuss.

Looking forward to hearing back if this resolves things!

nikhilsh commented 7 years ago

Hey sorry for the delay in getting back to this issue. Unfortunately I’m still unable to get this plugin to run against my code base at work. As you have verified that the versions specified work well together, I’ll go ahead and close this issue. If in the future I am able to find out what’s wrong, I’ll be sure to update here. Thanks a lot for the help @ashfurrow and @orta 🙂

Sent with GitHawk