From 6f714b6c1907e1929e300d4741adf53573c1e547 Mon Sep 17 00:00:00 2001 From: Nimesh Date: Fri, 20 Mar 2026 15:44:51 +0530 Subject: [PATCH 1/3] Integrates Codecov for PHP code coverage 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/workflows/test.yml | 22 ++++++++++++++++++++-- codecov.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1602a890..7b34d1b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: run: npm run lint:phpstan test-php: - name: Test PHP ${{ matrix.php }} ${{ matrix.wp != '' && format( ' (WP {0}) ', matrix.wp ) || '' }} + name: Test PHP ${{ matrix.php }} ${{ matrix.wp != '' && format( ' (WP {0}) ', matrix.wp ) || '' }}${{ matrix.coverage && ' (with coverage)' || '' }} runs-on: ubuntu-24.04 strategy: matrix: @@ -81,6 +81,11 @@ jobs: - latest - trunk - '6.8' + coverage: [false] + include: + - php: '8.3' + wp: latest + coverage: true exclude: - php: '7.3' wp: trunk @@ -115,7 +120,12 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: npm run env start + command: | + if [[ ${{ matrix.coverage == true }} == true ]]; then + npm run env start -- --xdebug=coverage + else + npm run env start + fi - name: Composer install run: | @@ -130,6 +140,14 @@ jobs: - name: Test run: npm run test + - 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 }} + build: name: Build runs-on: ubuntu-24.04 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..84c66a69 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,36 @@ +# Overall settings for PR integration via codecov.io +# See https://docs.codecov.com/docs/codecovyml-reference + +# Separate PR statuses for project-level and patch-level coverage +# See https://docs.codecov.com/docs/commit-status +coverage: + status: + # Project-level coverage + project: + default: + base: auto + # Disable once code base is more mature. + informational: true + only_pulls: true + target: auto + threshold: 5% + + # Patch-level coverage (how well is the PR tested) + patch: + default: + base: auto + informational: true + only_pulls: true + target: auto + threshold: 50% + +# Pull request comments +# See https://docs.codecov.com/docs/pull-request-comments +comment: false + +# See https://docs.codecov.com/docs/ignoring-paths +ignore: +- tests +- vendor +- node_modules +- dist From 8a64b1b1f2918ff0fbc45a0545a427ab161bf82a Mon Sep 17 00:00:00 2001 From: Nimesh Date: Tue, 24 Mar 2026 11:45:34 +0530 Subject: [PATCH 2/3] Tolerates Codecov upload failures in CI 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. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b34d1b7..4c67876c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -146,7 +146,7 @@ jobs: with: file: tests/logs/clover.xml flags: phpunit - token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false build: name: Build From d1e365ade309faf9c271c41549afc6546405d926 Mon Sep 17 00:00:00 2001 From: Nimesh Date: Fri, 27 Mar 2026 11:22:29 +0530 Subject: [PATCH 3/3] Integrates Codecov for code coverage Configures the PHP test workflow to generate code coverage data consistently. Uploads the coverage report to Codecov for the PHP 8.3 / latest WordPress test matrix. Removes the dedicated `coverage` matrix variable, streamlining the workflow definition. Adds a Codecov badge to the README to visualize current coverage status. --- .github/workflows/test.yml | 16 +++------------- readme.md | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c67876c..4dd291ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: run: npm run lint:phpstan test-php: - name: Test PHP ${{ matrix.php }} ${{ matrix.wp != '' && format( ' (WP {0}) ', matrix.wp ) || '' }}${{ matrix.coverage && ' (with coverage)' || '' }} + name: Test PHP ${{ matrix.php }} ${{ matrix.wp != '' && format( ' (WP {0}) ', matrix.wp ) || '' }} runs-on: ubuntu-24.04 strategy: matrix: @@ -81,11 +81,6 @@ jobs: - latest - trunk - '6.8' - coverage: [false] - include: - - php: '8.3' - wp: latest - coverage: true exclude: - php: '7.3' wp: trunk @@ -120,12 +115,7 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: | - if [[ ${{ matrix.coverage == true }} == true ]]; then - npm run env start -- --xdebug=coverage - else - npm run env start - fi + command: npm run env start -- --xdebug=coverage - name: Composer install run: | @@ -141,7 +131,7 @@ jobs: run: npm run test - name: Upload code coverage report - if: ${{ matrix.coverage }} + if: ${{ matrix.php == '8.3' && matrix.wp == 'latest' }} uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de with: file: tests/logs/clover.xml diff --git a/readme.md b/readme.md index ba89985d..dd2b1606 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,7 @@ ![WordPress.org Rating](https://img.shields.io/wordpress/plugin/rating/two-factor?label=WP.org%20Rating) ![WordPress Plugin Downloads](https://img.shields.io/wordpress/plugin/dt/two-factor?label=WP.org%20Downloads) ![WordPress Plugin Active Installs](https://img.shields.io/wordpress/plugin/installs/two-factor?label=WP.org%20Active%20Installs) [![WordPress Playground Demo](https://img.shields.io/wordpress/plugin/v/two-factor?logo=wordpress&logoColor=FFFFFF&label=Live%20Demo&labelColor=3858E9&color=3858E9)](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/WordPress/two-factor/master/.wordpress-org/blueprints/blueprint.json) -[![Test](https://github.com/WordPress/two-factor/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/test.yml) [![Deploy](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml) +[![Test](https://github.com/WordPress/two-factor/actions/workflows/test.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/test.yml) [![Deploy](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml/badge.svg)](https://github.com/WordPress/two-factor/actions/workflows/deploy.yml) [![codecov](https://codecov.io/gh/WordPress/two-factor/graph/badge.svg)](https://codecov.io/gh/WordPress/two-factor) > Two-Factor plugin for WordPress. [View on WordPress.org →](https://wordpress.org/plugins/two-factor/)