$devvkit learn --librarie codecov:-coverage-in-ci-guide
Codecov: Coverage in CI Guide
[oss-stack][testing][coverage][ci]
Open Source
Install
# After running tests with coverage: bash <(curl -s https://codecov.io/bash) # or the unified uploader: curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov
Codecov collects coverage reports from any test runner (Jest, pytest, cargo-tarpaulin...), visualizes them per file and line, and reports the delta on every pull request. The open source plan is free and unlimited for public repos: this is the easiest credibility win available to a new project.
The killer feature for maintainers is the patch check: a PR that drops coverage below your threshold fails, without a single line of test-policing code. Combined with badges on the README it converts "we test things" from a claim into a number.
Setup
Install the app· Codecov GitHub App + token in CI.
# Install app: github.com/apps/codecov
# Add CODECOV_TOKEN to repo secrets.
# CI step:
- run: npm test -- --coverage
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: trueUpload
Local upload· Upload from anywhere.
# Bash uploader (legacy): bash <(curl -s https://codecov.io/bash) # Current unified uploader: curl -Os https://uploader.codecov.io/v0.4/linux/codecov chmod +x codecov ./codecov -t $CODECOV_TOKEN # Python: pip install codecov codecov
Status Checks
Target and patch· Require minimum overall and delta coverage.
# codecov.yml:
coverage:
status:
project:
default:
target: 90%
threshold: 1%
patch:
default:
target: 80%
comment:
layout: "reach, diff, flags, components"
require_changes: trueConfiguration
Badge· The README badge that proves the number.
[](https://codecov.io/gh/OWNER/REPO) # Also expose on the branch: # codecov.io/gh/OWNER/REPO/branch/main/graphs/tree.html