Code Monkey home page Code Monkey logo

danger-swift-coverage's Introduction

DangerSwiftCoverage

Danger-Swift plugin to show the coverage of the modified/created files.

DangerSwiftCoverage

Getting Started

Install DangerSwiftCoverage

Swift Package Manager (More performant)

You can use a "full SPM" solution to install both danger-swift and DangerSwiftCoverage.

  • Add to your Package.swift:
let package = Package(
    ...
    products: [
        ...
        .library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]), // dev
        ...
    ],
    dependencies: [
        ...
        // Danger Plugins
        .package(url: "https://github.com/f-meloni/danger-swift-coverage", from: "0.1.0") // dev
        ...
    ],
    targets: [
        .target(name: "DangerDependencies", dependencies: ["Danger", "DangerSwiftCoverage"]), // dev
        ...
    ]
)
  • Add the correct import to your Dangerfile.swift:
import DangerSwiftCoverage

Coverage.xcodeBuildCoverage(.derivedDataFolder("Build"), 
                            minimumCoverage: 50, 
                            excludedTargets: ["DangerSwiftCoverageTests.xctest"])
  • Create a folder called DangerDependencies on Sources with an empty file inside like Fake.swift
  • To run Danger use swift run danger-swift command
  • (Recommended) If you are using SPM to distribute your framework, use 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
import DangerSwiftCoverage // package: https://github.com/f-meloni/danger-swift-coverage.git

Coverage.xcodeBuildCoverage(.derivedDataFolder("Build"), 
                            minimumCoverage: 50, 
                            excludedTargets: ["DangerSwiftCoverageTests.xctest"])
  • (Recommended) Cache the ~/.danger-swift folder

Gather Coverage

  • Enable "Gather the Coverage" on Xcode

GatherCoverage

or, on your CI, execute:

xcodebuild test -scheme DangerSwiftCoverage-Package -derivedDataPath Build/ -enableCodeCoverage YES

Custom XCResultBundle path

If you are using the -resultBundlePath parameter on xcodebuild you will need to use:

Coverage.xcodeBuildCoverage(.xcresultBundle("Build/bundlePath.xcresult"), 
                            minimumCoverage: 50, 
                            excludedTargets: ["DangerSwiftCoverageTests.xctest"])

Swift Package Manager

From Swift 5.0 you can gather the coverage from SPM with the --enable-code-coverage=true flag For SPM coverage add to your Dangerfile:

Coverage.spmCoverage(minimumCoverage: 50)

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

danger-swift-coverage's People

Contributors

f-meloni avatar avdlee avatar nikolaykasyanov avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.