Swiftpack.co -  mattpolzin/swift-test-codecov as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
mattpolzin/swift-test-codecov
Simple executable to produce code coverage numbers from the output of `swift test --enable-code-coverage`
.package(url: "https://github.com/mattpolzin/swift-test-codecov.git", from: "0.10.0")

swift-test-codecov

I'm writing this because tooling that can ingest the code coverage report produced by swift test --enable-code-coverage is shockingly hard to find.

Usage

Library

The library has a pretty small and straight forward interface. I have not had time to write about it here in the README, but taking a look at how the executable target uses the library target should be pretty informative.

Tool

USAGE: swift-test-codecov <codecov-filepath> [--metric <metric>] [--minimum <minimum-coverage>] [--print-format <print-format>] [--sort <sort>] [--dependencies]

ARGUMENTS:
  <codecov-filepath>      the location of the JSON file output by `swift test --enable-code-coverage`. 
        You will find this in the build directory.

        For example, if you've just performed a debug build, the file will be located at `./.build/debug/codecov/<package-name>.json`.

OPTIONS:
  -m, --metric <metric>   The metric over which to aggregate. One of lines, functions, instantiations (default: lines)
  -v, --minimum <minimum-coverage>
                          The minimum coverage allowed. A value between 0 and 100. Coverage below the minimum will result in exit code 1. (default: 0)
  -p, --print-format <print-format>
                          Set the print format. One of minimal, table, json (default: minimal)
  -s, --sort <sort>       Set the sort order for the coverage table. One of filename, +cov, -cov (default: filename)
  -d, --dependencies      Include dependencies in code coverage calculation. 
  -h, --help              Show help information.

Building Docker Image

Run docker build -t swift-test-codecov . to build the docker image.

GitHub

link
Stars: 9
Last commit: 23 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Release Notes

More useful output
23 weeks ago

Without changing the actual aggregation features, adds the ability to print a JSON representation of results containing all the information used in building out the table output and the summary.

Breaking:

  • There is no longer a -t/--table option; use --print-format=table instead now.
  • All output options used to short-circuit on failure and just print a message about the test coverage not meeting the minimum requirements; now, the script will exit with code 1 in the same situations but it will always print out the desired format of output (JSON, table, or just the percentage).

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API