Code coverage for every commit, free
Send a coverage report from your CI. Coverage shows the total of your repo, how it changed with each commit, which files lost coverage and which lines are not tested. Made for monorepos: each project is a flag, and a project that a commit did not touch keeps its last report.
Upload in 3 steps
- Sign in, add your repo (an owner and a name, such as
acme/widgets) and make an upload token. The token is shown once. Save it as a secret of your CI namedCOVERAGE_TOKEN. - Make the report: for each file, the covered and total counts of lines, statements, functions and branches, and the missed lines. The docs show the JSON.
- Send it after your tests, once for each flag. Both examples below do it with a gzip body.
gzip -c report.json | curl --fail-with-body \
-X POST https://coverage.utilarium.app/api/v1/upload \
-H "Authorization: Bearer $COVERAGE_TOKEN" \
-H "Content-Type: application/json" \
-H "Content-Encoding: gzip" \
--data-binary @-import { gzipSync } from "node:zlib";
const report = {
commit: process.env.GITHUB_SHA,
branch: process.env.GITHUB_REF_NAME,
flag: "apps/coro",
message: "Fix the login page",
files: [
{
path: "client/lib/x.ts",
lines: [12, 14], // [covered, total]
statements: [13, 15],
functions: [3, 3],
branches: [4, 6],
missed: "3-5,9", // the uncovered lines, as sorted ranges
},
],
};
const response = await fetch("https://coverage.utilarium.app/api/v1/upload", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COVERAGE_TOKEN}`,
"Content-Type": "application/json",
"Content-Encoding": "gzip",
},
body: gzipSync(JSON.stringify(report)),
});
console.log(response.status, await response.json());The answer is 201 with the address of the commit page. A second upload for the same commit and flag replaces the first, so a retried CI job is safe.
What you get
- The total and each flag, colored red, yellow or green.
- The last 30 commits with the change from the commit before.
- For each commit, the files whose coverage changed.
- For each flag, every file with its missed lines, and a history.
- A badge for your README, only when you turn it on.