danger / swift

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

Danger 3.19.1 is not working on Xcode 16. #623

Closed harryngict closed 1 month ago

harryngict commented 2 months ago

Hi Team, We are using Danger 3.19.1 on our Bitrise. before XCode 15 that working fine. After we upgrade to XCode 16, Bitrise throw the error:

################### DANGER ###################### Run danger /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/9D80CAB8-A906-4735-AD6E-128CA0161196/_tmpdangerfile.swift:2:8: error: no such module 'Danger' 1 | import Foundation 2 | import Danger | `- error: no such module 'Danger' 3 | 4 | func checkReviewers( bitbucketCloud: BitBucketCloud) { ERROR: Dangerfile eval failed at Dangerfile.swift ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/9D80CAB8-A906-4735-AD6E-128CA0161196/danger-response.json Failing the build, there is 1 fail.

ialimz commented 2 months ago

Any updates on this?

iwb-kevin-hirsch commented 2 months ago

We're also facing the same issue 😢 Would love to see any updates on this!

icecoffin commented 1 month ago

We are experiencing the same issue running Danger-Swift on Ubuntu, so Xcode is not involved. Could it be a Swift 6 issue?

andr3a88-amk commented 1 month ago

Same experience on Github Actions

skydivedan commented 1 month ago

We are experiencing the same issue running Danger-Swift on Ubuntu, so Xcode is not involved. Could it be a Swift 6 issue?

I don't see how. The Package. swift that I use for Danger is marked as 5.10. And I don't have Swift 6 enabled anywhere in my project.

icecoffin commented 1 month ago

I don't see how. The Package. swift that I use for Danger is marked as 5.10. And I don't have Swift 6 enabled anywhere in my project.

The swift-tools-version in Package.swift defines the minimum version of Swift tools required to build the package. I was referring to the Swift 6 toolchain, not the Swift 6 language - apologies for the confusion. If the system only has Swift 6 toolchain installed (which seems to be the case with the Ubuntu runners), it will be used to build the package.

oronbz commented 1 month ago

Also happening on 3.20.0:

danger-swift 3.18.1 is already installed but outdated (so it will be upgraded).
==> Fetching danger/tap/danger-swift
==> Downloading https://github.com/danger/danger-swift/archive/3.20.0.tar.gz
==> Downloading from https://codeload.github.com/danger/swift/tar.gz/refs/tags/3.20.0
==> Upgrading danger/tap/danger-swift
  3.18.1 -> 3.20.0 
