fix(release): retry transient Actions status errors
This commit is contained in:
1 parent
fcf4689f5b
commit
63ea461bef
2 files changed
+56
-11
No files matched your search
+33
-11
@@ -558,18 +558,40 @@ const parseRunId = (output) => {
|
||||
return match ? Number(match[1]) : null;
|
||||
};
|
||||
|
||||
const waitForRun = async ({ repository, runId, label }) => {
|
||||
export const waitForRun = async ({
|
||||
repository,
|
||||
runId,
|
||||
label,
|
||||
viewRun = () => ghJson([
|
||||
"run",
|
||||
"view",
|
||||
String(runId),
|
||||
"--repo",
|
||||
repository,
|
||||
"--json",
|
||||
"status,conclusion,url,headSha",
|
||||
]),
|
||||
waitForNextPoll = () => wait(POLL_INTERVAL_MS),
|
||||
maxConsecutiveFailures = 5,
|
||||
}) => {
|
||||
let lastStatus = "";
|
||||
let consecutiveFailures = 0;
|
||||
while (true) {
|
||||
const runView = ghJson([
|
||||
"run",
|
||||
"view",
|
||||
String(runId),
|
||||
"--repo",
|
||||
repository,
|
||||
"--json",
|
||||
"status,conclusion,url,headSha",
|
||||
]);
|
||||
let runView;
|
||||
try {
|
||||
runView = viewRun();
|
||||
consecutiveFailures = 0;
|
||||
} catch (error) {
|
||||
consecutiveFailures += 1;
|
||||
if (consecutiveFailures >= maxConsecutiveFailures) {
|
||||
throw error;
|
||||
}
|
||||
console.warn(
|
||||
`[release] ${label}: GitHub status check failed; retrying (${consecutiveFailures}/${maxConsecutiveFailures - 1})`,
|
||||
);
|
||||
await waitForNextPoll();
|
||||
continue;
|
||||
}
|
||||
const statusLabel = `${runView.status}${runView.conclusion ? `/${runView.conclusion}` : ""}`;
|
||||
if (statusLabel !== lastStatus) {
|
||||
console.log(`[release] ${label}: ${statusLabel} (${runView.url})`);
|
||||
@@ -581,7 +603,7 @@ const waitForRun = async ({ repository, runId, label }) => {
|
||||
}
|
||||
return runView;
|
||||
}
|
||||
await wait(POLL_INTERVAL_MS);
|
||||
await waitForNextPoll();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
resolveReleaseVersion,
|
||||
reusedAssetMatches,
|
||||
selectPublishedDmg,
|
||||
waitForRun,
|
||||
} from "./release.mjs";
|
||||
|
||||
describe("release automation", () => {
|
||||
@@ -26,6 +27,28 @@ describe("release automation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("retries transient GitHub status failures while waiting for a workflow", async () => {
|
||||
let attempts = 0;
|
||||
let polls = 0;
|
||||
const result = await waitForRun({
|
||||
repository: "tianma-if/edgeever",
|
||||
runId: 123,
|
||||
label: "Draft assets",
|
||||
viewRun: () => {
|
||||
attempts += 1;
|
||||
if (attempts < 3) throw new Error("transient EOF");
|
||||
return { status: "completed", conclusion: "success", url: "https://example.test/run" };
|
||||
},
|
||||
waitForNextPoll: async () => {
|
||||
polls += 1;
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.conclusion).toBe("success");
|
||||
expect(attempts).toBe(3);
|
||||
expect(polls).toBe(2);
|
||||
});
|
||||
|
||||
test("parses paired bilingual changes and labels", () => {
|
||||
expect(
|
||||
parseReleaseArgs([
|
||||
|
||||
Reference in new issue
Block a user