Coverage Quick Start
This guide will help you set up code coverage reporting in your CI pipeline.
Prerequisites
- A repository with automated tests that generate coverage data
- A GitHub user with administrator permissions on your organization
- Ability to modify and run CI scripts for your repository
Step 1. Determine an authentication approach
Qlty supports three ways to authenticate code coverage uploads from your CI system:
- OpenID Connect (OIDC) with GitHub Actions (recommended)
- Workspace-level coverage tokens
- Project-level coverage tokens
If you are using GitHub Actions, we recommend using OIDC as it is the most secure and requires no management of long-lived coverage tokens.
To use OIDC, you will make changes to your GitHub Actions workflow (described in Step 3 below). No other setup is required.
If you are not using GitHub Actions (or can’t use OIDC), you can use a workspace-level coverage token that is scoped to your entire organization.
Obtain a coverage token from Qlty
If you are not using OIDC, you will need to obtain a coverage token:
- Login to Qlty via GitHub OAuth
- Navigate to Workspace Settings > Code Coverage (e.g.
https://qlty.sh/gh/your-org/settings/coverage
) - Copy the workspace’s coverage token
Step 2. Store the coverage token as a CI secret (if not using OIDC)
If you are using OIDC, you can skip this step.
A coverage token should be treated as a credential and stored securely within your CI system.
The specifics for how to store a secret at the organization level vary by provider:
Step 3. Update CI workflow scripts
This guide assumes that your CI scripts are already generating code coverage data from the execution of your automated tests. The method to generate this data varies by programming language and testing tools.
Once you have code coverage data being generated in one of our supported formats, continue with the steps below.
GitHub Actions
Add a step to run the qltysh/qlty-action/coverage
reusable GitHub Action:
The Qlty GitHub Action is simply a convenience wrapper that installs the qlty CLI and executes qlty coverage publish
with the provided arguments.
If you are unable to use the Qlty Github Action (because your organization’s security policy does not permit it, or you are using a self-hosted runner), manual integration is straight-forward. See Manual Integration below.
CircleCI Orb
We provide a CircleCI Orb for uploading coverage reports. Add the following to your .circleci/config.yml
file:
Learn more about our CircleCI Orb
The Qlty CircleCI Orb is a convenience wrapper that simply installs the qlty CLI and executes qlty coverage publish
with the provided arguments.
If you are unable to use the Qlty CircleCI Orb manual integration is straight-forward. See Manual Integration below.
CLI Integration / Other CI Providers
If you are not using CircleCI or GitHub, or prefer not to use the convenience wrappers available for those providers, manual integration is straight-forward.
To publish coverage, you will install the Qlty CLI and run the qlty coverage publish
command, specifying the coverage data file(s):
Occassionally, qlty coverage publish
requires additional arguments. The most commonly used arguments are:
--add-prefix
and/or--strip-prefix
to ensure the paths to source files are valid--format
to specify the format of the coverage file (e.g.--format jacoco
)
See our documentation on Manual Integration for more information.
Step 4. Validate coverage uploads from a branch
After updating your CI script:
- Push your changes to a branch and trigger a build
- Ensure the build completes successfully with no errors during the upload process
- On Qlty, navigate to your Project Settings > Code Coverage page
- Your uploaded coverage report should appear in the table at the bottom of the page
- Click on the commit SHA to view your report details and verify it matches your expectations
Step 5. Merge your CI script changes into your main branch
Once coverage uploads are working successfully for your branch:
- Merge the branch into your main branch and run a build
- Ensure the build completes successfully with no errors from the coverage upload step
- Validate the coverage upload in your Project Settings
- Once Qlty receives a valid coverage report for your main branch, your coverage info will be displayed in your project’s Overview page
Optional: Enable coverage commit statuses
To enforce coverage thresholds on pull requests:
- Enable commit statuses (Qlty Coverage and Qlty Diff Coverage) within your Project’s Gate settings
- Adjust coverage check settings (including configurations for minimum diff size and total coverage decrease)
Next Steps
- Generating Coverage Data - Format-specific configuration
- Coverage Metrics - Learn about the coverage metrics Qlty provides
- Coverage Merging - Merge multiple coverage reports from parallel test runs
- Example Repositories - Reference implementations
- Troubleshooting - Common issues and solutions