GitHub Code Coverage Uploads Now Require Cobertura XML

GitHub's coverage upload now rejects invalid report formats. Fix the Cobertura XML requirement, permissions, workflow triggers, and common CI failures.

Coverage report sheets passing through a quality gate into a pull request coverage chart while a malformed report is stopped

GitHub's Code Quality upload-code-coverage action now checks the input file before accepting it. The file must be a Cobertura XML coverage report. Workflows that previously appeared to upload successfully while showing no coverage will now fail with a useful error instead.

The failure message is direct: the file is not a Cobertura XML report, so upload a Cobertura XML report. This usually means the test tool produced another format such as LCOV, or the workflow pointed at the wrong file. The fix belongs in report generation, not in a retry loop around the upload step.

What Cobertura XML means here

Cobertura is the interchange format GitHub Code Quality reads for pull request line coverage. Your language does not need to be Java or use a specific test framework. The test tool only needs to emit a valid Cobertura XML file, either directly or through a converter.

Generate the right report

For Python, pytest-cov can write XML coverage directly. For JavaScript and TypeScript, Istanbul or nyc can use the Cobertura reporter. For Go, a tool such as gocover-cobertura can convert a coverprofile. For Java, use the JaCoCo to Cobertura conversion path documented by GitHub. The important check is the file format at the upload boundary, not the name of the test runner.

The workflow requirements

The upload job needs code-quality: write permission. The usual baseline also grants contents: read. If a push workflow must discover an associated pull request, it needs pull-requests: read and GitHub CLI available on the runner. Keep the write permission in a separate upload job when practical so the job running tests and third-party dependencies has less access.

Use the right workflow triggers

For most repositories, run coverage on pull_request and on pushes to the default branch. The pull request run provides the review context, while the default branch establishes the comparison baseline. A broad push plus pull_request setup can run twice for the same commit, so choose the trigger strategy deliberately.

Handle fork pull requests safely

Pull requests from forks do not have write access to the base repository, so the coverage action cannot upload their report. Guard the upload step for fork pull requests, or use a workflow design that runs the upload only when the source repository is the same as the base repository. Let the tests run even when the upload is skipped.

Why valid reports may still need cleanup

GitHub also made processing more forgiving for valid Cobertura reports. Minor structural problems no longer reject the whole report, and individual lines without a usable line number or hit count are skipped. That helps imperfect reports, but it does not make a different format acceptable.

A quick debugging sequence

First confirm the file exists at the path passed to the action. Next identify its producer and configure that tool for Cobertura output. If conversion is required, validate the converted file before upload and keep the conversion step in the same job. Then check workflow permissions and fork conditions. Finally, open the pull request after a successful run and confirm that the coverage comment or result appears.

Availability

The change is available on GitHub Enterprise Cloud and GitHub Team, including GitHub Enterprise Cloud with data residency. It is not available on GitHub Enterprise Server. Code coverage also requires GitHub Code Quality to be enabled for the repository.

Bottom line

The new validation turns a silent coverage gap into a visible CI failure. Generate Cobertura XML on purpose, give the upload job only the permissions it needs, skip unsafe fork uploads, and verify coverage on the pull request after the workflow passes.