Skip to content

Commit 577808b

Browse files
authored
Merge pull request #10389 from kkmuffme/fix-ci-tests-chunks
fix CI "split" unevenly splits the number of tests
2 parents 98851b5 + 2c6aa77 commit 577808b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

bin/tests-github-actions.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,23 @@ exit "$exit_code"'
2424
mkdir -p build/parallel/ build/phpunit/logs/
2525

2626
find tests -name '*Test.php' | shuf --random-source=<(get_seeded_random) > build/tests_all
27-
split --number="l/$chunk_number/$chunk_count" build/tests_all > build/tests_split
27+
# split incorrectly splits the lines by byte size, which means that the number of tests per file are as evenly distributed as possible
28+
#split --number="l/$chunk_number/$chunk_count" build/tests_all > build/tests_split
29+
local -r lines=$(wc -l <build/tests_all)
30+
local -r chunk_lines=$(( $lines / $chunk_count ))
31+
local -r rest=$(( $lines % $chunk_count ))
32+
local start_line
33+
local end_line
34+
if [[ $chunk_number -le $rest ]]
35+
then
36+
start_line=$(( ($chunk_number - 1) * $chunk_lines + $chunk_number ))
37+
end_line=$(( $chunk_number * $chunk_lines + $chunk_number ))
38+
else
39+
start_line=$(( ($chunk_number - 1) * $chunk_lines + $rest + 1 ))
40+
end_line=$(( $chunk_number * $chunk_lines + $rest ))
41+
fi
42+
awk "NR==$start_line,NR==$end_line" <build/tests_all > build/tests_split
43+
2844
parallel --group -j"$parallel_processes" --rpl {_}\ s/\\//_/g --joblog build/parallel/jobs.log "$phpunit_cmd" < build/tests_split
2945
}
3046

0 commit comments

Comments
 (0)