Name: danger-swift
Owner: Danger
Description: ?? Stop saying "you forgot to ?" in code review
Created: 2017-08-24 21:30:03.0
Updated: 2018-05-22 11:29:27.0
Pushed: 2018-05-22 11:29:26.0
Homepage: http://danger.systems/js/swift.html
Size: 163
Language: Swift
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Write your Dangerfiles in Swift 4+.
Latest version requires Swift 4.1.
If you are using Swift 4.0, Use v0.3.5 .
You can make a Dangerfile that looks through PR metadata, it's fully typed.
rt Danger
allSourceFiles = danger.git.modifiedFiles + danger.git.createdFiles
changelogChanged = allSourceFiles.contains("CHANGELOG.md")
sourceChanges = allSourceFiles.first(where: { $0.hasPrefix("Sources") })
changelogChanged && sourceChanges != nil {
rn("No CHANGELOG entry added.")
ou can use these functions to send feedback:
age("Highlight something in the table")
("Something pretty bad, but not important enough to fail the build")
("Something that must be changed")
down("Free-form markdown that goes under the table, so you can do whatever.")
In your CI:
tup
install -g danger # Get DangerJS
install danger/tap/danger-swift # Install danger-swift locally
ript
er process danger-swift # Run Danger
install danger/tap/danger-swift
clone https://github.com/danger/danger-swift.git
anger-swift
install
Class SwiftObject is implemented in both [x], [y]
runtime error, probably thisSetting up:
brew install danger/tap/danger-swift
.danger-swift edit
.This will make a Dangerfile.swift
for you., then pop up a temporary Xcode project set up for editing a Swift Dangerfile.
Infrastructure exists to support plugins, which can help you avoid repeating the same Danger rules across separate repos. By
suffixing package: [url]
to an import, you can directly import Swift PM package as a dependency(through Marathon), which is basically how plugins work.
For example, a plugin could be used by the following.
angerfile.swift
rt DangerPlugin // package: https://github.com/username/DangerPlugin.git
erPlugin.doYourThing()
And could be implemented with the following.
angerPlugin.swift
rt Danger
ic struct DangerPlugin {
static let danger = Danger()
public static func doYourThing() {
// Code goes here
}
This project takes its ideas from how the Swift Package Manager handles package manifests. You can get the long story here, but the TLDR is that there is a runner project which compiles and executes a runtime lib which exports its data out into JSON when the libs process is over.
So this project will export a lib libDanger
and a CLI tool danger-swift
which is the runner. danger-swift
handles turning the Danger DSL JSON message from DangerJS and passing that into the eval'd Dangerfile.swift
. When that process is finished it's expected that the Swift Danger
object would post the results into a place where they can easily be passed back to DangerJS.
You need to be using Xcode 9.
clone https://github.com/danger/danger-swift.git
anger-swift
t build
t package generate-xcodeproj
Danger.xcodeproj
Then I tend to run it by eval the Dangerfile with:
t build && swiftc --driver-mode=swift -L .build/debug -I .build/debug -lDanger Dangerfile.swift fixtures/eidolon_609.json fixtures/response_data.json
If you want to emulate how DangerJS's process
will work entirely, then use:
t build && cat fixtures/eidolon_609.json | ./.build/debug/danger-swift
To add to or regenerate Equatable extensions for model tests, please:
$ brew install sourcery
For more about Sourcery, see: https://github.com/krzysztofzablocki/SourceryNewModel: AutoEquatable {}
$ sourcery --config .sourcery.yml
To change Sourcery settings, edit the yml file and/or the template in Sources/TemplatesMakefile
and Sources/Danger/Danger.swift
with the versionmake get_sha
to grab the SHAI, orta, only plan on bootstrapping this project, as I won't be using this in production. I'm happy to help support others who want to own this idea and really make it shine though! So if you're interested in helping out, make a few PRs and I'll give you org access.