ci: shard pr-core Gloo tests across two duration-balanced processes

Split the selected test files into two Gloo shards by deterministic
longest-first assignment over a committed duration table measured from
CI JUnit. Every selected file lands in exactly one shard, so unlisted
Gloo files still run. pr-core now runs three concurrent pytest
processes with the same exit-code, empty-side, artifact and coverage
combine rules; an empty shard never invokes pytest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Joseph MaglyandClaude Opus 5.5 committed 2026-10-07 15:39:58 -04:00
1 parent 23533b7fe2
commit 8681ef718b
9 files changed
+487 -76

No files matched your search

+59 -27
View File
@@ -290,21 +290,49 @@ jobs:
marker_expression="not slow and not gpu and not mps and not mlx and not network and not download and not remote and not operator_ui"
# Suppress the configured terminal report, retaining strictness and source scope.
pytest_addopts="--strict-config --strict-markers --cov=obliteratus"
# Keep concurrent pytest/subprocess coverage and temp roots isolated until both finish.
rm -f test-results/.coverage test-results/.coverage.gloo test-results/.coverage.core
COVERAGE_FILE=test-results/.coverage.gloo "$TEST_ENV/bin/python" -m pytest \
"${selected_tests[@]}" \
-o "addopts=$pytest_addopts" \
-m "$marker_expression and gloo" \
--cov=app \
--cov-branch \
--cov-fail-under=0 \
--cov-config=pyproject.toml \
--cov-report= \
--junitxml=test-results/junit-pr-core-gloo.xml \
--basetemp="$RUNNER_TEMP/pytest-pr-core-gloo" \
> test-results/pytest-pr-core-gloo.log 2>&1 &
gloo_pid=$!
"$TEST_ENV/bin/python" scripts/shard_pr_tests.py
mapfile -t gloo0_tests < test-results/selected-gloo-0.txt
mapfile -t gloo1_tests < test-results/selected-gloo-1.txt
# Isolate concurrent coverage and temp roots until all three finish.
rm -f test-results/.coverage test-results/.coverage.gloo0 test-results/.coverage.gloo1 test-results/.coverage.core
(
if [ "${#gloo0_tests[@]}" -eq 0 ]; then
echo "Empty Gloo shard 0; pytest not invoked (exit code 5)"
printf '<testsuites><testsuite name="gloo0" tests="0"/></testsuites>\n' > test-results/junit-pr-core-gloo-0.xml
exit 5
fi
COVERAGE_FILE=test-results/.coverage.gloo0 "$TEST_ENV/bin/python" -m pytest \
"${gloo0_tests[@]}" \
-o "addopts=$pytest_addopts" \
-m "$marker_expression and gloo" \
--cov=app \
--cov-branch \
--cov-fail-under=0 \
--cov-config=pyproject.toml \
--cov-report= \
--junitxml=test-results/junit-pr-core-gloo-0.xml \
--basetemp="$RUNNER_TEMP/pytest-pr-core-gloo0"
) > test-results/pytest-pr-core-gloo0.log 2>&1 &
gloo0_pid=$!
(
if [ "${#gloo1_tests[@]}" -eq 0 ]; then
echo "Empty Gloo shard 1; pytest not invoked (exit code 5)"
printf '<testsuites><testsuite name="gloo1" tests="0"/></testsuites>\n' > test-results/junit-pr-core-gloo-1.xml
exit 5
fi
COVERAGE_FILE=test-results/.coverage.gloo1 "$TEST_ENV/bin/python" -m pytest \
"${gloo1_tests[@]}" \
-o "addopts=$pytest_addopts" \
-m "$marker_expression and gloo" \
--cov=app \
--cov-branch \
--cov-fail-under=0 \
--cov-config=pyproject.toml \
--cov-report= \
--junitxml=test-results/junit-pr-core-gloo-1.xml \
--basetemp="$RUNNER_TEMP/pytest-pr-core-gloo1"
) > test-results/pytest-pr-core-gloo1.log 2>&1 &
gloo1_pid=$!
COVERAGE_FILE=test-results/.coverage.core "$TEST_ENV/bin/python" -m pytest \
"${selected_tests[@]}" \
-o "addopts=$pytest_addopts" \
@@ -315,36 +343,40 @@ jobs:
--cov-config=pyproject.toml \
--cov-report= \
--junitxml=test-results/junit-pr-core.xml \
--basetemp="$RUNNER_TEMP/pytest-pr-core" \
> test-results/pytest-pr-core.log 2>&1 &
--basetemp="$RUNNER_TEMP/pytest-pr-core-core" \
> test-results/pytest-pr-core-core.log 2>&1 &
core_pid=$!
# Conditional waits preserve each status under GitHub's bash -e shell.
gloo_status=0
wait "$gloo_pid" || gloo_status=$?
gloo0_status=0
wait "$gloo0_pid" || gloo0_status=$?
gloo1_status=0
wait "$gloo1_pid" || gloo1_status=$?
core_status=0
wait "$core_pid" || core_status=$?
echo "Gloo pytest exit code: $gloo_status"
cat test-results/pytest-pr-core-gloo.log
echo "Gloo shard 0 pytest exit code: $gloo0_status"
cat test-results/pytest-pr-core-gloo0.log
echo "Gloo shard 1 pytest exit code: $gloo1_status"
cat test-results/pytest-pr-core-gloo1.log
echo "Core pytest exit code: $core_status"
cat test-results/pytest-pr-core.log
if (( (gloo_status != 0 && gloo_status != 5) || (core_status != 0 && core_status != 5) )); then
cat test-results/pytest-pr-core-core.log
if (( (gloo0_status != 0 && gloo0_status != 5) || (gloo1_status != 0 && gloo1_status != 5) || (core_status != 0 && core_status != 5) )); then
exit 1
fi
if (( gloo_status == 5 && core_status == 5 )); then
echo "Neither pytest process ran any tests"
if (( gloo0_status == 5 && gloo1_status == 5 && core_status == 5 )); then
echo "No pytest process ran any tests"
exit 1
fi
# An empty partition may not write data. Combine only existing files.
coverage_files=()
for coverage_file in test-results/.coverage.gloo test-results/.coverage.core; do
for coverage_file in test-results/.coverage.gloo0 test-results/.coverage.gloo1 test-results/.coverage.core; do
if [ -f "$coverage_file" ]; then
coverage_files+=("$coverage_file")
fi
done
if [ "${#coverage_files[@]}" -eq 0 ]; then
echo "Neither pytest process produced coverage data"
echo "No pytest process produced coverage data"
exit 1
fi
export COVERAGE_FILE=test-results/.coverage