@@ -436,79 +436,102 @@ jobs:
436436 set -euo pipefail
437437
438438 REPO="${GITHUB_REPOSITORY}"
439- SHA="${GITHUB_SHA}"
440439 WORKDIR=$(mktemp -d)
441440 trap 'rm -rf "${WORKDIR}"' EXIT
442441
443- # Fetch all workflow runs associated with this commit (up to 100)
444- all_runs=$(gh api \
445- "repos/${REPO}/actions/runs?head_sha=${SHA}&per_page=100" \
446- --jq '.workflow_runs[]')
447-
448- # Identify child runs by their workflow file path; test-wheel-linux.yml
449- # covers both linux-64 and linux-aarch64 (two separate runs).
450- TEST_WORKFLOW_PATHS=(
451- ".github/workflows/test-sdist-linux.yml"
452- ".github/workflows/test-sdist-windows.yml"
453- ".github/workflows/test-wheel-linux.yml"
454- ".github/workflows/test-wheel-windows.yml"
442+ mkdir -p "${WORKDIR}/configs"
443+
444+ # Collect all jobs for this run and group matrix jobs into the five
445+ # top-level test configurations from ci.yml.
446+ jobs_json=$(gh api --paginate \
447+ "repos/${REPO}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=100" \
448+ | jq -s '[.[].jobs[]]')
449+
450+ declare -A CONFIG_PATTERNS=(
451+ [test-sdist-linux]='^Test sdist linux-64 / '
452+ [test-sdist-windows]='^Test sdist win-64 / '
453+ [test-linux-64]='^Test linux-64 / '
454+ [test-linux-aarch64]='^Test linux-aarch64 / '
455+ [test-windows]='^Test (win-64|windows) / '
455456 )
456457
457- mkdir -p "${WORKDIR}/configs"
458- config_index=0
459-
460- for wf_path in "${TEST_WORKFLOW_PATHS[@]}"; do
461- run_ids=$(echo "${all_runs}" | jq -r \
462- --arg p "${wf_path}" \
463- 'select(.path == $p) | .id')
464- for run_id in ${run_ids}; do
465- run_name=$(echo "${all_runs}" | jq -r \
466- --argjson id "${run_id}" 'select(.id == $id) | .name' | head -1)
467- echo "Fetching logs for: ${run_name} (id=${run_id})"
468- config_dir="${WORKDIR}/configs/${config_index}"
469- mkdir -p "${config_dir}"
470-
471- if gh api "repos/${REPO}/actions/runs/${run_id}/logs" \
472- > "${config_dir}/logs.zip" 2>/dev/null; then
473- unzip -q "${config_dir}/logs.zip" -d "${config_dir}/logs" 2>/dev/null || true
474- # Extract test IDs from lines matching the pytest SKIPPED output format
475- grep -rh ' SKIPPED' "${config_dir}/logs/" 2>/dev/null \
476- | grep -oE '[^[:space:]]+\.py::[^[:space:]]+ SKIPPED' \
477- | sed 's/ SKIPPED$//' \
478- | sort -u > "${config_dir}/skipped.txt" || true
479- echo " -> $(wc -l < "${config_dir}/skipped.txt") skipped tests"
480- config_index=$((config_index + 1))
481- else
482- echo " -> could not download logs (run may be skipped or unavailable)" >&2
483- rm -rf "${config_dir}"
484- fi
458+ configs=(
459+ test-sdist-linux
460+ test-sdist-windows
461+ test-linux-64
462+ test-linux-aarch64
463+ test-windows
464+ )
465+
466+ for cfg in "${configs[@]}"; do
467+ cfg_dir="${WORKDIR}/configs/${cfg}"
468+ mkdir -p "${cfg_dir}/logs"
469+ job_ids=$(echo "${jobs_json}" | jq -r \
470+ --arg pat "${CONFIG_PATTERNS[$cfg]}" \
471+ '.[] | select(.name | test($pat)) | .id')
472+
473+ if [[ -z "${job_ids}" ]]; then
474+ echo "No matrix jobs found for ${cfg}" >&2
475+ : > "${cfg_dir}/skipped.txt"
476+ continue
477+ fi
478+
479+ for job_id in ${job_ids}; do
480+ logfile="${cfg_dir}/logs/${job_id}.log"
481+ # gh run view handles log retrieval for a job ID reliably.
482+ gh run view "${GITHUB_RUN_ID}" --job "${job_id}" --log > "${logfile}" || true
485483 done
484+
485+ # Extract test IDs from lines matching pytest SKIPPED output.
486+ grep -h ' SKIPPED' "${cfg_dir}/logs/"*.log 2>/dev/null \
487+ | grep -oE '[^[:space:]]+\.py::[^[:space:]]+ SKIPPED' \
488+ | sed 's/ SKIPPED$//' \
489+ | sort -u > "${cfg_dir}/skipped.txt" || true
490+
491+ echo "${cfg}: $(wc -l < "${cfg_dir}/skipped.txt") skipped tests"
486492 done
487493
488494 {
489495 echo "## Universally-skipped tests"
490496 echo ""
491497 } >> "${GITHUB_STEP_SUMMARY}"
492498
493- if [[ ${config_index} -eq 0 ]]; then
494- echo "_No test run logs found._" >> "${GITHUB_STEP_SUMMARY}"
499+ available_configs=0
500+ missing_configs=()
501+ for cfg in "${configs[@]}"; do
502+ if [[ -s "${WORKDIR}/configs/${cfg}/skipped.txt" || -n "$(ls -A "${WORKDIR}/configs/${cfg}/logs" 2>/dev/null || true)" ]]; then
503+ available_configs=$((available_configs + 1))
504+ else
505+ missing_configs+=("${cfg}")
506+ fi
507+ done
508+
509+ if [[ ${available_configs} -eq 0 ]]; then
510+ echo "_No test job logs found in this run._" >> "${GITHUB_STEP_SUMMARY}"
495511 exit 0
496512 fi
497513
498- # Start the intersection from the first config and progressively
499- # narrow it down to only tests that appear in every config's list.
500- cp "${WORKDIR}/configs/0/skipped.txt" "${WORKDIR}/intersection.txt"
501- for i in $(seq 1 $((config_index - 1))); do
514+ if [[ ${#missing_configs[@]} -gt 0 ]]; then
515+ {
516+ echo "_Warning: missing logs for configuration(s): ${missing_configs[*]}_"
517+ echo ""
518+ } >> "${GITHUB_STEP_SUMMARY}"
519+ fi
520+
521+ # Start intersection from first config, then narrow with each of the
522+ # remaining four configurations.
523+ cp "${WORKDIR}/configs/${configs[0]}/skipped.txt" "${WORKDIR}/intersection.txt"
524+ for cfg in "${configs[@]:1}"; do
502525 comm -12 \
503526 "${WORKDIR}/intersection.txt" \
504- "${WORKDIR}/configs/${i }/skipped.txt" \
527+ "${WORKDIR}/configs/${cfg }/skipped.txt" \
505528 > "${WORKDIR}/intersection_new.txt"
506529 mv "${WORKDIR}/intersection_new.txt" "${WORKDIR}/intersection.txt"
507530 done
508531
509532 count=$(wc -l < "${WORKDIR}/intersection.txt")
510533 {
511- echo "Tests skipped across all ${config_index} test configuration(s) :"
534+ echo "Tests skipped across all five test configurations :"
512535 echo ""
513536 if [[ ${count} -eq 0 ]]; then
514537 echo "_No tests were skipped in all configurations._"
0 commit comments