Skip to content

swift run danger-swift edit doesn't include plugins; swift run danger-swift (ci|local) works #590

Open
@niorko

Description

I have a danger subdirectory in my project.

This is it's structure:

.
├── DangerDependencies
│   └── Fake.swift
├── Dangerfile.swift
├── Package.resolved
└── Package.swift

This is Dangerfile.swift:

import Foundation
import Danger
import DangerSwiftKantoku

let danger = Danger()
let kantokuConfig = XCResultParsingConfiguration(
    codeCoverageRequirement: .none,
    reportingFileType: .modifiedAndCreatedFiles
)
danger.kantoku.parseXCResultFile(at: "somePath", configuration: kantokuConfig)

and this is Package.swift:

// swift-tools-version:5.8
import PackageDescription

let package = Package(
    name: "DangerDepsProject",
    platforms: [.macOS(.v12)],
    products: [
        .library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"])
    ],
    dependencies: [
        .package(url: "https://github.com/danger/swift.git", from: "3.17.1"),
        .package(url: "https://www.github.com/yumemi-inc/danger-swift-kantoku.git", from: "0.1.1")
    ],
    targets: [
        .target(
            name: "DangerDependencies", 
            dependencies: [
                .product(name: "Danger", package: "swift"),
                .product(name: "DangerSwiftKantoku", package: "danger-swift-kantoku")
            ],
            path: "DangerDependencies"
        )
    ]
)

This works and it successfully uses plugins:

cd danger
swift build
swift run danger-swift local --failOnErrors --cwd ../ --base origin/develop

But I want to be able to edit the project, so I call this:

cd danger
swift build
swift run danger-swift edit

And this does not work, it generates the project where Package.swift does not contain plugins, so it won't build:

Generated Package.swift:

// swift-tools-version:5.8
// danger-dependency-generator-version:3

import PackageDescription

let package = Package(
    name: "Dangerfile",
    platforms: [.macOS(.v13)],
    products: [.executable(name: "DangerDependencies", targets: ["Dangerfile"])],
    dependencies: [
        .package(url: "https://github.com/danger/swift.git", exact: "3.17.1")
    ],
    targets: [.executableTarget(name: "Dangerfile", dependencies: [
        .product(name: "Danger", package: "swift")
    ])],
    swiftLanguageVersions: [.version("5")]
)

Swift Danger Version: 3.17.1

Example project: danger.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions