From 932f8bcc07465acb657aadd99e4f89403365fed5 Mon Sep 17 00:00:00 2001 From: Moshe Brodsky <44633930+moshe-autoleadstar@users.noreply.github.com> Date: Fri, 12 Jun 2026 22:19:30 +0300 Subject: [PATCH] consistent sharding logic when no shards file (#1710) --- src/Plugins/Shard.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Shard.php b/src/Plugins/Shard.php index b08dd1dd..8c4fc0d8 100644 --- a/src/Plugins/Shard.php +++ b/src/Plugins/Shard.php @@ -139,7 +139,8 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable self::$timeBalanced = true; self::$shardsOutdated = $newTests !== []; } else { - $testsToRun = (array_chunk($tests, max(1, (int) ceil(count($tests) / $total))))[$index - 1] ?? []; + $isInCurrentShard = fn (int $key) => $key % $total === ($index - 1); + $testsToRun = array_values(array_filter(array_values($tests), $isInCurrentShard, ARRAY_FILTER_USE_KEY)); } self::$shard = [