Skip to content

Commit 30901c0

Browse files
chore: logic update
1 parent 58ea105 commit 30901c0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/collector/scripts/ci-get-test-files.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,21 @@ IFS=$'\n' sorted=($(printf "%s\n" $files | sort))
2929
unset IFS
3030

3131
total=${#sorted[@]}
32-
perGroup=$(( (total + MAX_SPLIT - 1) / MAX_SPLIT ))
33-
start=$(( (SPLIT - 1) * perGroup ))
3432

35-
for ((i = start; i < start + perGroup && i < total; i++)); do
33+
# Calculate files per group using floor division
34+
# This ensures more even distribution across all splits
35+
perGroup=$(( total / MAX_SPLIT ))
36+
37+
remainder=$(( total % MAX_SPLIT ))
38+
39+
if [ $SPLIT -le $remainder ]; then
40+
start=$(( (SPLIT - 1) * (perGroup + 1) ))
41+
count=$(( perGroup + 1 ))
42+
else
43+
start=$(( remainder * (perGroup + 1) + (SPLIT - remainder - 1) * perGroup ))
44+
count=$perGroup
45+
fi
46+
47+
for ((i = start; i < start + count && i < total; i++)); do
3648
echo "${sorted[$i]}"
3749
done

0 commit comments

Comments
 (0)