danger / swift

⚠️ Stop saying "you forgot to …" in code review

Home Page:https://danger.systems/swift/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Danger-Swift as SPM Plugin? [IDEA]

NFulkerson opened this issue · comments

commented

At WWDC22, Apple introduced the concept of plugins for SPM. These plugins allow us to specify scripts that run either at build time or can be invoked manually.

Today, Danger Swift's setup requires "working around the system" to use the docs own words. I wonder whether the plugin system in SPM would remove the need to create a special target to get libDanger compiled. Once implemented as a plugin, it seems all one has to do is import it as a dependency like any other Swift Package, and then simply run something like:

swift package danger pr https://github.com/Moya/Harvey/pull/23

I don't see mass adoption of SPM plugins quite yet -- there may be reason for that. Perhaps at WWDC23 in a few days we'll see some further refinements to plugins.

This could work - it'd be worth figuring out if there are any sandboxing issues which come with running as a plugin ( I hear networking permissions were added pretty recently, so who knows what is not possible ) but it could work and it could be easier for folks to use then - which would be cool

I'd recommend taking a quick stab at it to see if there's any blockers

I believe the main issue is how Danger works.
Danger compiles the Dangerfile linking the needed libraries.
If you have plugins the library is compiled using your Package.swift definition to understand what is the library name to compile and link.
If you are not using plugins, the Danger library is linked.
I believe (and I would be happy to be wrong) using only a plugin would not allow us to have the libraries that needs to be linked to the Dangerfile compilation.

commented

It was my understanding that the SPM plugins are essentially just light runners or wrappers over tools, and so my hope is that we could compile and link as part of the build step for the plugin. I can try and fool around with it some over the upcoming weekend and see if there's any feasibility.