==> make install PREFIX=/opt/homebrew/Cellar/danger-swift/3.20.0
🍺  /opt/homebrew/Cellar/danger-swift/3.20.0: 8 files, 3.9MB, built in 39 seconds
Warning: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK is set: not checking for outdated
dependents or dependents with broken linkage!
+ echo '⚠️ DANGER ! :)'
⚠️ DANGER ! :)
+ danger-swift ci
/var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/FFA7F08D-5ACD-4F14-9B3C-8765A95A10D2/_tmp_dangerfile.swift:1:8: error: no such module 'Danger'
 1 [REDACTED] import Danger
   [REDACTED]        `- error: no such module 'Danger'
 2 [REDACTED] import Foundation
 3 [REDACTED] 
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/FFA7F08D-5ACD-4F14-9B3C-8765A95A10D2/danger-response.json
Failing the build, there is 1 fail.
Feedback: https://github.com/gtforge/gtforge-iphone/pull/3919#issuecomment-2411101472
ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/FFA7F08D-5ACD-4F14-9B3C-8765A95A10D2/danger-response.json
Sega-Zero commented 1 month ago

the homebrew version is not working, SwiftPM version is not working either. seeing a new releases, but none helps.

f-meloni commented 1 month ago

SwiftPM is working on 3.20.0 (https://github.com/danger/swift/issues/615) while brew should now be working on 3.20.1, please let me know if it works

Sega-Zero commented 1 month ago

nope. Tried SwiftPM today, still no luck when trying to use SwiftLint

launch log ```bash swift run danger-swift ci [0/1] Planning build Building for debugging... [0/14] Write sources [9/14] Write danger-swift-entitlement.plist [10/14] Write swift-version--58304C5D6DBC2206.txt [12/24] Emitting module Require [13/24] Compiling Require Require.swift [14/24] Emitting module DangerShellExecutor [15/24] Compiling DangerShellExecutor ShellExecutor.swift [16/24] Compiling Logger Logger.swift [17/24] Emitting module Logger [18/24] Emitting module ShellOut [19/24] Compiling ShellOut ShellOut.swift [20/38] Emitting module Files [21/38] Compiling Files Files.swift [22/43] Emitting module RunnerLib [23/43] Emitting module Releases [24/44] Compiling RunnerLib HelpMessagePresenter.swift [25/44] Compiling RunnerLib NSRegularExpression+FilesImport.swift [26/44] Compiling RunnerLib Runtime.swift [27/44] Compiling RunnerLib ImportsFinder.swift [28/44] Compiling RunnerLib GetDangerJSPath.swift [29/44] Compiling RunnerLib DangerfileArgumentsPath.swift [30/44] Compiling RunnerLib DangerSwiftOption.swift [31/44] Compiling RunnerLib CliArgs.swift [32/44] Compiling RunnerLib CliArgsParser.swift [33/44] Compiling RunnerLib CreateConfig.swift [34/44] Compiling RunnerLib DangerCommand.swift [35/44] Compiling RunnerLib DangerFileGenerator.swift [36/44] Compiling RunnerLib DangerJSVersionFinder.swift [37/44] Compiling Releases ReleasesError.swift [38/44] Compiling Releases Array+Version.swift [39/44] Compiling Releases Releases.swift [40/44] Compiling Releases Version.swift [41/44] Compiling RunnerLib SPMDanger.swift [42/72] Compiling MarathonCore PrintableError.swift [43/72] Compiling MarathonCore Printer.swift [44/72] Compiling MarathonCore Task.swift [45/72] Compiling MarathonCore URL+Marathon.swift [46/72] Compiling MarathonCore Help.swift [47/72] Compiling MarathonCore Install.swift [48/72] Compiling MarathonCore List.swift [49/72] Compiling MarathonCore Marathon.swift [50/72] Compiling MarathonCore MarathonFile.swift [51/72] Compiling MarathonCore Package.swift [52/72] Compiling MarathonCore Script.swift [53/72] Compiling MarathonCore ScriptManager.swift [54/72] Compiling MarathonCore PackageManager.swift [55/72] Compiling MarathonCore Perform.swift [56/72] Compiling MarathonCore ShellOut+Marathon.swift [57/72] Compiling MarathonCore String+Marathon.swift [58/72] Compiling MarathonCore Command.swift [59/72] Compiling MarathonCore Create.swift [60/72] Compiling MarathonCore Edit.swift [61/72] Compiling MarathonCore Remove.swift [62/72] Compiling MarathonCore Run.swift [63/72] Compiling MarathonCore Executable.swift [64/72] Compiling MarathonCore FishAutocompleteInstaller.swift [65/72] Compiling MarathonCore Folder+Marathon.swift [66/72] Emitting module MarathonCore [67/72] Compiling MarathonCore Add.swift [68/72] Compiling MarathonCore Array+Marathon.swift [69/72] Compiling MarathonCore Codable+TypeInference.swift [70/74] Compiling MarathonCore Update.swift [71/74] Compiling MarathonCore ZshAutocompleteInstaller.swift [72/81] Compiling Runner MarathonScriptManager.swift [73/81] Compiling Runner RunDangerJS.swift [74/81] Compiling Runner Script+Imports.swift [75/81] Compiling Runner main.swift [76/81] Compiling Runner Edit.swift [77/81] Emitting module Runner [78/81] Compiling Runner Runner.swift [78/81] Write Objects.LinkFileList [79/81] Linking danger-swift [80/81] Applying danger-swift Build of product 'danger-swift' complete! (9.83s) (node:19056) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) /pr/.build/debug/SwiftBasicFormat-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftBasicFormat' 1 | module SwiftBasicFormat { | `- error: redefinition of module 'SwiftBasicFormat' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftBasicFormat-tool.build/SwiftBasicFormat-Swift.h" 3 | requires objc /pr/.build/debug/SwiftBasicFormat.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftBasicFormat { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftBasicFormat.build/SwiftBasicFormat-Swift.h" 3 | requires objc /pr/.build/debug/SwiftParser.build/module.modulemap:1:8: error: redefinition of module 'SwiftParser' 1 | module SwiftParser { | `- error: redefinition of module 'SwiftParser' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftParser.build/SwiftParser-Swift.h" 3 | requires objc /pr/.build/debug/SwiftParser-tool.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftParser { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftParser-tool.build/SwiftParser-Swift.h" 3 | requires objc /pr/.build/debug/SwiftCompilerPluginMessageHandling.build/module.modulemap:1:8: error: redefinition of module 'SwiftCompilerPluginMessageHandling' 1 | module SwiftCompilerPluginMessageHandling { | `- error: redefinition of module 'SwiftCompilerPluginMessageHandling' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftCompilerPluginMessageHandling.build/SwiftCompilerPluginMessageHandling-Swift.h" 3 | requires objc /pr/.build/debug/SwiftCompilerPluginMessageHandling-tool.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftCompilerPluginMessageHandling { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftCompilerPluginMessageHandling-tool.build/SwiftCompilerPluginMessageHandling-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntaxMacros-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntaxMacros' 1 | module SwiftSyntaxMacros { | `- error: redefinition of module 'SwiftSyntaxMacros' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntaxMacros-tool.build/SwiftSyntaxMacros-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntaxMacros.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntaxMacros { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntaxMacros.build/SwiftSyntaxMacros-Swift.h" 3 | requires objc /pr/.build/debug/ArgumentParserToolInfo.build/module.modulemap:1:8: error: redefinition of module 'ArgumentParserToolInfo' 1 | module ArgumentParserToolInfo { | `- error: redefinition of module 'ArgumentParserToolInfo' 2 | header "/pr/.build/x86_64-apple-macosx/debug/ArgumentParserToolInfo.build/ArgumentParserToolInfo-Swift.h" 3 | requires objc /pr/.build/debug/ArgumentParserToolInfo-tool.build/module.modulemap:1:8: note: previously defined here 1 | module ArgumentParserToolInfo { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/ArgumentParserToolInfo-tool.build/ArgumentParserToolInfo-Swift.h" 3 | requires objc /pr/.build/debug/ArgumentParser.build/module.modulemap:1:8: error: redefinition of module 'ArgumentParser' 1 | module ArgumentParser { | `- error: redefinition of module 'ArgumentParser' 2 | header "/pr/.build/x86_64-apple-macosx/debug/ArgumentParser.build/ArgumentParser-Swift.h" 3 | requires objc /pr/.build/debug/ArgumentParser-tool.build/module.modulemap:1:8: note: previously defined here 1 | module ArgumentParser { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/ArgumentParser-tool.build/ArgumentParser-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax509-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntax509' 1 | module SwiftSyntax509 { | `- error: redefinition of module 'SwiftSyntax509' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax509-tool.build/SwiftSyntax509-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax509.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntax509 { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax509.build/SwiftSyntax509-Swift.h" 3 | requires objc /pr/.build/debug/SwiftParserDiagnostics.build/module.modulemap:1:8: error: redefinition of module 'SwiftParserDiagnostics' 1 | module SwiftParserDiagnostics { | `- error: redefinition of module 'SwiftParserDiagnostics' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftParserDiagnostics.build/SwiftParserDiagnostics-Swift.h" 3 | requires objc /pr/.build/debug/SwiftParserDiagnostics-tool.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftParserDiagnostics { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftParserDiagnostics-tool.build/SwiftParserDiagnostics-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax510-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntax510' 1 | module SwiftSyntax510 { | `- error: redefinition of module 'SwiftSyntax510' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax510-tool.build/SwiftSyntax510-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax510.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntax510 { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax510.build/SwiftSyntax510-Swift.h" 3 | requires objc /pr/.build/debug/SwiftOperators-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftOperators' 1 | module SwiftOperators { | `- error: redefinition of module 'SwiftOperators' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftOperators-tool.build/SwiftOperators-Swift.h" 3 | requires objc /pr/.build/debug/SwiftOperators.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftOperators { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftOperators.build/SwiftOperators-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntax' 1 | module SwiftSyntax { | `- error: redefinition of module 'SwiftSyntax' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax-tool.build/SwiftSyntax-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntax { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax.build/SwiftSyntax-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntaxBuilder-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntaxBuilder' 1 | module SwiftSyntaxBuilder { | `- error: redefinition of module 'SwiftSyntaxBuilder' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntaxBuilder-tool.build/SwiftSyntaxBuilder-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntaxBuilder.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntaxBuilder { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntaxBuilder.build/SwiftSyntaxBuilder-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax600-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntax600' 1 | module SwiftSyntax600 { | `- error: redefinition of module 'SwiftSyntax600' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax600-tool.build/SwiftSyntax600-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntax600.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntax600 { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntax600.build/SwiftSyntax600-Swift.h" 3 | requires objc /pr/.build/debug/SwiftCompilerPlugin-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftCompilerPlugin' 1 | module SwiftCompilerPlugin { | `- error: redefinition of module 'SwiftCompilerPlugin' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftCompilerPlugin-tool.build/SwiftCompilerPlugin-Swift.h" 3 | requires objc /pr/.build/debug/SwiftCompilerPlugin.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftCompilerPlugin { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftCompilerPlugin.build/SwiftCompilerPlugin-Swift.h" 3 | requires objc /pr/.build/debug/SwiftDiagnostics.build/module.modulemap:1:8: error: redefinition of module 'SwiftDiagnostics' 1 | module SwiftDiagnostics { | `- error: redefinition of module 'SwiftDiagnostics' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftDiagnostics.build/SwiftDiagnostics-Swift.h" 3 | requires objc /pr/.build/debug/SwiftDiagnostics-tool.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftDiagnostics { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftDiagnostics-tool.build/SwiftDiagnostics-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntaxMacroExpansion-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftSyntaxMacroExpansion' 1 | module SwiftSyntaxMacroExpansion { | `- error: redefinition of module 'SwiftSyntaxMacroExpansion' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntaxMacroExpansion-tool.build/SwiftSyntaxMacroExpansion-Swift.h" 3 | requires objc /pr/.build/debug/SwiftSyntaxMacroExpansion.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftSyntaxMacroExpansion { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftSyntaxMacroExpansion.build/SwiftSyntaxMacroExpansion-Swift.h" 3 | requires objc /pr/.build/debug/SwiftFormat-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftFormat' 1 | module SwiftFormat { | `- error: redefinition of module 'SwiftFormat' 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftFormat-tool.build/SwiftFormat-Swift.h" 3 | requires objc /pr/.build/debug/SwiftFormat.build/module.modulemap:1:8: note: previously defined here 1 | module SwiftFormat { | `- note: previously defined here 2 | header "/pr/.build/x86_64-apple-macosx/debug/SwiftFormat.build/SwiftFormat-Swift.h" 3 | requires objc /pr/.build/debug/Danger.build/module.modulemap:2:12: error: header '/pr/.build/x86_64-apple-macosx/debug/Danger.build/Danger-Swift.h' not found 1 | module Danger { 2 | header "/pr/.build/x86_64-apple-macosx/debug/Danger.build/Danger-Swift.h" | `- error: header '/pr/.build/x86_64-apple-macosx/debug/Danger.build/Danger-Swift.h' not found 3 | requires objc 4 | } /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/_tmp_dangerfile.swift:4:8: error: could not build Objective-C module 'Danger' 2 | 3 | import Foundation 4 | import Danger | `- error: could not build Objective-C module 'Danger' 5 | import DangerShellExecutor 6 | ERROR: Dangerfile eval failed at Dangerfile.swift ```
DangerFile ```swift import Foundation import Danger import DangerShellExecutor let path = ShellExecutor().execute("pwd", arguments: [], environmentVariables: [:], outputFile: nil) SwiftLint.lint(.all(directory: path + "/Project/Path"), inline: true, swiftlintPath: .bin(path + "/Project/Pods/SwiftLint/swiftlint")) let misplacedLines = ShellExecutor().execute("grep --include=\\*.{storyboard,xib} -rnw . -e \"misplaced=\\\"YES\\\"\"", arguments: [], environmentVariables: [:], outputFile: nil).split(separator: "\n").map { String($0) } let regEx = try? NSRegularExpression(pattern: "([^\\:]*)\\:(\\d+)\\:.*", options: [.anchorsMatchLines, .dotMatchesLineSeparators]) for misplacedLine in misplacedLines { let range = NSRange(misplacedLine.startIndex..., in: misplacedLine) guard let checkingResult = regEx?.firstMatch(in: misplacedLine, options: [], range: range) else { continue } let rngFile: NSRange = checkingResult.range(at: 1) let rngPos: NSRange = checkingResult.range(at: 2) guard let subRangeFile = Range(rngFile, in: misplacedLine), let subRangePos = Range(rngPos, in: misplacedLine), let pos = Int(String(misplacedLine[subRangePos])) else { continue } let file = String(misplacedLine[subRangeFile]) warn(message: "storyboard ambiguity", file: file, line: pos) ```
Package.swift ```swift // swift-tools-version:5.9 import PackageDescription let package = Package( name: "Eigen", products: [ .library(name: "DangerDepsLinter", type: .dynamic, targets: ["DangerDependencies"]), // dev ], dependencies: [ .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.54.0"), .package(url: "https://github.com/danger/swift.git", from: "1.0.0"), .package(url: "https://github.com/Realm/SwiftLint", from: "0.56.0") ], targets: [ .target(name: "DangerDependencies") ] ) ```
f-meloni commented 1 month ago

Can you please post the verbose logs obtained by adding --verbose in the command?

Sega-Zero commented 1 month ago

Sure! Will provide you verbose logs a bit later

f-meloni commented 1 month ago

@Sega-Zero looking at your Package.swift it seems you have

.package(url: "https://github.com/danger/swift.git", from: "1.0.0"),

I think this would not get the latest version 3.20.1. Please let me know if that helps!

oronbz commented 1 month ago

Still not working with brew in 3.20.1 @f-meloni

Warning: swiftlint 0.57.0 is already installed and up-to-date.
To reinstall 0.57.0, run:
  brew reinstall swiftlint
+ brew install danger-swift
danger-swift 3.18.1 is already installed but outdated (so it will be upgraded).
==> Fetching danger/tap/danger-swift
==> Downloading https://github.com/danger/danger-swift/archive/3.20.1.tar.gz
==> Downloading from https://codeload.github.com/danger/swift/tar.gz/refs/tags/3.20.1
==> Upgrading danger/tap/danger-swift
  3.18.1 -> 3.20.1 
==> make install PREFIX=/opt/homebrew/Cellar/danger-swift/3.20.1
🍺  /opt/homebrew/Cellar/danger-swift/3.20.1: 8 files, 3.9MB, built in 47 seconds
Warning: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK is set: not checking for outdated
dependents or dependents with broken linkage!
+ echo '⚠️ DANGER ! :)'
⚠️ DANGER ! :)
+ danger-swift ci
/var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/A2174C8B-B237-46B1-9154-A4BF42A901DA/_tmp_dangerfile.swift:1:8: error: no such module 'Danger'
 1 [REDACTED] import Danger
   [REDACTED]        `- error: no such module 'Danger'
 2 [REDACTED] import Foundation
 3 [REDACTED] 
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/A2174C8B-B237-46B1-9154-A4BF42A901DA/danger-response.json
Failing the build, there is 1 fail.
Feedback: https://github.com/gtforge/gtforge-iphone/pull/3919#issuecomment-2411101472
ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/A2174C8B-B237-46B1-9154-A4BF42A901DA/danger-response.json
f-meloni commented 1 month ago

@oronbz would you have time to manually install danger swift (clone the repo, run make install)? Just to understand if the issue is on how we are installing it with brew, because on ci it was working.

oronbz commented 1 month ago

@oronbz would you have time to manually install danger swift (clone the repo, run make install)? Just to understand if the issue is on how we are installing it with brew, because on ci it was working.

Trying...

oronbz commented 1 month ago

Same issue @f-meloni:

23 [REDACTED]     if let spmDanger = SPMDanger() {
[23/30] Write Objects.LinkFileList
[24/30] Linking danger-swift
[26/30] Compiling OctoKit Configuration.swift
[27/31] Compiling Danger BitBucketCloud.swift
[27/31] Write Objects.LinkFileList
[29/33] Compiling Danger_Swift Fake.swift
[29/33] Write Objects.LinkFileList
[30/33] Linking libDanger.dylib
[31/33] Linking libDangerDeps.dylib
[33/33] Compiling DangerFixtures CustomGitHubDSL.swift
Build complete! (48.98s)
swift-driver version: 1.115 + cd ..
+ echo '⚠️ DANGER ! :)'
⚠️ DANGER ! :)
+ danger-swift ci
/var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/373C7EB1-762B-4E64-9B08-F2A3C9EF15D7/_tmp_dangerfile.swift:1:8: error: no such module 'Danger'
 1 [REDACTED] import Danger
   [REDACTED]        `- error: no such module 'Danger'
 2 [REDACTED] import Foundation
 3 [REDACTED] 
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/373C7EB1-762B-4E64-9B08-F2A3C9EF15D7/danger-response.json
Failing the build, there is 1 fail.
Feedback: https://github.com/gtforge/gtforge-iphone/pull/3919#issuecomment-2411101472
ERROR: Could not get the results JSON file at /var/folders/b8/9zt_tx3s1y37nzh_cs991xyc0000gn/T/danger/373C7EB1-762B-4E64-9B08-F2A3C9EF15D7/danger-response.json
f-meloni commented 1 month ago

@oronbz I'm not able to reproduce it on Mac, are you on Linux?

Screenshot 2024-10-15 alle 11 18 04
oronbz commented 1 month ago

@oronbz I'm not able to reproduce it on Mac, are you on Linux?

It's a Bitrise (CI) mac

edit: It comes preinstalled with Danger 3.18.1, are there any steps to fully uninstall it other than brew uninstall danger-swift?

f-meloni commented 1 month ago

@oronbz I'm not able to reproduce it on Mac, are you on Linux?

It's a Bitrise (CI) mac

edit: It comes preinstalled with Danger 3.18.1, are there any steps to fully uninstall it other than brew uninstall danger-swift?

I would probably run

rm -rf /usr/local/lib/danger                  
rm -rf /usr/local/bin/danger-swift

(assuming danger is saved there) and then make install from the cloned repo, to minimise the possibilities of an issue

oronbz commented 1 month ago

@f-meloni first of all, it doesn't work locally for me macOS 15.0 Xcode 16:

➜  gtforge-iphone git:(infra/return_danger) danger-swift --version
3.20.1
➜  gtforge-iphone git:(infra/return_danger) danger-swift pr https://github.com/gtforge/gtforge-iphone/pull/3919
Starting Danger PR on gtforge/gtforge-iphone#3919
/var/folders/5c/pr5fqvp10g3237xh2zvywh6r0000gq/T/danger/F0097C4F-C4A0-40DC-989E-DB7DCD1828A1/_tmp_dangerfile.swift:1:8: error: no such module 'Danger'
 1 | import Danger
   |        `- error: no such module 'Danger'
 2 | import Foundation
 3 | 

ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/5c/pr5fqvp10g3237xh2zvywh6r0000gq/T/danger/F0097C4F-C4A0-40DC-989E-DB7DCD1828A1/danger-response.json

Danger: ⅹ Failing the build, there is 1 fail.
## Failures
`danger-swift` failed.
## Markdowns
### Log

<details>

/var/folders/5c/pr5fqvp10g3237xh2zvywh6r0000gq/T/danger/F0097C4F-C4A0-40DC-989E-DB7DCD1828A1/_tmp_dangerfile.swift:1:8: error: no such module 'Danger'
 1 | import Danger
   |        `- error: no such module 'Danger'
 2 | import Foundation
 3 | 
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/5c/pr5fqvp10g3237xh2zvywh6r0000gq/T/danger/F0097C4F-C4A0-40DC-989E-DB7DCD1828A1/danger-response.json

</details>

This is from a brew install, will try now with a local clone

oronbz commented 1 month ago

@f-meloni exactly the same with local clone and make install. attaching the Dangerfile.swift just in case I missed something:

import Danger
import Foundation

let danger = Danger()

// Make sure no Quick focused tests were accidentally left in
verifyNoQuickFocusedTests()

// When run locally or out of a PR scenario, `github` will be nil
if let pullRequest = danger.github?.pullRequest {
    if pullRequest.title.starts(with: "[WIP]") {
        warn("PR is classified as Work in Progress")
    }

    detectJIRATicket(in: pullRequest.title)
}

// Warn if GTRide.h has been changed
if danger.git.modifiedFiles.contains("Gett/Model/GTRide.h") {
    warn("`GTRide.h` has been modified. " +
         "If you've added a property, make sure you've also added it in: " +
         "`GTWorkflow.m` `updateRide:(GTRide*)ride`")
}

// Lint Rider
let riderViloations = SwiftLint.lint(.all(directory: "Rider"), inline: true, configFile: "Rider/.swiftlint.yml")

// Lint project
let gtViloations = SwiftLint.lint(.all(directory: nil), inline: true)

let violationCount = riderViloations.count + gtViloations.count

if violationCount > 0 {
    fail("There are \(violationCount) violations, please fix those before merging")
}

// MARK: - Private Helpers

/// Check if a JIRA ticket is mentioned in the PR title
private func detectJIRATicket(in title: String) {
    guard title.starts(with: "[GETT-"),
          let jiraTicket = title.components(separatedBy: "]").first?.dropFirst() else {
        return
    }

    message("JIRA Ticket: [\(jiraTicket)](https://jira.gtforge.com/browse/\(jiraTicket))")
}

/// Make sure we didn't forget any focused Quick tests on
private func verifyNoQuickFocusedTests() {
    func testFiles(containing searchTerm: String) -> [String] {
        let result = danger.utils.exec("grep -rlI \"\(searchTerm)\" GettTests/")

        return result
            .components(separatedBy: "\n")
            .compactMap { piece -> String? in
                guard let spec = piece.components(separatedBy: "/")
                                      .last?
                                      .trimmingCharacters(in: .whitespacesAndNewlines),
                      !spec.isEmpty else { return nil }

                return spec
            }
    }

    let fitFiles = testFiles(containing: "fit(")
    let fdescribeFiles = testFiles(containing: "fdescribe(")
    let fcontextFiles = testFiles(containing: "fcontext(")

    if !fitFiles.isEmpty {
        fail("The following specs have fit() focused tests: \(fitFiles.joined(separator: ", "))")
    }

    if !fdescribeFiles.isEmpty {
        fail("The following specs have fdescribe() focused tests: \(fdescribeFiles.joined(separator: ", "))")
    }

    if !fcontextFiles.isEmpty {
        fail("The following specs have fcontext() focused tests: \(fcontextFiles.joined(separator: ", "))")
    }
}
f-meloni commented 1 month ago

So, this is what confuses me at the moment: https://github.com/danger/swift/actions/runs/11328285003/job/31501199290

This is doing a make install, then creates a new folder with just a dangerfile and runs danger there, and that is passing. I can also make it work locally, but if I look at the libraries moved by make install, they don't seem the right ones. Let me investigate this further

f-meloni commented 1 month ago

@oronbz can you try to run make install from this branch please? fix_install_script

oronbz commented 1 month ago

@f-meloni worked! Woop woop

➜  gtforge-iphone git:(infra/return_danger) danger-swift pr https://github.com/gtforge/gtforge-iphone/pull/3919
Starting Danger PR on gtforge/gtforge-iphone#3919

Danger: ⅹ Failing the build, there is 1 fail.
## Failures
There are 1 violations, please fix those before merging
## Warnings
Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (`colon`)
f-meloni commented 1 month ago

Great! let me clean up, merge and release!

f-meloni commented 1 month ago

Can you please try the new version 3.20.2? Thank you! :)

oronbz commented 1 month ago

image 🥳

Thank you so much @f-meloni!

f-meloni commented 1 month ago

Fantastic! Closing the issue then :)

Sega-Zero commented 1 month ago

@f-meloni sorry 😭

```shell swift run danger-swift ci --verbose [0/1] Planning build Building for debugging... [0/11] Write sources [6/11] Write danger-swift-entitlement.plist [7/11] Write swift-version--58304C5D6DBC2206.txt [9/21] Compiling Version Version+Comparable.swift [10/21] Compiling Version Version.swift [11/21] Compiling Version Version+Codable.swift [12/21] Compiling Version Version+Range.swift [13/21] Emitting module Version [14/21] Compiling Version Version+Foundation.swift [15/21] Compiling DangerShellExecutor ShellExecutor.swift [16/21] Emitting module DangerShellExecutor [17/21] Emitting module Logger [18/21] Compiling Logger Logger.swift [19/48] Emitting module RunnerLib [20/48] Compiling RunnerLib DangerFileGenerator.swift [21/49] Compiling RunnerLib ImportsFinder.swift [22/49] Compiling RunnerLib NSRegularExpression+FilesImport.swift [23/49] Compiling RunnerLib Runtime.swift [24/49] Compiling RunnerLib String+Path.swift [25/49] Compiling RunnerLib HelpMessagePresenter.swift [26/49] Compiling RunnerLib DangerCommand.swift [27/49] Compiling RunnerLib DangerJSVersionFinder.swift [28/49] Compiling RunnerLib GetDangerJSPath.swift [29/49] Compiling RunnerLib DangerSwiftOption.swift [30/49] Compiling RunnerLib DangerfileArgumentsPath.swift [31/49] Compiling RunnerLib CliArgs.swift [32/49] Compiling RunnerLib CliArgsParser.swift [33/49] Compiling RunnerLib SPMDanger.swift [34/49] Compiling DangerDependenciesResolver URL+RemoteRepository.swift [35/49] Compiling DangerDependenciesResolver PackageGenerator.swift [36/49] Compiling DangerDependenciesResolver PackageDataProvider.swift [37/49] Compiling DangerDependenciesResolver PackageListMaker.swift [38/49] Compiling DangerDependenciesResolver PackageManager.swift [39/49] Compiling DangerDependenciesResolver Data+Encoding.swift [40/49] Compiling DangerDependenciesResolver FileReader.swift [41/49] Compiling DangerDependenciesResolver Script.swift [42/49] Compiling DangerDependenciesResolver FileCreator.swift [43/49] Compiling DangerDependenciesResolver Package.swift [44/49] Emitting module DangerDependenciesResolver [45/49] Compiling DangerDependenciesResolver InlineDependenciesFinder.swift [46/49] Compiling RunnerLib VersionChecker.swift [47/55] Compiling Runner RunDangerJS.swift [48/55] Compiling Runner Runner.swift [49/55] Compiling Runner MarathonScriptManager.swift [50/55] Compiling Runner Edit.swift [51/55] Compiling Runner main.swift [52/55] Emitting module Runner [52/55] Write Objects.LinkFileList [53/55] Linking danger-swift [54/55] Applying danger-swift Build of product 'danger-swift' complete! (8.20s) (node:76886) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger/5196ACCE-432E-4569-8C47-B23A61C80303/_tmp_dangerfile.swift:4:8: error: no such module 'Danger' 2 | 3 | import Foundation 4 | import Danger | `- error: no such module 'Danger' 5 | import DangerShellExecutor 6 | Launching Danger Swift runner (v3.20.2) Got URL for JSON: /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger-dsl-391a3e8c.json Created a temporary file for the Dangerfile DSL at: /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger-dsl-391a3e8c.json Running Dangerfile at: Dangerfile.swift Preparing to compile Running: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --driver-mode=swift -L /Users/admin/.jenkins/workspace/iOS/.build/debug -I /Users/admin/.jenkins/workspace/iOS/.build/debug/Modules -lDangerDepsLinter /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger/5196ACCE-432E-4569-8C47-B23A61C80303/_tmp_dangerfile.swift runner /usr/local/lib/node_modules/danger/distribution/commands/danger-ci.js --process .build/debug/danger-swift --passURLForDSL --verbose /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger-dsl-391a3e8c.json /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger/5196ACCE-432E-4569-8C47-B23A61C80303/danger-response.json Completed evaluation ERROR: Dangerfile eval failed at Dangerfile.swift ERROR: Could not get the results JSON file at /var/folders/qp/bcc51wv112750l2rsgqv21nw0000gn/T/danger/5196ACCE-432E-4569-8C47-B23A61C80303/danger-response.json Failing the build, there is 1 fail. Feedback: Danger: ⅹ Failing the build, there is 1 fail. ## Failures `danger-swift` failed. ## Markdowns ### Log ```

patched a version in Package.swift to 3.0.0 as you mentioned

f-meloni commented 1 month ago

@Sega-Zero I'm looking at your package.swift, I think DangerDepedencies needs to depend on Danger, for it to be linked

.target(name: "DangerDependencies", dependencies: ["Danger"])

Sega-Zero commented 1 month ago

It will not compile then

```shell % swift build --cache-path ~/data/DangerCachedSources Updating https://github.com/shibapm/Logger Updating https://github.com/JohnSundell/Marathon Updating https://github.com/danger/swift.git Updating https://github.com/JohnSundell/ShellOut.git Updating https://github.com/JohnSundell/Files.git Updating https://github.com/JohnSundell/Require.git Updating https://github.com/nerdishbynature/RequestKit.git Updating https://github.com/JohnSundell/Releases.git Updating https://github.com/apple/swift-argument-parser.git Updated https://github.com/shibapm/Logger (0.51s) Updating https://github.com/JohnSundell/CollectionConcurrencyKit.git Updated https://github.com/JohnSundell/Files.git (0.82s) Updated https://github.com/JohnSundell/ShellOut.git (0.82s) Updated https://github.com/JohnSundell/Marathon (0.82s) Updated https://github.com/apple/swift-argument-parser.git (0.82s) Updated https://github.com/JohnSundell/Require.git (0.82s) Updated https://github.com/nerdishbynature/RequestKit.git (0.82s) Updated https://github.com/JohnSundell/Releases.git (0.82s) Updated https://github.com/danger/swift.git (0.82s) Updating https://github.com/nerdishbynature/octokit.swift Updating https://github.com/jpsim/SourceKitten.git Updating https://github.com/nicklockwood/SwiftFormat Updating https://github.com/Realm/SwiftLint Updating https://github.com/drmohundro/SWXMLHash.git Updating https://github.com/jpsim/Yams.git Updating https://github.com/krzyzanowskim/CryptoSwift.git Updating https://github.com/scottrhoyt/SwiftyTextTable.git Updated https://github.com/JohnSundell/CollectionConcurrencyKit.git (0.43s) Updating https://github.com/swiftlang/swift-syntax.git Updated https://github.com/swiftlang/swift-syntax.git (1.39s) Updated https://github.com/nerdishbynature/octokit.swift (2.64s) Updated https://github.com/jpsim/Yams.git (2.64s) Updated https://github.com/jpsim/SourceKitten.git (2.64s) Updated https://github.com/krzyzanowskim/CryptoSwift.git (2.64s) Updated https://github.com/drmohundro/SWXMLHash.git (2.64s) Updated https://github.com/nicklockwood/SwiftFormat (2.64s) Updated https://github.com/Realm/SwiftLint (2.64s) Updated https://github.com/scottrhoyt/SwiftyTextTable.git (2.64s) Computing version for https://github.com/Realm/SwiftLint.git Computed https://github.com/Realm/SwiftLint.git at 0.57.0 (0.49s) Computing version for https://github.com/nicklockwood/SwiftFormat Computed https://github.com/nicklockwood/SwiftFormat at 0.54.5 (0.63s) Computing version for https://github.com/krzyzanowskim/CryptoSwift.git Computed https://github.com/krzyzanowskim/CryptoSwift.git at 1.8.3 (0.62s) Computing version for https://github.com/JohnSundell/CollectionConcurrencyKit.git Computed https://github.com/JohnSundell/CollectionConcurrencyKit.git at 0.2.0 (0.61s) Computing version for https://github.com/scottrhoyt/SwiftyTextTable.git Computed https://github.com/scottrhoyt/SwiftyTextTable.git at 0.9.0 (0.61s) Computing version for https://github.com/jpsim/Yams.git Computed https://github.com/jpsim/Yams.git at 5.1.3 (0.61s) Computing version for https://github.com/jpsim/SourceKitten.git Computed https://github.com/jpsim/SourceKitten.git at 0.35.0 (0.62s) Computing version for https://github.com/apple/swift-argument-parser.git Computed https://github.com/apple/swift-argument-parser.git at 1.5.0 (0.47s) Computing version for https://github.com/drmohundro/SWXMLHash.git Computed https://github.com/drmohundro/SWXMLHash.git at 7.0.2 (0.62s) Computing version for https://github.com/danger/swift.git Computed https://github.com/danger/swift.git at 3.20.2 (0.59s) Fetching https://github.com/mxcl/Version from cache Fetched https://github.com/mxcl/Version from cache (0.52s) Computing version for https://github.com/nerdishbynature/octokit.swift Computed https://github.com/nerdishbynature/octokit.swift at 0.13.0 (0.61s) Computing version for https://github.com/shibapm/Logger Computed https://github.com/shibapm/Logger at 0.2.3 (0.61s) Computing version for https://github.com/nerdishbynature/RequestKit.git Computed https://github.com/nerdishbynature/RequestKit.git at 3.3.0 (0.61s) Computing version for https://github.com/mxcl/Version Computed https://github.com/mxcl/Version at 2.1.0 (0.72s) Computing version for https://github.com/swiftlang/swift-syntax.git Computed https://github.com/swiftlang/swift-syntax.git at 600.0.0-prerelease-2024-08-14 (0.74s) Removing https://github.com/JohnSundell/ShellOut.git Removing https://github.com/JohnSundell/Marathon Removing https://github.com/JohnSundell/Files.git Removing https://github.com/JohnSundell/Require.git Removing https://github.com/JohnSundell/Releases.git Working copy of https://github.com/danger/swift.git resolved at 3.20.2 Creating working copy for https://github.com/mxcl/Version Working copy of https://github.com/mxcl/Version resolved at 2.1.0 error: 'experiment': product 'Danger' required by package 'experiment' target 'DangerDependencies' not found. Did you mean '.product(name: "Danger", package: "swift")'? error: ExitCode(rawValue: 1) [0/1] Planning build% ```
Sega-Zero commented 1 month ago

finally got it working after changing the Package.swift to

```swift // swift-tools-version:5.9 import PackageDescription let package = Package( name: "Eigen", products: [ .library(name: "DangerDepsLinter", type: .dynamic, targets: ["DangerDependencies"]), // dev ], dependencies: [ .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.54.0"), .package(url: "https://github.com/danger/swift.git", from: "3.0.0"), .package(url: "https://github.com/Realm/SwiftLint.git", from: "0.56.0") ], targets: [ .target(name: "DangerDependencies", dependencies: [ .product(name: "Danger", package: "swift") ]) ] ) ```
Arafo commented 1 month ago

@f-meloni I'm still getting some errors when using a vanilla danger setup with Swift 6 / Xcode 16

This is my Package.swift file

// swift-tools-version:6.0
import PackageDescription

let package = Package(
    name: "Eigen",
    platforms: [.macOS(.v13)],
    products: [
        .library(
            name: "DangerDeps",
            type: .dynamic,
            targets: ["DangerDependencies"]
        )
    ],
    dependencies: [
        .package(
            url: "https://github.com/danger/swift.git",
            from: "3.20.2"
        )
    ],
    targets: [
        .target(
            name: "DangerDependencies",
            dependencies: [
                .product(
                    name: "Danger",
                    package: "swift"
                ),
            ]
        )
    ]
)

And this is the error I'm getting after running these commands:

swift build -c release
cp .build/release/libDangerDeps.dylib .build/release/libDanger.dylib
DEBUG="*" swift run -c release danger-swift ci

Error:

/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftFormat'
1 | module SwiftFormat {
  |        `- error: redefinition of module 'SwiftFormat'
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat-tool.build/SwiftFormat-Swift.h"
3 |     requires objc

/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat.build/module.modulemap:1:8: note: previously defined here
1 | module SwiftFormat {
  |        `- note: previously defined here
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat.build/SwiftFormat-Swift.h"
3 |     requires objc

/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftFormat'
1 | module SwiftFormat {
  |        `- error: redefinition of module 'SwiftFormat'
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat-tool.build/SwiftFormat-Swift.h"
3 |     requires objc

/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat.build/module.modulemap:1:8: note: previously defined here
1 | module SwiftFormat {
  |        `- note: previously defined here
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/release/SwiftFormat.build/SwiftFormat-Swift.h"
3 |     requires objc

/var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger/D60A5DF8-BB5B-4655-BA7A-345479D39771/_tmp_dangerfile.swift:1:8: error: could not build Objective-C module 'Danger'
1 | import Danger
  |        `- error: could not build Objective-C module 'Danger'
2 |
3 | let danger = Danger()

Any idea what's happening here?

f-meloni commented 1 month ago

Are you sure you are using the latest danger swift version?

Arafo commented 1 month ago

According to the resolved file yes, not sure what's going on

{
  "originHash" : "36abd041412583f5cd210268e843be9b5b8e8277411c70fb9c71ae0fdda24bdf",
  "pins" : [
    {
      "identity" : "logger",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/shibapm/Logger",
      "state" : {
        "revision" : "53c3ecca5abe8cf46697e33901ee774236d94cce",
        "version" : "0.2.3"
      }
    },
    {
      "identity" : "octokit.swift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/nerdishbynature/octokit.swift",
      "state" : {
        "revision" : "44192458beb89180c3a3a1245d904aacac8be0ae",
        "version" : "0.13.0"
      }
    },
    {
      "identity" : "requestkit",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/nerdishbynature/RequestKit.git",
      "state" : {
        "revision" : "e4d905fed938807e36d87f28375f88b7c1c26840",
        "version" : "3.3.0"
      }
    },
    {
      "identity" : "swift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/danger/swift.git",
      "state" : {
        "revision" : "e43a19617fc905ef303b1af2f0449b99fc6ea0f2",
        "version" : "3.20.2"
      }
    },
    {
      "identity" : "swiftformat",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/nicklockwood/SwiftFormat",
      "state" : {
        "revision" : "86ed20990585f478c0daf309af645c2a528b59d8",
        "version" : "0.54.6"
      }
    },
    {
      "identity" : "version",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/mxcl/Version",
      "state" : {
        "revision" : "303a0f916772545e1e8667d3104f83be708a723c",
        "version" : "2.1.0"
      }
    }
  ],
  "version" : 3
}
f-meloni commented 1 month ago

I think you don't need those two commands

swift build -c release
cp .build/release/libDangerDeps.dylib .build/release/libDanger.dylib

Also can you please try Swift run without -c release? Just want to see what happens, thanks

Arafo commented 1 month ago

Getting this running swift run -c release danger-swift ci

Launching Danger Swift runner (v3.20.2)
Got URL for JSON: /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger-dsl-fabda10d.json
Created a temporary file for the Dangerfile DSL at: /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger-dsl-fabda10d.json
Running Dangerfile at: Dangerfile.swift
ERROR: Could not find a libDanger to link against at any of: [".build/debug", ".build/x86_64-unknown-linux/debug", ".build/release", "/usr/local/lib/danger", "/opt/homebrew/lib/danger"]
Or via Homebrew, or Marathon

Same without the -c release flag

And with the same commands as before but without the flag:

swift build
cp .build/debug/libDangerDeps.dylib .build/debug/libDanger.dylib
swift run danger-swift ci

I'm getting this error:

/Users/myuser/danger-test/.build/debug/SwiftFormat-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftFormat'
1 | module SwiftFormat {
  |        `- error: redefinition of module 'SwiftFormat'
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/debug/SwiftFormat-tool.build/SwiftFormat-Swift.h"
3 |     requires objc

/Users/myuser/danger-test/.build/debug/SwiftFormat.build/module.modulemap:1:8: note: previously defined here
1 | module SwiftFormat {
  |        `- note: previously defined here
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/debug/SwiftFormat.build/SwiftFormat-Swift.h"
3 |     requires objc

/Users/myuser/danger-test/.build/debug/SwiftFormat-tool.build/module.modulemap:1:8: error: redefinition of module 'SwiftFormat'
1 | module SwiftFormat {
  |        `- error: redefinition of module 'SwiftFormat'
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/debug/SwiftFormat-tool.build/SwiftFormat-Swift.h"
3 |     requires objc

/Users/myuser/danger-test/.build/debug/SwiftFormat.build/module.modulemap:1:8: note: previously defined here
1 | module SwiftFormat {
  |        `- note: previously defined here
2 |     header "/Users/myuser/danger-test/.build/arm64-apple-macosx/debug/SwiftFormat.build/SwiftFormat-Swift.h"
3 |     requires objc

/var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger/543F39B0-BE17-40A0-B565-2B4E500A0D90/_tmp_dangerfile.swift:1:8: error: could not build Objective-C module 'Danger'
1 | import Danger
  |        `- error: could not build Objective-C module 'Danger'
2 |
3 | let danger = Danger()

Launching Danger Swift runner (v3.20.2)
Got URL for JSON: /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger-dsl-4551d159.json
Created a temporary file for the Dangerfile DSL at: /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger-dsl-4551d159.json
Running Dangerfile at: Dangerfile.swift
Preparing to compile
Running: /Applications/Xcode-16.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --driver-mode=swift -L /Users/myuser/danger-test/.build/debug -I /Users/myuser/danger-test/.build/debug -lDanger /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger/543F39B0-BE17-40A0-B565-2B4E500A0D90/_tmp_dangerfile.swift runner /snapshot/danger-js/distribution/commands/danger-ci.js --process .build/debug/danger-swift --passURLForDSL /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger-dsl-4551d159.json /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger/543F39B0-BE17-40A0-B565-2B4E500A0D90/danger-response.json
Completed evaluation
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/xy/fyskh3557hj_zjyrnnjmhg9nqsvv6_/T/danger/543F39B0-BE17-40A0-B565-2B4E500A0D90/danger-response.json

Swift version:

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0
f-meloni commented 1 month ago

Try to remove the new line in

library(name: "DangerDeps",

(Just write it like this, to match the regex)

Then do not do the other steps just run danger-swift directly

Arafo commented 1 month ago

That worked, thank you!

Btw, -c flag is ignored when running swift run, is that expected?

f-meloni commented 1 month ago

Yes

Arafo commented 1 month ago

Out of context but another observation is that --package-path flag does not work either, you have to run danger at the same dir level you're located