diff --git a/.github/workflows/scripts/rerunFlakyTests.js b/.github/workflows/scripts/rerunFlakyTests.js index 3e7630f8f6..dd7e653756 100644 --- a/.github/workflows/scripts/rerunFlakyTests.js +++ b/.github/workflows/scripts/rerunFlakyTests.js @@ -16,10 +16,7 @@ async function getFailedJobsForRun(github, context, workflowRunId, runAttempt) { }); return jobs - .filter((job) => job.conclusion === "failure") - .filter((job) => - CONSIDERED_JOBS.some((title) => job.name.startsWith(title)) - ); + .filter((job) => job.conclusion === "failure"); } export async function rerunFlakyTests({ github, context }) { @@ -35,12 +32,14 @@ export async function rerunFlakyTests({ github, context }) { return; } - if (failingJobs.length === 0) { - throw new Error( - "rerunFlakyTests should not have run on a run with no failing jobs" - ); + const filteredFailingJobs = failingJobs.filter((job) => CONSIDERED_JOBS.some((title) => job.name.startsWith(title))); + if (filteredFailingJobs.length === 0) { + console.log("Failing jobs are NOT designated flaky. Not rerunning."); + return; } + console.log(`Rerunning job: ${filteredFailingJobs[0].name}`); + github.rest.actions.reRunWorkflowFailedJobs({ owner: context.repo.owner, repo: context.repo.repo,