mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Build/Test Tools: Expand Slack notifications for GitHub Actions.
This expands Slack notifications to include success, cancelled, and “fixed” GitHub Action workflow run outcomes in addition to failures. A “fixed” outcome occurs when the previous run for a workflow failed and the current one succeeds. This matches the behavior that was native to TravisCI by setting `on_success` for notifications to `change`. The message details and where each outcome is posted is controlled by Slack workflows. The Slack notification logic has also been pulled into a separate workflow to prevent repeating code in every workflow. See #52644. git-svn-id: https://develop.svn.wordpress.org/trunk@51535 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
19
.github/workflows/coding-standards.yml
vendored
19
.github/workflows/coding-standards.yml
vendored
@@ -146,22 +146,3 @@ 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
.github/workflows/end-to-end-tests.yml
vendored
19
.github/workflows/end-to-end-tests.yml
vendored
@@ -116,22 +116,3 @@ 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
.github/workflows/javascript-tests.yml
vendored
19
.github/workflows/javascript-tests.yml
vendored
@@ -85,22 +85,3 @@ 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 }}
|
||||
|
||||
19
.github/workflows/php-compatibility.yml
vendored
19
.github/workflows/php-compatibility.yml
vendored
@@ -87,22 +87,3 @@ 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
.github/workflows/phpunit-tests.yml
vendored
19
.github/workflows/phpunit-tests.yml
vendored
@@ -236,22 +236,3 @@ 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 }}
|
||||
|
||||
121
.github/workflows/slack-notifications.yml
vendored
Normal file
121
.github/workflows/slack-notifications.yml
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
##
|
||||
# Posts messages to the Making WordPress Core Slack Instance by
|
||||
# submitting data to Slack webhook URLs received by Slack Workflows.
|
||||
##
|
||||
name: Slack Notifications
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- Code Coverage Report
|
||||
- Coding Standards
|
||||
- End-to-end Tests
|
||||
- JavaScript Tests
|
||||
- PHP Compatibility
|
||||
- PHPUnit Tests
|
||||
- Test NPM
|
||||
- Test old branches
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
# Gathers the details needed for Slack notifications.
|
||||
#
|
||||
# These details are passed as outputs to the subsequent, dependant jobs that
|
||||
# submit data to Slack webhook URLs configured to post messages.
|
||||
#
|
||||
# Performs the following steps:
|
||||
# - Retrieves the previous workflow run and stores its conclusion.
|
||||
# - Sets the previous conclusion as an output.
|
||||
# - Constructs and stores a message payload as an output.
|
||||
prepare:
|
||||
name: Prepare notifications
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event.workflow_run.conclusion != 'skipped' && github.event_name != 'pull_request' }}
|
||||
outputs:
|
||||
previous_conclusion: ${{ steps.previous-conclusion.outputs.previous_conclusion }}
|
||||
payload: ${{ steps.create-payload.outputs.payload }}
|
||||
|
||||
steps:
|
||||
- name: Get details about the workflow
|
||||
id: previous-result
|
||||
uses: actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293 # v4.0.2
|
||||
with:
|
||||
script: |
|
||||
const workflow_runs = await github.actions.listWorkflowRuns({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
workflow_id: ${{ github.event.workflow_run.workflow_id }},
|
||||
branch: '${{ github.event.workflow_run.head_branch }}',
|
||||
per_page: 1,
|
||||
page: 2,
|
||||
});
|
||||
return workflow_runs.data.workflow_runs[0].conclusion;
|
||||
|
||||
- name: Store previous conclusion as an output
|
||||
id: previous-conclusion
|
||||
run: echo "::set-output name=previous_conclusion::${{ steps.previous-result.outputs.result }}"
|
||||
|
||||
- name: Construct payload and store as an output
|
||||
id: create-payload
|
||||
run: echo "::set-output name=payload::\"{\"workflow_name\":\"${{ github.event.workflow_run.name }}\",\"ref_name\":\"${{ github.event.workflow_run.head_branch }}\",\"run_url\":\"${{ github.event.workflow_run.html_url }}\"}\""
|
||||
|
||||
# Posts notifications when a workflow fails.
|
||||
failure:
|
||||
name: Failure notifications
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ prepare ]
|
||||
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
||||
|
||||
steps:
|
||||
- name: Post failure notifications to Slack
|
||||
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
|
||||
with:
|
||||
payload: ${{ needs.prepare.outputs.payload }}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
|
||||
|
||||
# Posts notifications the first time a workflow run succeeds after previously failing.
|
||||
fixed:
|
||||
name: Fixed notifications
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ prepare ]
|
||||
if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && github.event.workflow_run.conclusion == 'success' }}
|
||||
|
||||
steps:
|
||||
- name: Post failure notifications to Slack
|
||||
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
|
||||
with:
|
||||
payload: ${{ needs.prepare.outputs.payload }}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
|
||||
|
||||
# Posts notifications when a workflow is successful.
|
||||
success:
|
||||
name: Success notifications
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ prepare ]
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
|
||||
steps:
|
||||
- name: Post success notifications to Slack
|
||||
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
|
||||
with:
|
||||
payload: ${{ needs.prepare.outputs.payload }}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
|
||||
|
||||
# Posts notifications when a workflow is cancelled.
|
||||
cancelled:
|
||||
name: Cancelled notifications
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ prepare ]
|
||||
if: ${{ github.event.workflow_run.conclusion == 'cancelled' }}
|
||||
|
||||
steps:
|
||||
- name: Post cancelled notifications to Slack
|
||||
uses: slackapi/slack-github-action@d5d276d7ae0f38f29322b80da9baf985cc80f8b1 # v1.15.0
|
||||
with:
|
||||
payload: ${{ needs.prepare.outputs.payload }}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
|
||||
19
.github/workflows/test-coverage.yml
vendored
19
.github/workflows/test-coverage.yml
vendored
@@ -146,22 +146,3 @@ 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
.github/workflows/test-npm.yml
vendored
19
.github/workflows/test-npm.yml
vendored
@@ -154,22 +154,3 @@ 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
.github/workflows/test-old-branches.yml
vendored
19
.github/workflows/test-old-branches.yml
vendored
@@ -69,22 +69,3 @@ 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 }}
|
||||
|
||||
19
.github/workflows/welcome-new-contributors.yml
vendored
19
.github/workflows/welcome-new-contributors.yml
vendored
@@ -57,22 +57,3 @@ 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 }}
|
||||
|
||||
@@ -60,7 +60,7 @@ function _get_cron_lock() {
|
||||
global $wpdb;
|
||||
|
||||
$value = 0;
|
||||
if ( wp_using_ext_object_cache() ) {
|
||||
if (wp_using_ext_object_cache()) {
|
||||
/*
|
||||
* Skip local cache and force re-fetch of doing_cron transient
|
||||
* in case another process updated the cache.
|
||||
|
||||
@@ -27,7 +27,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertSame( array(), wp_parse_args( $a ) );
|
||||
$b = array(
|
||||
'_baba' => 5,
|
||||
'yZ' => 'baba',
|
||||
'yZ' => 'bab',
|
||||
'a' => array( 5, 111, 'x' ),
|
||||
);
|
||||
$this->assertSame(
|
||||
|
||||
Reference in New Issue
Block a user