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
This commit is contained in:
Jonathan Desrosiers 2022-06-20 14:58:45 +00:00
parent 3813f9b2ba
commit ebfc6cdc82

View File

@ -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;
}