Add the correct import to your Dangerfile.swift:
```swift
import DangerXCodeSummary
let summary = XCodeSummary(filePath: “result.json”)
- Create a folder called `DangerDependencies` on `Sources` with an empty file inside like [Fake.swift](//dnrops/danger-swift-xcodesummary/tree/master/Sources/DangerDependencies/Fake.swift)
- To run `Danger` use `swift run danger-swift command`
- (Recommended) If you are using SPM to distribute your framework, use [Rocket](https://github.com/f-meloni/Rocket), or similar to comment out all the dev depencencies from your `Package.swift`.
This prevents the dev dependencies to be downloaded and compiled with your framework.
#### Marathon
- Add this to your `Dangerfile.swift`
```swift
import DangerXCodeSummary // package: https://github.com/f-meloni/danger-swift-xcodesummary.git
let summary = XCodeSummary(filePath: "result.json")
(Recommended) Cache the ~/.danger-swift folder
Run with SPM
DangerXCodeSummary can be used with SPM (this repo uses it on the Linux CI), but at the moment, if you use SPM, falining tests inline messages are not generated.
To generate the report run:
swift test | XCPRETTY_JSON_FILE_OUTPUT=result.json xcpretty -f `xcpretty-json-formatter`
Send report to Danger
summary.report()
Warning and Errors count
if summary.errorsCount > maxErrorCount {
fail("There are more than \(maxErrorCount) errors"
}
if summary.warningsCount > maxWarningsCount {
fail("There are more than \(maxWarningsCount) warnings"
}
Filtering results
Don’t show warnings:
let summary = XCodeSummary(json: JSONFile.jsonObject(fromString: reportTestJSON), dsl: dsl, resultsFilter: { result in
return result.category != .warning
})
summary.report()
Filter out any error or warning for a specific path:
let summary = XCodeSummary(json: JSONFile.jsonObject(fromString: warningsJSON), dsl: dsl, resultsFilter: { result in
guard let file = result.file else { return true }
return !file.contains("Sources/DangerXCodeSummary/")
})
summary.report()
DangerXCodeSummary
A Danger-Swift plugin that adds build errors, warnings and unit tests results generated from xcodebuild to your Danger report
Inspired by danger-xcode_summary
Getting Started
Install DangerSwiftCoverage
Swift Package Manager (More performant)
You can use a “full SPM” solution to install both
danger-swift
andDangerXCodeSummary
.Package.swift
:Dangerfile.swift
: ```swift import DangerXCodeSummarylet summary = XCodeSummary(filePath: “result.json”)
~/.danger-swift
folderRun with SPM
DangerXCodeSummary can be used with SPM (this repo uses it on the Linux CI), but at the moment, if you use SPM, falining tests inline messages are not generated. To generate the report run:
Send report to Danger
Warning and Errors count
Filtering results
Don’t show warnings:
Filter out any error or warning for a specific path: