Skip to content

xnzg/xccov-to-codecov

Repository files navigation

Xcode Code Coverage to Codecov

This repo provides a commandline tool to convert Xcode code coverage report to the custom Codecov JSON format.

It seems that Codecov has recently pulled off all documentation on this private JSON format. If it no longer works, I will change the output to some other format supported by Codecov.

Installation

At the moment, you need to build the package yourself and move the executable to your PATH. To build, run:

swift build --configuration release

The executable’s should be located in:

swift build --configuration release --show-bin-path

Usage

Two tools are required, Xcode from 11 and up, and xcparse. The workflow consists of three steps.

First, generate a result bundle (.xcresult) with code coverage. For instance, if you are using xcodebuild, run:

xcodebuild -project <projectname> -scheme <schemename> -resultBundlePath Test.xcresult test

This will generate a result bundle named Test.xcresult. It is crucial to turn on “Gather code coverage” in your scheme.

Second, extract .xccovarchive from the result bundle. Run

xcparse codecov <path-to-xcresult> <destination>

Two files will be generated in <destionation>, action.xccovarchive and action.xccovreport. The first will be used.

Lastly, run our tool:

xccov-to-codecov <path-to-xccovarchive> FILE1 FILE2 ...

A JSON will be outputed. You can pipe the output to any file you like.

Regarding the file list, notice that you might want to exclude certain files from your code coverage calculation, such as all Package.swift files as well as or files generated by SwiftGen/Sourcery/Protobuf. For instance, you can run:

git ls-files | grep '.*\\.swift$' | grep -v Package.swift"

It uses git to list all tracked files, then keeps only files with .swift extension, and lastly removes all files named Package.swift.

About

Convert xccov files for Codecov.io.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages