Test coverage
Codzee can show, on every pull request, how many of the changed lines your tests actually run, and link to the ones they miss. It reads the coverage report your CI already makes. It never runs your code or your tests.
What you get
Once a report arrives, a line is added to the bottom of the Codzee summary. On GitHub:
Test coverage: 18 of 24 changed lines tested. Untested: refund.ts:36–38 in refund(), quota.ts:12Each untested range links to the lines, with the function they sit in. On GitLab the summary note shows the same as Diff coverage: 18/24 changed lines tested (75%), with the untested lines listed below it.
- Only the lines a pull request adds or changes count, and only those your coverage tool measures (blank lines and comments don't).
- Test files are left out: a test can't be untested.
- No report, or a report that doesn't measure any changed line, means no coverage line at all, never a false 0%.
- Coverage never fails the Codzee review check. It has a check of its own, described next.
The coverage check, and requiring a minimum
Each measurement is also put on the commit as a separate check named Codzee coverage, beside the review's. It says the share of changed lines your tests ran, for example 75% of changed lines tested (18 of 24), and it is updated on every push that sends a report.
- With no minimum set, the check always passes. It is there to be read.
- With a minimum set, a pull request below it fails the coverage check, and only that check. An admin sets it under Settings → Test coverage → Coverage check, as a whole percent from 1 to 100. It applies to the whole workspace.
- No report means no check, never a failing one. Codzee doesn't fail a pull request for a report that was never sent.
Whether a failing coverage check stops a merge depends on the platform:
- GitHub: A failing coverage check only stops a merge once you add Codzee coverage as a required status check in your branch protection (Settings → Branches). A required check must be present to pass, so require it only where every pull request sends a report.
- GitLab: Codzee's checks are part of the merge request's pipeline. If “Pipelines must succeed” is on (Settings → Merge requests → Merge checks), a merge request below the minimum cannot be merged.
- Bitbucket: Codzee's checks are build statuses. If a merge check requires passing builds (“no failed builds”, under Repository settings → Branch restrictions) and the workspace enforces merge checks (Bitbucket Premium), a pull request below the minimum cannot be merged. On other plans it shows as a warning.
The same settings page shows the last 30 days: the share of changed lines tested for each repository, and each recent pull request with its result.
Two ways to set it up
- From your build's artifacts. If your tests run in GitHub Actions or GitLab CI/CD and keep the report as an artifact, Codzee finds it when the build finishes. Nothing to set up in Codzee.
- Sent by your CI. Add one step that sends the report to Codzee with a CI token. It works from any CI, including Jenkins, CircleCI and Buildkite, and it's the way to go when you don't keep artifacts.
You can use both. A report your CI sends is used first. If it doesn't cover any of the changed lines, Codzee still looks in the artifacts, so adding the step never loses coverage you already had.
Codzee reads lcov (lcov.info), Cobertura XML, JaCoCo XML and Istanbul (coverage-final.json). Most tools write one of these: Jest and Vitest (lcov or Istanbul), pytest-cov (--cov-report=xml, Cobertura), JaCoCo for Java and Kotlin, coverlet for .NET (Cobertura), and Go through gocover-cobertura.
From your build's artifacts
GitHub Actions. Upload the report as an artifact in the job that runs your tests:
# In the job that runs your tests, after the tests.
- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/lcov.info- Name the artifact with “coverage”, “cov”, “lcov”, “jacoco” or “cobertura” in it. A run with three artifacts or fewer is searched whatever they're called.
- The report file inside must be called
lcov.info,*.lcov,coverage-final.json,coverage.xml,cobertura*.xmlorjacoco*.xml. - Artifacts up to 50 MB that haven't expired. Codzee uses the Actions read permission it asks for when you install it.
GitLab CI/CD. Keep the report in the test job's artifacts:
test:
script:
- npm test -- --coverage
artifacts:
when: always
paths:
- coverage/lcov.info- List the file under
artifacts: paths. A file only underartifacts: reportsisn't in the archive Codzee reads. - Jobs with names like test, coverage, unit, jest or pytest are looked at first. Archives up to 50 MB.
- The file names are the same as for GitHub, above.
A review runs within seconds of a push, and tests take longer, so the coverage line usually appears a few minutes after the review, once the build has finished.
Create a CI token
To have your CI send the report, it needs a token for your workspace.
- In the dashboard, open Settings → Test coverage.
- Click Create token and copy it straight away. It's shown once. Codzee keeps only a fingerprint of it and can't show it again.
- Save it as a secret named
CODZEE_CI_TOKENin your CI, as below.
- One token works for every repository in your workspace. Only admins can create, replace or revoke it.
- Replace token makes a new one and stops the old one at once, so update your CI secret straight after. That's also what to do if a token leaks.
- Revoke stops uploads until you create a new token.
- The page shows the token's first characters, who created it and when it was last used. Tokens start with
czci_, so one found in a log is easy to recognise.
Settings → Test coverage also shows the steps below with your address filled in, ready to copy.
Send it from GitHub Actions
- In GitHub, open the repository's Settings → Secrets and variables → Actions and add a secret named
CODZEE_CI_TOKENwith the token. To use it in every repository, add it as an organization secret instead. - Add this step to the job that runs your tests, after the tests, and change
coverage/lcov.infoto wherever your tests write their report:
# Add after the step that runs your tests.
- name: Send coverage to Codzee
if: always()
continue-on-error: true
env:
CODZEE_CI_TOKEN: ${{ secrets.CODZEE_CI_TOKEN }}
COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
curl -fsS -X POST "https://codzeeweb-production.up.railway.app/api/coverage/upload?repo=${{ github.repository }}&commit=$COMMIT" -H "Authorization: Bearer $CODZEE_CI_TOKEN" --data-binary @coverage/lcov.info- On a pull request it sends the branch's own commit, not the merge commit GitHub checks out.
if: always()sends the report even when a test fails, so you still see what was covered.continue-on-error: truekeeps your build green if the upload can't happen. GitHub gives no secrets to pull requests from forks, so the upload is refused there. Coverage from artifacts still works for forks.- Pull requests from Dependabot read Dependabot's own secrets. To get coverage on them too, add the same secret under Secrets and variables → Dependabot.
Send it from GitLab CI/CD
- In GitLab, open the project's Settings → CI/CD → Variables and add a variable named
CODZEE_CI_TOKENwith the token. Tick Mask variable. Leave Protect variable off: protected variables only reach protected branches, and merge request branches usually aren't. To use it in every project, add it to the group instead. - Add this to the job that runs your tests, and change
coverage/lcov.infoto wherever your tests write their report. If the job already has anafter_script, add the line to it.
# Add to the job that runs your tests, after the tests.
after_script:
- 'curl -fsS -X POST "https://codzeeweb-production.up.railway.app/api/coverage/upload?repo=$CI_PROJECT_PATH&commit=${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}" -H "Authorization: Bearer $CODZEE_CI_TOKEN" --data-binary @coverage/lcov.info'after_scriptruns even when tests fail, and a failed upload never fails the job.- In a merged results pipeline it sends the merge request's own commit, not the merge commit GitLab builds.
Send it from any other CI
It's one request. Run it after your tests, with the token in a secret:
curl -fsS -X POST "https://codzeeweb-production.up.railway.app/api/coverage/upload?repo=<owner/name>&commit=<commit sha>" \
-H "Authorization: Bearer $CODZEE_CI_TOKEN" \
--data-binary @coverage/lcov.info- repo is the repository as your Git host names it:
acme/web, orgroup/subgroup/projecton GitLab. Capitals don't matter. - commit is the full 40-character sha of the pull request's latest commit.
- Send the file with
--data-binary. Plain-dstrips the line breaks and the report can't be read. - Don't let this step fail your build: check how your CI marks a step as allowed to fail.
Where common CIs keep the commit:
| CI | Commit |
|---|---|
| CircleCI | $CIRCLE_SHA1 |
| Buildkite | $BUILDKITE_COMMIT |
| Jenkins | $GIT_COMMIT, when Jenkins builds the branch itself rather than a merge with the target branch |
| Azure Pipelines | $(System.PullRequest.SourceCommitId) on pull request builds; $(Build.SourceVersion) is the merge commit there |
| Bitrise | $BITRISE_GIT_COMMIT |
If your CI builds a merge of the branch into the target branch, send the branch's own commit: that's the one Codzee reviewed.
Several reports
If a monorepo or several test jobs each write a report, send each one, with the same repository and commit. Codzee adds them together: a line counts as tested if any report ran it. Up to 20 reports per commit. Each one that arrives brings the summary up to date.
Limits and what Codzee keeps
- lcov, Cobertura XML, JaCoCo XML and Istanbul
coverage-final.json. - Up to 20 MB per report and 20 reports per commit.
- Up to 60 uploads a minute from one workspace.
- Reports are kept for 30 days.
- Codzee keeps only what it reads out of a report: file paths, line numbers and how often each line ran. Never the file itself, and never your code. Anything that isn't a coverage report is refused.
- The token is kept only as a fingerprint, so even Codzee can't read it back.
Troubleshooting
The upload step failed. Its log shows Codzee's answer:
| Answer | What it means |
|---|---|
| 201 | Kept. The answer says which format Codzee read and how many files it covers. |
| 400 | The address is missing ?repo= or &commit=, the commit isn't a full 40-character sha, or nothing was sent. |
| 401 | No token, a wrong one, or one that was replaced or revoked. On GitHub this is also what a pull request from a fork gets, because GitHub gives it no secrets. |
| 404 | No repository by that name is connected to Codzee in your workspace. Check the spelling and that Codzee is installed on it. |
| 409 | This commit already has 20 reports. Re-running a pipeline sends them again; push a new commit. |
| 413 | The report is over 20 MB. |
| 422 | What arrived isn't a coverage report Codzee can read. Check the path to the file and its format. |
| 429 | More than 60 uploads from your workspace in a minute. Wait a moment and send it again. |
The report was sent, but the summary has no coverage line.
- The report doesn't measure the changed lines. Its file paths must end with the file's path in the repository. Absolute paths like
/home/runner/work/app/app/src/a.tsare fine. Also check the report covers the package you changed. - Only test files changed, or only lines your coverage tool doesn't measure.
- It was sent for another commit, like a merge commit your CI built. See the commit table above.
- A newer commit was pushed. Coverage is for the commit Codzee last reviewed. The next build sends the next report.
- Codzee hasn't reviewed the pull request yet. That's fine: a report that arrives first is used when the review runs.
Coverage from artifacts doesn't show up. Check that the build has finished, the artifact hasn't expired, it's under 50 MB, and both the artifact and the file inside are named as described above. Or send the report from your CI instead: it's the most reliable way.
Can't find what you need? Email support@codzee.io and we'll help.