Skip to content

Commit dde70b8

Browse files
schlesseraclaude
andauthored
Collect coverage with Xdebug when the locked php-code-coverage cannot use PCOV (#317)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a7e2b75 commit dde70b8

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎.github/workflows/reusable-testing.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,24 @@ jobs:
523523
SHARDS=$(( (SCENARIOS + SCENARIOS_PER_SHARD - 1) / SCENARIOS_PER_SHARD ))
524524
SHARDS=$(( SHARDS < 1 ? 1 : SHARDS > COVERAGE_SHARDS ? COVERAGE_SHARDS : SHARDS ))
525525
echo "Splitting the Behat tests with code coverage across ${SHARDS} runners, for ${SCENARIOS} scenarios."
526-
COVERAGE=$(jq -c --argjson shards "${SHARDS}" '
526+
527+
# PCOV needs phpunit/php-code-coverage 9.1 or later, which picks the driver that is
528+
# loaded. Older versions, as locked by a package that supports PHP 7.2, only use Xdebug.
529+
DRIVER=pcov
530+
if [ -f composer.lock ]; then
531+
LOCKED=$(jq -r '[.packages[]?, .["packages-dev"][]? | select(.name == "phpunit/php-code-coverage") | .version][0] // empty' composer.lock)
532+
LOCKED=${LOCKED#v}
533+
if [ -n "${LOCKED}" ] && [ "$(printf '%s\n' "${LOCKED}" 9.1 | sort -V | head -n 1)" != 9.1 ]; then
534+
echo "Collecting code coverage with Xdebug, as composer.lock has phpunit/php-code-coverage ${LOCKED}."
535+
DRIVER=xdebug
536+
fi
537+
fi
538+
539+
COVERAGE=$(jq -c --argjson shards "${SHARDS}" --arg driver "${DRIVER}" '
527540
[
528541
.include[] | select(.coverage == true) | . as $entry |
529542
($entry.coverage_shards // $shards) as $total |
543+
($entry | .coverage_driver //= $driver) as $entry |
530544
if $total > 1 then
531545
range(1; $total + 1) | $entry + { shard: "\(.)/\($total)" }
532546
else

0 commit comments

Comments
 (0)