Skip to content
Latchkey

How to Publish Coverage to Codecov with GitHub Actions

codecov/codecov-action takes the coverage file your tests produce and uploads it to Codecov for PR annotations.

Run your tests with coverage to emit a report (for example coverage/lcov.info or coverage.xml), then call codecov/codecov-action with a CODECOV_TOKEN secret so the upload is authenticated and not rate-limited.

Steps

  • Run tests with --coverage to produce a report file.
  • Add codecov/codecov-action, passing files and the token.
  • Store the upload token as the CODECOV_TOKEN repository secret.

Workflow

.github/workflows/ci.yml
jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npx jest --coverage
      - uses: codecov/codecov-action@v5
        with:
          files: ./coverage/lcov.info
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: true

Gotchas

  • Without a token, uploads can fail with "Token required" or hit rate limits on private repos.
  • Point files at the report your runner actually wrote, or Codecov reports no coverage found.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →