Build/Test Tools: Post a message to #core in Slack when a workflow fails.

This adds an additional step to each GitHub Action workflow file that posts a message to #core in Slack every time a workflow run fails.

A minor test and spacing change is included in this commit in order to that messages are posted correctly and will be reverted after testing.

See #52644.

git-svn-id: https://develop.svn.wordpress.org/trunk@51511 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2021-07-29 19:47:43 +00:00
parent 2905c5a9bc
commit 7a60b8eb8b
11 changed files with 174 additions and 9 deletions
+19 -2
View File
@@ -56,7 +56,6 @@ jobs:
# - Runs PHPCS on the full codebase with warnings suppressed.
# - Runs PHPCS on the `tests` directory without warnings suppressed.
# - Ensures version-controlled files are not modified or deleted.
# - todo: Configure Slack notifications for failing scans.
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
@@ -110,7 +109,6 @@ jobs:
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Run the WordPress JSHint checks.
# - Ensures version-controlled files are not modified or deleted.
# - todo: Configure Slack notifications for failing tests.
jshint:
name: JavaScript coding standards
runs-on: ubuntu-latest
@@ -148,3 +146,22 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ phpcs, jshint ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+19 -1
View File
@@ -46,7 +46,6 @@ jobs:
# - Install WordPress within the Docker container.
# - Run the E2E tests.
# - Ensures version-controlled files are not modified or deleted.
# - todo: Configure Slack notifications for failing tests.
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
@@ -117,3 +116,22 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ e2e-tests ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+19 -1
View File
@@ -50,7 +50,6 @@ jobs:
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Run the WordPress QUnit tests.
# - Ensures version-controlled files are not modified or deleted.
# - todo: Configure Slack notifications for failing tests.
test-js:
name: QUnit Tests
runs-on: ubuntu-latest
@@ -86,3 +85,22 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ test-js ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+20 -2
View File
@@ -50,8 +50,7 @@ jobs:
# - Logs PHP_CodeSniffer debug information.
# - Runs the PHP compatibility tests.
# - Ensures version-controlled files are not modified or deleted.
# - todo: Configure Slack notifications for failing scans.
php-comatibility:
php-compatibility:
name: Check PHP compatibility
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
@@ -88,3 +87,22 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ php-compatibility ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+19 -1
View File
@@ -59,7 +59,6 @@ jobs:
# - Checks out the WordPress Test reporter repository.
# - Reconnect the directory to the Git repository.
# - Submit the test results to the WordPress.org host test results.
# - todo: Configure Slack notifications for failing tests.
test-php:
name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
@@ -237,3 +236,22 @@ jobs:
env:
WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ test-php ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+19
View File
@@ -146,3 +146,22 @@ jobs:
with:
file: wp-code-coverage-multisite-clover-${{ github.sha }}.xml
flags: multisite,php
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ test-coverage-report ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+19
View File
@@ -154,3 +154,22 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted during building and cleaning
run: git diff --exit-code
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ test-npm, test-npm-macos ]
if: ${{ failure() && github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
+19
View File
@@ -69,3 +69,22 @@ jobs:
workflow_id: '${{ matrix.workflow }}',
ref: '${{ matrix.branch }}'
});
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ dispatch-workflows-for-old-branches ]
if: ${{ failure() }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}
@@ -57,3 +57,22 @@ jobs:
Thank you,
The WordPress Project
# Post workflow related status updates to Slack.
#
# When a job in this workflow fails, a message is posted to #core.
#
# This job should always require all other jobs in this workflow to complete before running.
slack-notifications:
name: Slack Notifications
runs-on: ubuntu-latest
needs: [ post-welcome-message ]
if: ${{ failure() }}
steps:
- name: Post failure notification to Slack
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
with:
payload: "{\"workflow_name\":\"${{ github.workflow }}\",\"run_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_WEBHOOK_URL }}