Skip to content
TypeScript

fix(ci): recover from transient download and stale report failures (#22232)

Theo Browneb14ae647a311
diff --git a/.github/scripts/thread-transfer-report.cjs b/.github/scripts/thread-transfer-report.cjs
index a85fec9ee04..5ed6a6ff498 100644
--- a/.github/scripts/thread-transfer-report.cjs
+++ b/.github/scripts/thread-transfer-report.cjs
@@ -244,10 +244,26 @@ async function resolve({ github, context, core }) {
let pullNumber = source.pull_requests?.[0]?.number;
if (!pullNumber) {
- const associated = await github.paginate(
- github.rest.repos.listPullRequestsAssociatedWithCommit,
- { owner, repo, commit_sha: source.head_sha, per_page: 100 },
- );
+ let associated;
+ try {
+ associated = await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, {
+ owner,
+ repo,
+ commit_sha: source.head_sha,
+ per_page: 100,
+ });
+ } catch (error) {
+ // A force-pushed or deleted PR head can disappear before this workflow runs.
+ if (
+ error.status === 422 &&
+ error.response?.data?.message === `No commit found for SHA: ${source.head_sha}`
+ ) {
+ core.info(`Skipping CI result for unavailable commit ${source.head_sha}.`);
+ core.setOutput("publish", "false");
+ return;
+ }
+ throw error;
+ }
const matchingPulls = associated.filter(
(pull) =>
pull.state === "open" &&
diff --git a/.github/scripts/thread-transfer-report.test.cjs b/.github/scripts/thread-transfer-report.test.cjs
index 5b1749fc53f..fa149f6d117 100644
--- a/.github/scripts/thread-transfer-report.test.cjs
+++ b/.github/scripts/thread-transfer-report.test.cjs
@@ -216,6 +216,47 @@ test("does not guess when a fallback commit belongs to multiple PRs", async () =
assert.equal(fetchedPull, false);
});
+test("skips a missing PR commit but preserves other lookup failures", async () => {
+ for (const [status, message, shouldSkip] of [
+ [422, "No commit found for SHA: old-head", true],
+ [422, "Validation Failed", false],
+ [403, "API rate limit exceeded", false],
+ ]) {
+ const outputs = {};
+ const error = Object.assign(new Error(message), {
+ status,
+ response: { data: { message } },
+ });
+ const run = resolve({
+ github: {
+ paginate: async () => {
+ throw error;
+ },
+ rest: { repos: { listPullRequestsAssociatedWithCommit: () => {} } },
+ },
+ context: {
+ repo: { owner: "pingdotgg", repo: "t3code" },
+ payload: {
+ workflow_run: { event: "pull_request", head_sha: "old-head", pull_requests: [] },
+ },
+ },
+ core: {
+ info: () => {},
+ setOutput: (key, value) => {
+ outputs[key] = value;
+ },
+ },
+ });
+ if (shouldSkip) {
+ await run;
+ assert.equal(outputs.publish, "false");
+ } else {
+ await assert.rejects(run, (caught) => caught === error);
+ assert.deepEqual(outputs, {});
+ }
+ }
+});
+
test("does not report a passing run that skipped the server tests", async () => {
const outputs = {};
const listWorkflowRunArtifacts = () => {};
diff --git a/apps/desktop/scripts/ensure-electron-runtime.mjs b/apps/desktop/scripts/ensure-electron-runtime.mjs
index b8b8254c9b3..ae6cd05961b 100644
--- a/apps/desktop/scripts/ensure-electron-runtime.mjs
+++ b/apps/desktop/scripts/ensure-electron-runtime.mjs
@@ -123,6 +123,13 @@ function installElectronRuntime(electronDir, version) {
try {
runChecked("curl", [
"-fsSL",
+ "--retry",
+ "3",
+ "--retry-all-errors",
+ "--connect-timeout",
+ "30",
+ "--max-time",
+ "300",
`https://github.com/electron/electron/releases/download/v${version}/electron-v${version}-${hostPlatform}-${hostArch}.zip`,
"-o",
zipPath,