diff --git a/.github/workflows/mypy_primer_comment.yml b/.github/workflows/mypy_primer_comment.yml index 2acfff7b3..4cc699f35 100644 --- a/.github/workflows/mypy_primer_comment.yml +++ b/.github/workflows/mypy_primer_comment.yml @@ -47,14 +47,17 @@ jobs: workflow_id: "mypy_primer.yml", }) if (response) { - return response.data.workflow_runs.find(run => run.head_sha == pr_commit_sha) + workflow_runs = response.data.workflow_runs + // Sort by reverse updated_at + workflow_runs.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()) + return workflow_runs.find(run => run.head_sha == pr_commit_sha) } return undefined } const end_time = Number(new Date()) + 60 * 60 * 1000 let primer_run = await check_mypy_primer() - while (!primer_run || primer_run.status != "completed") { + while (!primer_run || primer_run.status != "completed" || primer_run.conclusion != "success") { if (Number(new Date()) > end_time) { throw Error("Timed out waiting for mypy_primer") }