danger / swift

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

Proposal: Revised plugin system #139

Open orta opened 5 years ago

orta commented 5 years ago

So, the current idea of plugins is great until we got it working out in prod for a while.

Roughly how it is now:

This is fine, but it's actually not. It takes forever to clone and build all of those dependencies and causes https://github.com/danger/swift/issues/97

So, instead I have two proposals:

yhkaplan commented 5 years ago

Personally, I use minor plugins that I create myself sometimes, so having some kind of plugin system is preferable. One aspect of this is that many CI services are smart about caching bundled gems, npm packages, etc so installing them is very fast. Unfortunately, SPM is not big enough for CI services to optimize for yet, and probably won’t be soon.

orta commented 5 years ago

Yeah, good point on the build caching ( I just added it to this repo )

Looks like my idea of moving your dependencies to be owned by the project won't work, because SwiftPM uses urls for resolving dependencies, it can't know that github.com/danger/swift actually represents the current project from the looks of things, will have to investigate.

f-meloni commented 5 years ago

I personally think that put all in danger has two downsides:

Today there is not a big number of plugins, I agree, but some potential plugins could be

Then i suppose that would be more future proof allow people to integrate the plugin they want.

orta commented 5 years ago

I don't mean to deprecate plugins completely, just to make them normal packages though SwiftPM instead of as special magic dependencies added at runtime.

Then to also move the most common ones into Danger so that they are available by default, without needing the plugin system.

I now also realized that it'd just be in danger-swift where the above would be an issue, so that still makes it feasible.

ashfurrow commented 5 years ago

Yeah, I think Danger Swift should follow the example of Cocoa architecture: common things should be easy, and uncommon things should be possible. Orta's clarification in the above comment fits that paradigm really well, and I think would be a good step forward for Danger Swift.

orta commented 5 years ago

OK: so, what I think could work.

// swift-tools-version:4.2

import PackageDescription

let package = Package(
    name: "Eigen",
    products: [
        .library(name: "Danger", type: .dynamic, targets: ["Danger"]),
    ],
    dependencies: [
      .package(url: "https://github.com/danger/swift.git", from: "1.0.0"),
      .package(url: "https://github.com/orta/danger-plugin-swiftformat.git", from: "1.0.0")
    ],
    targets: [
        .target(name: "Danger", dependencies: ["Danger", "DangerSwiftFormat"], path: "Artsy", sources: ["Stringify.swift"]),
    ]
)

Advantages:

Downsides:

freak4pc commented 5 years ago

I really like the idea of moving the plugins as SPM package - it seems like a smart move to me and will also allow CI providers to provide better caching to these artifacts at a later phase

f-meloni commented 5 years ago

I personally like the idea of using SPM, the file in the danger target could be the Dangerfile.swift, and we could search for Danger in Sources/Danger/Dangerfile.swift. The thing would be that if you are shipping your framework with SPM who adds your framework downloads Danger as well, because is an explicit dependency of your target and you can not comment it as dev dependency. But maybe add // dev to the danger target as well would make Rocket hide the target as well and maybe it will work.