From ebfc6cdc82126d1fd7d4988402db03d7146259d3 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Mon, 20 Jun 2022 14:58:45 +0000 Subject: [PATCH] Build/Test Tools: Adjust Slack notifications logic to account for expected non `push` events. This adjusts the logic used to determine the outcome of the previous workflow run of the current one to account for `schedule` and `workflow_dispatch` events. In the current state, only workflows triggered by `push` events are examined. This is causing failures when trying to post Slack notifications for the Test Coverage workflow, and inconsistent results for `workflow_dispatch` events when testing older branches on a schedule. Follow up to [53466] and [53468]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53534 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/slack-notifications.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 1ae927ac0c..383d846683 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -112,6 +112,8 @@ jobs: return 'none'; } + const expected_events = new Array( 'push', 'schedule', 'workflow_dispatch' ); + // Find the workflow run for the commit that immediately preceded this one. for ( let i = 0; i < previous_runs.data.workflow_runs.length; i++ ) { if ( previous_runs.data.workflow_runs[ i ].run_number == workflow_run.data.run_number ) { @@ -120,7 +122,7 @@ jobs: next_index++; // Protects against a false notification when contributors use the trunk branch as the pull request head_ref. - if ( previous_runs.data.workflow_runs[ next_index ].event !== "push" ) { + if ( expected_events.indexOf( previous_runs.data.workflow_runs[ next_index ].event ) == -1 ) { continue; }