From 9cfdfd4ecd9b763c4140203b079405ecd3bb33c5 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 3 Nov 2021 14:54:20 +0000 Subject: [PATCH] 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 --- .github/workflows/coding-standards.yml | 2 ++ .github/workflows/end-to-end-tests.yml | 2 ++ .github/workflows/javascript-tests.yml | 2 ++ .github/workflows/php-compatibility.yml | 2 ++ .github/workflows/phpunit-tests.yml | 2 ++ .github/workflows/slack-notifications.yml | 13 +++++++++---- .github/workflows/test-coverage.yml | 2 ++ .github/workflows/test-npm.yml | 2 ++ .github/workflows/test-old-branches.yml | 2 ++ 9 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 164642e1ad..41faf379ee 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -152,6 +152,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ phpcs, jshint ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.phpcs.result == 'success' && needs.jshint.result == 'success' && 'success' || ( needs.phpcs.result == 'cancelled' || needs.jshint.result == 'cancelled' ) && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 16ad0c0f99..6bcaa9a3ff 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -122,6 +122,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ e2e-tests ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.e2e-tests.result == 'success' && 'success' || needs.e2e-tests.result == 'cancelled' && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index a13a3b095e..4c0c6e17e1 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -91,6 +91,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ test-js ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.test-js.result == 'success' && 'success' || needs.test-js.result == 'cancelled' && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 2121ddeb14..de89b79a3d 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -93,6 +93,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ php-compatibility ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.php-compatibility.result == 'success' && 'success' || needs.php-compatibility.result == 'cancelled' && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index ef328a5761..b6ce31b99b 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -248,6 +248,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ test-php ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.test-php.result == 'success' && 'success' || needs.test-php.result == 'cancelled' && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 0e435eb5b7..ceb06c5fd4 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -23,6 +23,11 @@ on: - '5.[0-8]' workflow_call: + inputs: + calling_status: + description: 'The status of the calling workflow' + type: string + required: true secrets: SLACK_GHA_SUCCESS_WEBHOOK: description: 'The Slack webhook URL for a successful build.' @@ -125,7 +130,7 @@ jobs: name: Failure notifications runs-on: ubuntu-latest needs: [ prepare ] - if: ${{ github.event_name == 'push' && failure() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }} + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' || inputs.calling_status == 'failure' || failure() }} steps: - name: Post failure notifications to Slack @@ -140,7 +145,7 @@ jobs: name: Fixed notifications runs-on: ubuntu-latest needs: [ prepare ] - if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && ( github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' ) }} + if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && ( github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' ) && success() }} steps: - name: Post failure notifications to Slack @@ -155,7 +160,7 @@ jobs: name: Success notifications runs-on: ubuntu-latest needs: [ prepare ] - if: ${{ github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' && success() }} steps: - name: Post success notifications to Slack @@ -170,7 +175,7 @@ jobs: name: Cancelled notifications runs-on: ubuntu-latest needs: [ prepare ] - if: ${{ github.event_name == 'push' && cancelled() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' }} + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' || inputs.calling_status == 'cancelled' || cancelled() }} steps: - name: Post cancelled notifications to Slack diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index cbf18067e9..b11ae0348e 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -174,6 +174,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ test-coverage-report ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.test-coverage-report.result == 'success' && 'success' || needs.test-coverage-report.result == 'cancelled' && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 207882513a..0b49e9ab7c 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -160,6 +160,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ test-npm, test-npm-macos ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + 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' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml index 7051b727d9..1d0bc59a7e 100644 --- a/.github/workflows/test-old-branches.yml +++ b/.github/workflows/test-old-branches.yml @@ -75,6 +75,8 @@ jobs: uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@master needs: [ dispatch-workflows-for-old-branches ] if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} + with: + calling_status: ${{ needs.dispatch-workflows-for-old-branches.result == 'success' && 'success' || needs.dispatch-workflows-for-old-branches.result == 'cancelled' && 'cancelled' || 'failure' }} secrets: SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}