danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.04k stars 135 forks source link

swiftlint: command not found - how can I fix this? #604

Open skydivedan opened 5 months ago

skydivedan commented 5 months ago

My environment is CircleCI, just so you know. and this is running as a Mac executor.

My Dangerfile.swift file looks like this:

import Danger
let danger = Danger()

let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
message("These files have changed: \(editedFiles.joined(separator: ", "))")

SwiftLint.lint()

Now, while Danger does write in my PR about modified and created files, SwiftLint.lint() run, and gives this error: /bin/sh: swiftlint: command not found

Why would that be? The "danger-swift" Package contains SwiftLint as a dependency, so wouldn't it be able to run SwiftLint? Do I need to actually install SwiftLint? If so, then what does the SwiftLint dependency do?

skydivedan commented 5 months ago

additionally, the docs say that when building my Package.swift file, I should add the the target like this: .target(name: "eigen", dependencies: ["Danger"], path: "Artsy", sources: ["Stringify.swift"]),

Which I was unable to do exactly.... mine looks like this: .target(name: "eigen", dependencies: [.product(name: "Danger", package: "swift")], path: "Artsy", sources: ["Stringify.swift"]),

When I do this, Package.resolved does not include Swiftlint. The result of Package.resolved behaves as if isDevelop is false -- which is weird considering that I can see that it's set to true right in the Package.swift file itself. So, I don't know why I'm seeing this behavior.

Nikoloutsos commented 1 month ago

A quick fix would be to run something like: brew install swiftlint on your CI.

And in case you don't want to waste time on installing swiftlint you can always provide it as an executable. You can do that by setting the swiftlintPath property to .bin(<Path>).

Why would that be? The "danger-swift" Package contains SwiftLint as a dependency, so wouldn't it be able to run SwiftLint?

No I don't think that this is true. Are you using the --cwd on the command? May you please share it with us?