Skip to content

Integrates Codecov for PHP code coverage#842

Open
nimesh-xecurify wants to merge 2 commits intoWordPress:masterfrom
nimesh-xecurify:codecov-integration
Open

Integrates Codecov for PHP code coverage#842
nimesh-xecurify wants to merge 2 commits intoWordPress:masterfrom
nimesh-xecurify:codecov-integration

Conversation

@nimesh-xecurify
Copy link
Contributor

What?

Adds Codecov integration to the PHP test workflow in GitHub Actions. Enables automated code coverage collection using Xdebug for a dedicated matrix job. Configures Codecov through codecov.yml to set project and patch coverage thresholds, ignore irrelevant files, and manage PR comments.

Why?

This provides automated visibility into code coverage changes within pull requests, helping maintain code quality.

Changelog Entry

Added - Codecov Integration.

Fixes #832

Adds Codecov integration to the PHP test workflow in GitHub Actions.
Enables automated code coverage collection using Xdebug for a dedicated matrix job.
Configures Codecov through `codecov.yml` to set project and patch coverage thresholds, ignore irrelevant files, and manage PR comments.

This provides automated visibility into code coverage changes within pull requests, helping maintain code quality.
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: nimeshatxecurify, masteradhoc.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: nimesh-xecurify <nimeshatxecurify@git.wordpress.org>
Co-authored-by: masteradhoc <masteradhoc@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Codecov-based PHP coverage reporting to the CI pipeline, so pull requests can surface project/patch coverage signals and upload a Clover report from a dedicated coverage job.

Changes:

  • Add codecov.yml configuration for coverage statuses (project/patch), ignored paths, and PR comment behavior.
  • Extend the PHP test GitHub Actions workflow with a dedicated “with coverage” matrix entry that enables Xdebug coverage.
  • Upload tests/logs/clover.xml to Codecov from the coverage job.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
codecov.yml Introduces Codecov configuration (coverage status thresholds, ignore rules, PR comment setting).
.github/workflows/test.yml Adds a coverage-enabled matrix run and uploads the Clover report to Codecov.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +143 to +149
- name: Upload code coverage report
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de
with:
file: tests/logs/clover.xml
flags: phpunit
token: ${{ secrets.CODECOV_TOKEN }}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/codecov-action is configured with token: ${{ secrets.CODECOV_TOKEN }}. Secrets are not available to pull_request workflows from forks, so the coverage matrix job will fail for external contributors unless you either omit the token (for tokenless uploads via the Codecov GitHub App / OSS mode) or gate the upload step to only run when a token is available (e.g., same-repo PRs / pushes) or set the action to not fail CI when the token is missing.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nimesh-xecurify can we get your feedback on this? what would be your approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for tokenless uploads via the Codecov GitHub App / OSS mode)

I believe removing the token would be the way. It does require installing the Codecov GitHub App across the repo. plugin-check implements the last suggested approach - set the action to not fail CI when the token is missing.
@jeffpaul we could use your opinion on this. Would it be possible to omit the token (OSS Mode)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Codecov app is set up on https://github.com/WordPress/ai so doing the same here seems fine to me, though I don't have repo admin access to click the necessary buttons

Configures the Codecov upload step to not fail the CI pipeline if an error occurs during coverage data submission. This ensures that essential build and test jobs can pass even if there are transient issues with Codecov integration or network connectivity, preventing unnecessary CI failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Codecov integration for test coverage tracking

4 participants