From f8a9466b93de6ace15b65fdb651e0c151a56fe96 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 7 Oct 2026 02:19:59 -0400 Subject: [PATCH] [Fix] (CI): retrace exit detection tolerates a single failed pidof, and artifact cleanup lists jobs in pages the API serves. --- .github/workflows/apk.yml | 3 ++- .github/workflows/test.yml | 3 ++- android-plugin/trace-replay-ci.sh | 12 ++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml index 15289659..b6c32398 100644 --- a/.github/workflows/apk.yml +++ b/.github/workflows/apk.yml @@ -733,7 +733,8 @@ jobs: GH_TOKEN: ${{ github.token }} run: | # Fail before deletion if either paginated inventory cannot be read. - gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=100" \ + # 50 rows per page: the jobs endpoint answers HTTP 502 for 90+ rows on a re-run attempt of a run this size. + gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=50" \ --jq '.jobs[] | select(.name | startswith("retrace (")) | select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out" or .conclusion == "action_required") | .name' \ > "${RUNNER_TEMP}/cleanup-jobs.txt" gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100" \ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a069e35b..7106e74e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3465,7 +3465,8 @@ jobs: # Read the complete inventories before deleting anything. A failed API # request must fail this step, not look like "no failed cases" through # an unchecked process substitution. - gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=100" \ + # 50 rows per page: the jobs endpoint answers HTTP 502 for 90+ rows on a re-run attempt of a run this size. + gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=50" \ --jq '.jobs[] | select((.name | startswith("retrace (")) or (.name | startswith("retrace verify (")) or (.name | startswith("retrace split ("))) | select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out" or .conclusion == "action_required") | .name' \ > "${RUNNER_TEMP}/cleanup-jobs.txt" gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100" \ diff --git a/android-plugin/trace-replay-ci.sh b/android-plugin/trace-replay-ci.sh index 32b29875..f685da5b 100644 --- a/android-plugin/trace-replay-ci.sh +++ b/android-plugin/trace-replay-ci.sh @@ -511,6 +511,10 @@ run_retrace() { app_exited=0 saw_app_process=0 + # One failed pidof is not an exit: under memory pressure the adb shell call + # itself can fail while the app is alive (seen with the process still in + # pidof and the activity still initializing right after the "exit"). + missed_app_polls=0 poll_started="$(date +%s)" for _ in $(seq 1 "${timeout_seconds}"); do if adb_device_path shell run-as "${package_name}" ls "${app_dir}/output/result.json" >/dev/null 2>&1; then @@ -518,6 +522,7 @@ run_retrace() { fi if adb_device_path shell pidof "${package_name}" >/dev/null 2>&1; then saw_app_process=1 + missed_app_polls=0 else poll_adb_state="$(adb_device_path get-state 2>/dev/null | tr -d '\r' || true)" if [ "${poll_adb_state}" != "device" ]; then @@ -525,8 +530,11 @@ run_retrace() { break fi if [ "${saw_app_process}" -eq 1 ]; then - app_exited=1 - break + missed_app_polls=$((missed_app_polls + 1)) + if [ "${missed_app_polls}" -ge 3 ]; then + app_exited=1 + break + fi fi fi sleep 1