CVR

Get code coverage reports from your LCOV, Cobertura, Jacoco, or Go Cover results.

Sign in with GitHub

Use

curl

    
    curl -F coverage=@coverage.info "https://cvr.vokal.io/coverage?token=:TOKEN&commit=:COMMIT_HASH&coveragetype=:COVERAGE_TYPE&removepath=:REMOVE_PATH"
    
    

Details

Travis

This script can be used to work with Travis, which doesn't make the token available on pull requests. This includes getting the repo name and owner from Travis, but they can be hardcoded as well.


#!/bin/bash

# Required Travis config:
# - Add the repo token in the variable CVR_TOKEN as a secure property in the Travis configuration
# - LCOV_OUTPUT below must be the file path to the coverage output


if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
    # Upload the non-PR coverage to cvr.vokal.io
    curl -F coverage=@"${LCOV_OUTPUT}" \
        "https://cvr.vokal.io/coverage?token=${CVR_TOKEN}&commit=${TRAVIS_COMMIT}&removepath=${TRAVIS_BUILD_DIR}"

    # Exit successfully (so that the pull-request type uploading doesn't happen).
    exit 0
fi

# For PRs, we have to do some more fiddling to get the proper commit hash ($TRAVIS_COMMIT is the hash of a merge
# that Travis makes, not the hash of the last commit in the PR)...
LAST_PR_COMMIT="${TRAVIS_COMMIT_RANGE##*...}"
# ... and we have to split the repo slug to get repo owner and name.
REPO_OWNER="${TRAVIS_REPO_SLUG%%/*}"
REPO_NAME="${TRAVIS_REPO_SLUG##*/}"
# Let's put those into a URL query string fragment, to make the lines in this script shorter.
GIT_PARAMS="commit=${LAST_PR_COMMIT}&owner=${REPO_OWNER}&repo=${REPO_NAME}"
# Do the actual upload of PR coverage to cvr.vokal.io.
URL="https://cvr.vokal.io/coverage?${GIT_PARAMS}&removepath=${TRAVIS_BUILD_DIR}"
curl -F coverage=@"${LCOV_OUTPUT}" "${URL}"