garriguv / danger-ruby-swiftformat

A danger plugin to check Swift formatting using SwiftFormat.
MIT License
39 stars 15 forks source link

Config file #24

Closed rumnat closed 4 years ago

rumnat commented 5 years ago

Hi, I get the error

bundler: failed to load command: danger (/usr/local/bin/danger)
    Danger::DSLError: 
    [!] Invalid `Dangerfile` file: No such file or directory - swiftformat. Updating the Danger gem might fix the issue. Your Danger version: 6.0.6, latest Danger version: 6.0.9

     #  from Dangerfile:20
     #  -------------------------------------------
     #  swiftformat.additional_args = "--config swiftformat"
     >  swiftformat.check_format(fail_on_error: true)
     #  
     #  -------------------------------------------

Danger file and swiftformat file are in the same folder

garriguv commented 5 years ago

This looks like a Ruby issue.

rumnat commented 5 years ago

Yes, here is my Gemfile:

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'danger'
gem 'danger-swiftlint'
gem 'danger-jira'
gem 'danger-swiftformat'

danger running command bundle exec danger --fail-on-errors=true

I also have .ruby-version file with 2.4.1 setting

rumnat commented 5 years ago
      /Users/buddybuild/.rubies/ruby-2.5.1/lib/ruby/2.5.0/open3.rb:199:in `spawn'
      /Users/buddybuild/.rubies/ruby-2.5.1/lib/ruby/2.5.0/open3.rb:199:in `popen_run'
      /Users/buddybuild/.rubies/ruby-2.5.1/lib/ruby/2.5.0/open3.rb:95:in `popen3'
      /Users/buddybuild/.rubies/ruby-2.5.1/lib/ruby/2.5.0/open3.rb:258:in `capture3'
      /Users/buddybuild/.gem/ruby/2.5.1/gems/danger-swiftformat-0.6.0/lib/swiftformat/cmd.rb:7:in `run'
      /Users/buddybuild/.gem/ruby/2.5.1/gems/danger-swiftformat-0.6.0/lib/swiftformat/swiftformat.rb:10:in `installed?'
      /Users/buddybuild/.gem/ruby/2.5.1/gems/danger-swiftformat-0.6.0/lib/swiftformat/plugin.rb:40:in `check_format'

something with an installed check

garriguv commented 4 years ago

Are you still encountering this issue?

rumnat commented 4 years ago

I gave up then and moved it to a run script phase for the tests target

garriguv commented 4 years ago

Ah, I think I got it. It’s likely that the tool can’t find the swiftformat binary, hence the error.

It’s a bit tool late now though. Sorry about that. I’ll close the issue.

Happy holidays.

stherold commented 11 months ago

I encounter this now :-(

garriguv commented 11 months ago

@stherold how is swiftformat installed in your project? This error is thrown when the script cannot find the swiftformat binary.

stherold commented 11 months ago

Argh I, got it! I think we have a special case. I want to make it work using GitHub Actions and as a bonus the tooling uses the Ubuntu runner from GH Actions where no SwiftFormat is installed. Sadly I wasn't able to find any great workflow example that demonstrates the full integration as follows:

Did you encounter a working example in the past when creating the plugin?

garriguv commented 11 months ago

@stherold I haven't used the plugin in years 😃

However, when I did, I always vendored the binary to make sure that the whole team was using the same one. Our CI used macOS machines, so they could use the vendored binary as well, which is probably not the case for you.

My recommendation would be to find out where the swiftformat binary gets installed on your CI, then use that as the binary_path.