From 47e7c8e01a5e3ff36e615a7118cf61a017d09c6c Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Sun, 5 Jun 2022 09:29:53 +0000 Subject: [PATCH] =?UTF-8?q?Build/Test=20Tools:=20Prevent=20inaccurate=20?= =?UTF-8?q?=E2=80=9Cfixed=E2=80=9D=20notifications=20in=20Slack.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When searching for previous workflow runs by branch, GitHub currently includes matches within forks. If a contributor opens a pull request from their fork with a `head_ref` matching a Core branch that triggers a workflow on `push` event, the outcomes of the workflows associated with that pull request are currently used to determine if the previous workflow run had failed. The result is a false “fixed” notifications when a commit immediately follows a failed workflow run from the pull request. This adds a check to skip any workflow runs not triggered by a `push` event to prevent these inaccurate notifications. Props SergeyBiryukov. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53466 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/slack-notifications.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 9db209ddea..969d8b067e 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -114,6 +114,11 @@ jobs: // Find the workflow run for the commit that immediately preceded this one. for ( let i = 0; i < previous_runs.data.workflow_runs.length; i++ ) { + // Protects against false notifications when contributors use similar head_ref names. + if ( previous_runs.data.workflow_runs[ i ].event !== "push" ) { + continue; + } + if ( previous_runs.data.workflow_runs[ i ].run_number == workflow_run.data.run_number ) { return previous_runs.data.workflow_runs[ i + 1 ].conclusion; }