From f7534b10c069fb33c529a6a5cdc699aac8b2dff1 Mon Sep 17 00:00:00 2001 From: ShuaixinHuang <1836656514@qq.com> Date: Thu, 19 Nov 2026 19:14:40 +0800 Subject: [PATCH] fix(ci): continue after an unreadable timing history candidate (#12245) --- scripts/ci/test-history.mjs | 13 +++++++++--- .../boundary/filesystem/ciTestHistory.test.ts | 21 ++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/ci/test-history.mjs b/scripts/ci/test-history.mjs index f14f73873c..18a60ebe44 100644 --- a/scripts/ci/test-history.mjs +++ b/scripts/ci/test-history.mjs @@ -86,9 +86,16 @@ function findTimingRun({ .slice(0, MAX_CANDIDATES); for (const artifact of candidates) { - const run = normalizeWorkflowRun( - api(`repos/${repository}/actions/runs/${artifact.workflow_run.id}`), - ); + let run; + try { + run = normalizeWorkflowRun( + api(`repos/${repository}/actions/runs/${artifact.workflow_run.id}`), + ); + } catch { + // A listed artifact can outlive its run or race a deletion. Its + // lineage remains unverified, but the next candidate may still work. + continue; + } const runAge = now - Date.parse(run?.created_at); if ( typeof run?.created_at === "string" && diff --git a/tests/boundary/filesystem/ciTestHistory.test.ts b/tests/boundary/filesystem/ciTestHistory.test.ts index 9cf82548cb..517560f91f 100644 --- a/tests/boundary/filesystem/ciTestHistory.test.ts +++ b/tests/boundary/filesystem/ciTestHistory.test.ts @@ -74,7 +74,7 @@ async function invoke( ' node -e \'const fs=require("node:fs"); const x=JSON.parse(fs.readFileSync(process.env.GH_FIXTURE_RESPONSE,"utf8")); process.stdout.write(JSON.stringify({artifacts:x.artifacts}));\'', "else", ' run_id="${4##*/}"', - ' node -e \'const fs=require("node:fs"); const x=JSON.parse(fs.readFileSync(process.env.GH_FIXTURE_RESPONSE,"utf8")); process.stdout.write(JSON.stringify(x.runs[Number(process.argv[1])] ?? {}));\' "$run_id"', + ' node -e \'const fs=require("node:fs"); const x=JSON.parse(fs.readFileSync(process.env.GH_FIXTURE_RESPONSE,"utf8")); const run=x.runs[Number(process.argv[1])]; if(run===null){console.error("gh: Not Found (HTTP 404)"); process.exit(1);} process.stdout.write(JSON.stringify(run ?? {}));\' "$run_id"', "fi", "", ].join("\n"), @@ -325,3 +325,22 @@ it("selects full-tier history without using a newer fast artifact", async () => artifact_name: "test-timings-full", }); }); + +it("uses the next valid timing run when one listed run disappears", async () => { + const { result, calls } = await invoke( + [ + artifact(81, { created_at: new Date(now - 30_000).toISOString() }), + artifact(80), + artifact(79), + ], + { 81: null, 80: run(80), 79: run(79) }, + { tier: "full" }, + ); + expect(JSON.parse(result.stdout)).toEqual({ + run_id: "80", + artifact_name: "test-timings-full", + }); + expect(calls).toContain("actions/runs/81"); + expect(calls).toContain("actions/runs/80"); + expect(calls).not.toContain("actions/runs/79"); +});