Fix rerunFlakyTests

This commit is contained in:
Jordan Dominion
2024-04-20 18:00:45 -04:00
parent e98da28130
commit 153032153d
+7 -8
View File
@@ -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,