diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 9c5bba8d89..8edb2f281f 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -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 }} diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 1cdc707fad..9358fc9520 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -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 }} diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 50ac94f361..b1226bacca 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -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 }} diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index a41063a15a..b5316fd1a6 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -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 }} diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 988dd0103c..aba74879f0 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -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 }} diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml new file mode 100644 index 0000000000..15a9929e1c --- /dev/null +++ b/.github/workflows/slack-notifications.yml @@ -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 }} diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 30a17068c4..e82fa1e1e4 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -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 }} diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 807d0528ac..3774ee2851 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -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 }} diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml index b4e999a05e..2bb5664a98 100644 --- a/.github/workflows/test-old-branches.yml +++ b/.github/workflows/test-old-branches.yml @@ -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 }} diff --git a/.github/workflows/welcome-new-contributors.yml b/.github/workflows/welcome-new-contributors.yml index 32a1fcd859..f475a432a0 100644 --- a/.github/workflows/welcome-new-contributors.yml +++ b/.github/workflows/welcome-new-contributors.yml @@ -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 }} diff --git a/src/wp-cron.php b/src/wp-cron.php index 489550dedc..99e8f95821 100644 --- a/src/wp-cron.php +++ b/src/wp-cron.php @@ -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. diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index e6b8580dc8..c4163d52d4 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -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(