From d23825abe86ce210aa03a8ff41b3aa393753dc85 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 26 May 2025 09:44:44 +0200 Subject: [PATCH] workflows/eval: skip on ready_for_review We don't need to run full eval when undrafting a PR. We already have an eval result, so we can use that to do the maintainer pings. We need to wait for eval to finish first, but we're already half there because of how we're waiting for the artifact to appear. Since the ready_for_review case is triggered in a different workflow run, we'll need to fetch the ID of the relevant Eval workflow first, though. (cherry picked from commit 83700242038485a49750f4a8f722389fa325b2c0) (cherry picked from commit 1166640be9a207f5707324215752a727ab3c167b) --- .github/workflows/eval.yml | 2 +- .github/workflows/reviewers.yml | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml index 0aa475c4c1e1..ccf54af04e32 100644 --- a/.github/workflows/eval.yml +++ b/.github/workflows/eval.yml @@ -4,8 +4,8 @@ on: pull_request: paths: - .github/workflows/eval.yml + - .github/workflows/reviews.yml # needs eval results from the same event type pull_request_target: - types: [opened, ready_for_review, synchronize, reopened] push: # Keep this synced with ci/request-reviews/dev-branches.txt branches: diff --git a/.github/workflows/reviewers.yml b/.github/workflows/reviewers.yml index 141541c57330..62c8f242164b 100644 --- a/.github/workflows/reviewers.yml +++ b/.github/workflows/reviewers.yml @@ -4,6 +4,11 @@ name: Reviewers on: + pull_request: + paths: + - .github/workflows/reviewers.yml + pull_request_target: + types: [ready_for_review] workflow_call: permissions: {} @@ -39,16 +44,29 @@ jobs: permission-members: read permission-pull-requests: write + + # In the regular case, this workflow is called via workflow_call from the eval workflow directly. + # In the more special case, when a PR is undrafted an eval run will have started already. - name: Wait for comparison to be done uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: | - // Waiting 24 * 5 sec = 2 min. max. - for (let i = 0; i < 24; i++) { + const run_id = (await github.rest.actions.listWorkflowRuns({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'eval.yml', + event: context.eventName, + head_sha: context.payload.pull_request.head.sha + })).data.workflow_runs[0].id + + // Waiting 120 * 5 sec = 10 min. max. + // The extreme case is an Eval run that just started when the PR is undrafted. + // Eval takes max 5-6 minutes, normally. + for (let i = 0; i < 120; i++) { const result = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, - run_id: context.runId, + run_id, name: 'comparison' }) if (result.data.total_count > 0) return