Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
11caf1f
Fix Codecov badge by adding OIDC permission for tokenless upload
nimesh-xecurify Mar 28, 2026
1497fe7
Enables OIDC for Codecov action
nimesh-xecurify Mar 28, 2026
fa58b7e
Prepares workflow for code coverage
nimesh-xecurify Mar 28, 2026
5e6556a
Enables Codecov report upload
nimesh-xecurify Mar 28, 2026
91881c2
Removes redundant coverage report retrieval
nimesh-xecurify Mar 28, 2026
ba3d8a2
Fix coverage file retrieval via docker exec on persistent container
nimesh-xecurify Mar 28, 2026
07a7398
Add debug step to diagnose coverage report content and xdebug mode
nimesh-xecurify Mar 28, 2026
e6bcc88
Ensure robust code coverage report retrieval and upload
nimesh-xecurify Mar 28, 2026
2513a33
Streamlines CI coverage report handling
nimesh-xecurify Mar 28, 2026
3d9317b
Fetches coverage report from test container
nimesh-xecurify Mar 28, 2026
367f804
Ensures robust code coverage generation in CI
nimesh-xecurify Mar 28, 2026
68452bd
Adjusts `wp-env` coverage command
nimesh-xecurify Mar 28, 2026
e8a9180
Streamlines CI coverage generation
nimesh-xecurify Mar 28, 2026
683a838
Merge branch 'master' into codecov-integration
masteradhoc Mar 28, 2026
83f5ee5
Removes redundant coverage report retrieval
nimesh-xecurify Mar 29, 2026
10a1cbb
Merge branch 'master' into codecov-integration
nimesh-xecurify May 14, 2026
3783602
Scope Codecov OIDC permission to a dedicated upload job
nimesh-xecurify Jul 3, 2026
9563db7
Merge branch 'master' into codecov-integration
nimesh-xecurify Jul 3, 2026
2cf6841
Merge branch 'master' into codecov-integration
masteradhoc Aug 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensures robust code coverage generation in CI
Updates Composer install to use `--ignore-platform-req=php` on PHP 8.x, ensuring PHPUnit 9.6 is installed for compatible code coverage. Explicitly enables Xdebug coverage mode and passes `--coverage-clover` to PHPUnit within `wp-env` for the coverage matrix cell, guaranteeing reliable report generation. Refines comments regarding atomic file retrieval via `docker cp`.
  • Loading branch information
nimesh-xecurify committed Mar 28, 2026
commit 367f8049cc5ccb37e20856e6da56faa5326e4f05
38 changes: 28 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ jobs:
- name: Composer install
run: |
rm composer.lock || true # We need to install fresh.
npm run composer install
# On PHP 8+, the composer.json platform override (php: 7.2.24) causes PHPUnit 8.5 to
# be installed. PHPUnit 8.5 explicitly refuses to generate code coverage on PHP 8 with
# the message "This version of PHPUnit does not support code coverage on PHP 8". Pass
# --ignore-platform-req=php so Composer resolves against the actual PHP runtime and
# installs PHPUnit 9.6, which supports coverage on PHP 8.x.
if [[ "${WP_ENV_PHP_VERSION}" == 8.* ]]; then
npm run composer -- install --ignore-platform-req=php
else
npm run composer install
fi

- name: Versions
run: |
Expand All @@ -133,27 +142,36 @@ jobs:
- name: Test
run: |
npm run env run tests-cli --env-cwd=wp-content/plugins/two-factor -- mkdir -p tests/logs
npm run test
# For the coverage matrix cell, set XDEBUG_MODE=coverage explicitly via env var
# (Xdebug 3 feature) rather than relying on the ini configuration that wp-env
# applies to persistent containers — ephemeral wp-env run containers may not
# inherit it. Pass --coverage-clover in addition to what phpunit.xml.dist configures
# so the clover output is guaranteed regardless of XML config format differences
# between PHPUnit versions.
if [[ "${{ matrix.php }}" == "8.3" && "${{ matrix.wp }}" == "latest" ]]; then
npm run env run tests-cli --env-cwd=wp-content/plugins/two-factor -- \
sh -c 'XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover tests/logs/clover.xml'
else
npm run test
fi

- name: Retrieve coverage report from container
if: ${{ matrix.php == '8.3' && matrix.wp == 'latest' }}
run: |
# PHPUnit writes clover.xml into the named Docker volume shared between the
# tests-wordpress and tests-cli containers. The plugin directory is NOT bind-mounted
# from the workspace in CI, so the file does not appear on the host filesystem after
# npm run test. We use docker cp (not 'docker exec cat > file') because docker cp is
# an atomic Docker API call that reads from the container's merged filesystem without
# a shell redirect that would pre-truncate the destination and cause a self-overwrite.
# PHPUnit writes clover.xml into the Docker volume shared between tests-cli and
# tests-wordpress. We use docker cp (not 'docker exec cat > file') because docker cp
# is an atomic Docker API call that avoids a shell redirect pre-truncating the
# destination — which would zero-out the file before cat can read it.
CONTAINER=$(docker ps --filter "name=tests-wordpress" --format "{{.Names}}" | head -1)
if [ -z "$CONTAINER" ]; then
echo "Error: tests-wordpress container not found"
exit 1
fi
mkdir -p tests/logs
docker cp "$CONTAINER:/var/www/html/wp-content/plugins/two-factor/tests/logs/clover.xml" tests/logs/clover.xml
echo "=== xdebug mode reported by tests-wordpress ==="
echo "=== xdebug mode in tests-wordpress ==="
docker exec "$CONTAINER" php -r "echo ini_get('xdebug.mode') . PHP_EOL;"
echo "=== clover.xml size and summary ==="
echo "=== clover.xml size and first 10 lines ==="
wc -c tests/logs/clover.xml
head -10 tests/logs/clover.xml
if [ ! -s tests/logs/clover.xml ]; then
Expand Down
Loading