Types of Coverage Tokens
Qlty offers three authentication methods for uploading coverage reports:1. OpenID Connect (OIDC) with GitHub Actions
OIDC is a tokenless approach that uses temporary credentials. It’s the most secure method as it doesn’t require storing any long-lived tokens. Benefits:- No token management required
- Enhanced security with short-lived credentials
- Automatic token rotation
- Zero setup beyond the initial configuration
- Only works with GitHub Actions
- Requires the
id-token: writepermission in your workflow
2. Workspace-level Coverage Tokens
Workspace tokens provide coverage upload access for all repositories within a workspace (GitHub organization or user account). Benefits:- One token covers all repositories in a workspace
- Simplified setup for organizations with many repositories
- Works with any CI provider
- Broader scope than project tokens (less secure)
- Must be rotated manually if compromised
3. Project-level Coverage Tokens
Project tokens provide coverage upload access for a single repository. Benefits:- Most restrictive scope for enhanced security
- Independent token management per repository
- Works with any CI provider
- Requires separate token management for each project
- Must be rotated manually if compromised
Obtaining Coverage Tokens
Workspace-level Token
- Sign in to Qlty Cloud
- Go to Workspace Settings
- Navigate to the “Code Coverage” tab
- Copy the workspace coverage token
Project-level Token
- Sign in to Qlty Cloud
- Navigate to your project
- Go to Project Settings
- Select the “Code Coverage” tab
- Copy the project coverage token
Using Coverage Tokens
In GitHub Actions
Using OIDC (recommended):In Other CI Systems
Use the token as an environment variable:What an Upload Proves
Qlty accepts any upload that authenticates for a project. It can’t check that the coverage data in an upload is true. The commit, branch and pull request an upload names also come from the uploader, who can set them with the CLI’s--override-* options. Coverage in Qlty, and the commit statuses Qlty posts from it, are only as trustworthy as whoever can upload. If a Qlty coverage status is a required check, anyone who can upload can make it pass.
Who Can Upload with a Coverage Token
Anyone who has the token. A project token uploads to one project, and a workspace token uploads to every project in its workspace. On GitHub Actions, a workflow on any branch can read a repository or organization secret. People with write access to the repository can upload with a token stored there, just as they can with OIDC.Who Can Upload with OIDC
Qlty accepts a GitHub Actions OIDC token whose audience ishttps://qlty.sh. It files the upload under the project whose GitHub owner and repository name match the token’s repository claim. It doesn’t check which workflow, branch, event or environment the token came from.
Any job in the repository that has the id-token: write permission can get a token, so all of these can upload:
- people with write access to the repository, from a workflow on any branch, including a branch pushed only to upload
- a fork’s code, when a
pull_request_targetorworkflow_runworkflow runs it in a job withid-token: write - a third-party action that runs in a job with
id-token: write
pull_request workflow run from a fork.
Limiting Who Can Upload
- In a workflow with more than one job, set
id-token: writeon the job that uploads coverage rather than at the top of the workflow. The setup examples in these docs set it at the top, which is the same thing when the workflow has only one job. - Don’t run a fork’s code in a job that has
id-token: writeor can read a coverage token. - In jobs that have
id-token: write, pin third-party actions to a full commit SHA. The examples in these docs use version tags, such asqltysh/qlty-action/coverage@v2. Replace each tag with the commit SHA it points to.
Security Best Practices
Token Storage
Coverage tokens should be treated as sensitive credentials:- Never commit tokens to your repository
- Always use CI/CD environment variables or secrets
- Don’t expose tokens in build logs
- Don’t share tokens in communication channels
Environment Variable Storage
Store your coverage token as a secret environment variable in your CI system:- GitHub Actions: Repository or organization secrets
- CircleCI: Environment variables or contexts
- Travis CI: Environment variables
- GitLab CI: CI/CD variables
- Azure DevOps: Pipeline variables
- Jenkins: Credentials binding plugin
Token Rotation
Rotate your coverage tokens periodically or immediately if you suspect they’ve been compromised:- Go to the same place where you obtained the token
- Click “Refresh Token” (or similar)
- Update the token in all your CI configurations
Scope Limitation
Use the token with the most limited scope that meets your needs:- Use OIDC whenever possible with GitHub Actions
- Use project-level tokens when working with a single repository
- Use workspace-level tokens only when managing multiple repositories
Common Questions
What can someone do with a coverage token?
Coverage tokens only allow uploading coverage reports to specific projects or workspaces. They cannot:- Access other Qlty features
- Modify repository settings
- Access source code
- View private data
How do I rotate a token?
Tokens can be rotated through the same UI where you obtained them. Click “Refresh Token” to generate a new token and invalidate the old one.Can I use multiple tokens?
Yes, you can use different tokens for different contexts. For example:- Different tokens for production vs. development environments
- Different tokens for different CI pipelines
- Different tokens for manual vs. automated uploads
Should I verify my tokens are working?
Yes, after setting up a new token, run a test upload to verify it’s working correctly:Troubleshooting
Authentication Failures
If you get an authentication error:- Verify the token is correct (no extra spaces or line breaks)
- Check that the environment variable is correctly defined
- Ensure the token has not been rotated
- Verify you’re using the token in the correct context (workspace vs. project)
Invalid Token Format
If you see “Invalid token format” errors, check that:- The token is the complete string without any truncation
- There are no extra characters or whitespace
- You’re not accidentally using a different type of token
See Also
- CI Integration - Set up automated coverage reporting
- GitHub OIDC - Detailed guide on using OIDC with GitHub Actions
- Troubleshooting - Common issues and solutions