Open Coverage Documentation: Integration

Using the public Open Coverage service

Do not integrate with private repositories. Use the self-hosted option for private repositories.

Install Open Coverage GitHub Application

Before you can submit your coverage to the public Open Coverage service, you need install the application for your organization.

Visit the GitHub App and install it for your organization.

After you install the application to your organization, pay attention to the installation id for your organization. You will be using this as a token when you upload your coverage report.

In this example, the install id is 14396163.

Generate coverage data

Next, you'll need to generate coverage data for your test runs. This will look different depending on the language you're developing with.
Use the python Coverage coverage package to generate an xml coverage report.
Once `coverage` is installed, you just need to produce the xml report.
coverage xml

If you're using `pytest`, you can also integrate with `pytest-cov` to generate it all with once command.
pytest tests --cov=[mypackage] --cov-report xml

Submit coverage

Finally, you need to submit your coverage data to Open Coverage

The tested method for submitting coverage data is through the python codecov module.

pip install codecov
Then, submit with custom URL:
codecov --url="https://open-coverage.org/api" --token=[github installation id] --slug=[org]/[repo]
You can also use the `codecov` npm package for node projects:
yarn add codecov
Submit to open coverage is the same syntax:

codecov --url='https://open-coverage.org/api' --token=14396163 --slug=[org]/[repo] -f coverage.lcov
There is a suite of client libraries for codecov that should be compatible with Open Coverage.

Configuration

OptionValue
--tokenOpen Coverage installation id for your organization
--slugShould be [org]/[repo] combination for your repository. For example, vercel/next.js`
-FFlags allow you to pass information about the coverage report. For example, to specify that the report is for a specific project in the repo, use the `-F project:foobar` and the report will be categorized separately from others. This is how you can manage mono-repos and one commit spanning multiple projects.

cov.yaml: Configuration

To configure projects in your repo, you must have a cov.yamlfile in the root of your repo.

target: 99%
projects:
  frontend:
    base_path: app
  api:
    target: 100%
OptionValue
targetGlobal target coverage
diff_targetGlobal target coverage on changed code
projectsContainer for project specific settings
projects.[name].targetCustomized target specifically for a project
projects.[name].diff_targetCustomized target coverage on changed code for a project
projects.[name].base_pathBase path of where coverage report was generated from. This is useful for mono-repos