File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments