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

Running from non-root directory issue #50

Open
luongvo opened this issue Aug 28, 2023 · 1 comment
Open

Running from non-root directory issue #50

luongvo opened this issue Aug 28, 2023 · 1 comment

Comments

@luongvo
Copy link

luongvo commented Aug 28, 2023

Hi @garriguv,

I'm working on a KMM project, and the KMM project is inside a sample folder.

  • The ios module of the KMM project is located at sample/ios.
  • The Dangerfile of the iOS project is at sample/ios/Dangerfile.

Running the Danger with SwiftFormat produces a File not found error as below. The cause is while danger-ruby-swiftformat returns the list of swift files with the full path from the root dir, e.g. sample/ios/fastlane/Constants/Constant.swift, including sample/ios, SwiftFormat joins them with the current working dir /Users/runner/work/kmm-templates/kmm-templates/sample/ios/.

Run bundle exec danger --danger_id=danger_ios
From https://github.com/nimblehq/kmm-templates
 * [new branch]      chore/optimize-test-workflow-to-execute-on-the-sample-project -> origin/chore/optimize-test-workflow-to-execute-on-the-sample-project
bundler: failed to load command: danger (/usr/local/lib/ruby/gems/3.0.0/bin/danger)
/usr/local/lib/ruby/gems/3.0.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/swiftformat.rb:31:in `check_format': \e[31m (Danger::DSLError)
[!] Invalid `Dangerfile` file: Error running SwiftFormat:
Error: \e[0merror: File not found at /Users/runner/work/kmm-templates/kmm-templates/sample/ios/sample/ios/fastlane/Constants/Constant.swift.\e[0m
 #  from Dangerfile:14
 #  -------------------------------------------
 #  swiftformat.exclude = %w(Pods/**  **/*generated.swift)
 >  swiftformat.check_format
 #  
 #  -------------------------------------------
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/plugin.rb:54:in `check_format'
	from Dangerfile:14:in `eval_file'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:311:in `eval'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:311:in `eval_file'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:204:in `block in parse'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:201:in `instance_eval'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:201:in `parse'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:28[7](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:8):in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/executor.rb:2[8](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:9):in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-[9](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:10).3.1/lib/danger/commands/runner.rb:73:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/bin/danger:5:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/danger:25:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/danger:25:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:[11](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:12)7:in `with_friendly_errors'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/bundle:25:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/bundle:25:in `<main>'
/usr/local/lib/ruby/gems/3.0.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/swiftformat.rb:31:in `check_format': Error running SwiftFormat: (RuntimeError)
Error: \e[0merror: File not found at /Users/runner/work/kmm-templates/kmm-templates/sample/ios/sample/ios/fastlane/Constants/Constant.swift.\e[0m
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/plugin.rb:54:in `check_format'
	from Dangerfile:14:in `eval_file'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:311:in `eval'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:311:in `eval_file'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:204:in `block in parse'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:201:in `instance_eval'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:201:in `parse'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/dangerfile.rb:287:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/danger_core/executor.rb:28:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/lib/danger/commands/runner.rb:73:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/danger-9.3.1/bin/danger:5:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/danger:25:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/danger:25:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:[12](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:13)7:in `invoke_command'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:1[17](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:18):in `with_friendly_errors'
	from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.4.[19](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:20)/exe/bundle:29:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/bundle:[25](https://github.com/nimblehq/kmm-templates/actions/runs/5982564343/job/16231801560#step:12:26):in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/bundle:25:in `<main>'
[!] The exception involves the following plugins:
 -  danger-swiftformat
Error: Process completed with exit code 1.
@hbmartin
Copy link

hbmartin commented Nov 8, 2023

I was able to workaround this by running Danger from within the ios directory and adding a symlink hack on CI `cd ios; ln -s . ios

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