Skip to content

Commit 9cfdfd4

Browse files
committed
Build/Test Tools: Pass workflow outcome to Slack Notifications.
When using a workflow as a callable workflow, the job status check functions do not take the called workflow into account. This has caused some failures to be incorrectly reported as successful. This adds an input to the Slack notifications workflow for when the `workflow_call` event is used. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@52002 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 387269d commit 9cfdfd4

9 files changed

Lines changed: 25 additions & 4 deletions

.github/workflows/coding-standards.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ jobs:
152152
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
153153
needs: [ phpcs, jshint ]
154154
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
155+
with:
156+
calling_status: ${{ needs.phpcs.result == 'success' && needs.jshint.result == 'success' && 'success' || ( needs.phpcs.result == 'cancelled' || needs.jshint.result == 'cancelled' ) && 'cancelled' || 'failure' }}
155157
secrets:
156158
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
157159
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/end-to-end-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ jobs:
122122
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
123123
needs: [ e2e-tests ]
124124
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
125+
with:
126+
calling_status: ${{ needs.e2e-tests.result == 'success' && 'success' || needs.e2e-tests.result == 'cancelled' && 'cancelled' || 'failure' }}
125127
secrets:
126128
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
127129
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/javascript-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ jobs:
9191
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
9292
needs: [ test-js ]
9393
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
94+
with:
95+
calling_status: ${{ needs.test-js.result == 'success' && 'success' || needs.test-js.result == 'cancelled' && 'cancelled' || 'failure' }}
9496
secrets:
9597
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
9698
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/php-compatibility.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ jobs:
9393
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
9494
needs: [ php-compatibility ]
9595
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
96+
with:
97+
calling_status: ${{ needs.php-compatibility.result == 'success' && 'success' || needs.php-compatibility.result == 'cancelled' && 'cancelled' || 'failure' }}
9698
secrets:
9799
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
98100
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/phpunit-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ jobs:
248248
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
249249
needs: [ test-php ]
250250
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
251+
with:
252+
calling_status: ${{ needs.test-php.result == 'success' && 'success' || needs.test-php.result == 'cancelled' && 'cancelled' || 'failure' }}
251253
secrets:
252254
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
253255
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/slack-notifications.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
- '5.[0-8]'
2424

2525
workflow_call:
26+
inputs:
27+
calling_status:
28+
description: 'The status of the calling workflow'
29+
type: string
30+
required: true
2631
secrets:
2732
SLACK_GHA_SUCCESS_WEBHOOK:
2833
description: 'The Slack webhook URL for a successful build.'
@@ -125,7 +130,7 @@ jobs:
125130
name: Failure notifications
126131
runs-on: ubuntu-latest
127132
needs: [ prepare ]
128-
if: ${{ github.event_name == 'push' && failure() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }}
133+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' || inputs.calling_status == 'failure' || failure() }}
129134

130135
steps:
131136
- name: Post failure notifications to Slack
@@ -140,7 +145,7 @@ jobs:
140145
name: Fixed notifications
141146
runs-on: ubuntu-latest
142147
needs: [ prepare ]
143-
if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && ( github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' ) }}
148+
if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && ( github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' ) && success() }}
144149

145150
steps:
146151
- name: Post failure notifications to Slack
@@ -155,7 +160,7 @@ jobs:
155160
name: Success notifications
156161
runs-on: ubuntu-latest
157162
needs: [ prepare ]
158-
if: ${{ github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
163+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' && success() }}
159164

160165
steps:
161166
- name: Post success notifications to Slack
@@ -170,7 +175,7 @@ jobs:
170175
name: Cancelled notifications
171176
runs-on: ubuntu-latest
172177
needs: [ prepare ]
173-
if: ${{ github.event_name == 'push' && cancelled() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' }}
178+
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' || inputs.calling_status == 'cancelled' || cancelled() }}
174179

175180
steps:
176181
- name: Post cancelled notifications to Slack

.github/workflows/test-coverage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ jobs:
174174
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
175175
needs: [ test-coverage-report ]
176176
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
177+
with:
178+
calling_status: ${{ needs.test-coverage-report.result == 'success' && 'success' || needs.test-coverage-report.result == 'cancelled' && 'cancelled' || 'failure' }}
177179
secrets:
178180
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
179181
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/test-npm.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ jobs:
160160
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
161161
needs: [ test-npm, test-npm-macos ]
162162
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
163+
with:
164+
calling_status: ${{ needs.test-npm.result == 'success' && needs.test-npm-macos.result == 'success' && 'success' || ( needs.test-npm.result == 'cancelled' || needs.test-npm-macos.result == 'cancelled' ) && 'cancelled' || 'failure' }}
163165
secrets:
164166
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
165167
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

.github/workflows/test-old-branches.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ jobs:
7575
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master
7676
needs: [ dispatch-workflows-for-old-branches ]
7777
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
78+
with:
79+
calling_status: ${{ needs.dispatch-workflows-for-old-branches.result == 'success' && 'success' || needs.dispatch-workflows-for-old-branches.result == 'cancelled' && 'cancelled' || 'failure' }}
7880
secrets:
7981
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
8082
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

0 commit comments

Comments
 (0)