From 7a60b8eb8bff621f9faa4f0e823616bb5e6611e4 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Thu, 29 Jul 2021 19:47:43 +0000 Subject: [PATCH] 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 --- .github/workflows/coding-standards.yml | 21 ++++++++++++++++-- .github/workflows/end-to-end-tests.yml | 20 ++++++++++++++++- .github/workflows/javascript-tests.yml | 20 ++++++++++++++++- .github/workflows/php-compatibility.yml | 22 +++++++++++++++++-- .github/workflows/phpunit-tests.yml | 20 ++++++++++++++++- .github/workflows/test-coverage.yml | 19 ++++++++++++++++ .github/workflows/test-npm.yml | 19 ++++++++++++++++ .github/workflows/test-old-branches.yml | 19 ++++++++++++++++ .../workflows/welcome-new-contributors.yml | 19 ++++++++++++++++ src/wp-cron.php | 2 +- tests/phpunit/tests/functions.php | 2 +- 11 files changed, 174 insertions(+), 9 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 67c41200b5..9c5bba8d89 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -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 }} diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 12b6355641..1cdc707fad 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -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 }} diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 06eb81bd19..50ac94f361 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -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 }} diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index cb6409d954..a41063a15a 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -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 }} diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 2f29086f72..988dd0103c 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -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 }} diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index e82fa1e1e4..30a17068c4 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -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 }} diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 3774ee2851..807d0528ac 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -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 }} diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml index 2bb5664a98..b4e999a05e 100644 --- a/.github/workflows/test-old-branches.yml +++ b/.github/workflows/test-old-branches.yml @@ -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 }} diff --git a/.github/workflows/welcome-new-contributors.yml b/.github/workflows/welcome-new-contributors.yml index f475a432a0..32a1fcd859 100644 --- a/.github/workflows/welcome-new-contributors.yml +++ b/.github/workflows/welcome-new-contributors.yml @@ -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 }} 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(