From 3c1677a75901b5960d1ea69b38a7150c6f7dcdca Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 13 Jan 2022 06:19:07 +0000 Subject: [PATCH 01/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 4 ++-- .github/workflows/regenerate-readme.yml | 2 +- .github/workflows/testing.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 54c324a..871b6ed 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -41,7 +41,7 @@ jobs: if: steps.check_composer_file.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: 'dev-main' + COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} - name: Check existence of vendor/bin/parallel-lint file id: check_linter_file @@ -80,7 +80,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: 'dev-main' + COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} - name: Check existence of vendor/bin/phpcs file id: check_phpcs_binary_file diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 9469b04..6ee5fc2 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -44,7 +44,7 @@ jobs: if: steps.check_composer_file.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: 'dev-main' + COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} - name: Configure git user run: | diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f7f80da..2ffe388 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -47,7 +47,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: 'dev-main' + COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} - name: Setup problem matcher to provide annotations for PHPUnit if: steps.check_files.outputs.files_exists == 'true' @@ -138,7 +138,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: 'dev-main' + COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} - name: Start MySQL server if: steps.check_files.outputs.files_exists == 'true' From 3bcb2ecd4509627801ac3a729bc6f286eeabe271 Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 13 Jan 2022 08:32:23 +0000 Subject: [PATCH 02/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 4 ++-- .github/workflows/regenerate-readme.yml | 2 +- .github/workflows/testing.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 871b6ed..c791c8f 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -41,7 +41,7 @@ jobs: if: steps.check_composer_file.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} + COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - name: Check existence of vendor/bin/parallel-lint file id: check_linter_file @@ -80,7 +80,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} + COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - name: Check existence of vendor/bin/phpcs file id: check_phpcs_binary_file diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 6ee5fc2..d075c9f 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -44,7 +44,7 @@ jobs: if: steps.check_composer_file.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} + COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - name: Configure git user run: | diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2ffe388..0149e31 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -47,7 +47,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} + COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - name: Setup problem matcher to provide annotations for PHPUnit if: steps.check_files.outputs.files_exists == 'true' @@ -138,7 +138,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' uses: "ramsey/composer-install@v2" env: - COMPOSER_ROOT_VERSION: ${{ github.event.repository.default_branch }} + COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - name: Start MySQL server if: steps.check_files.outputs.files_exists == 'true' From bd70c06015426d2cc8752cb90f0a1fe60594a368 Mon Sep 17 00:00:00 2001 From: schlessera Date: Mon, 9 May 2022 14:56:27 +0000 Subject: [PATCH 03/28] Update file(s) from wp-cli/.github --- .github/workflows/regenerate-readme.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index d075c9f..8283590 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -96,7 +96,7 @@ jobs: uses: repo-sync/pull-request@v2 with: source_branch: regenerate-readme - destination_branch: main + destination_branch: ${{ github.event.repository.default_branch }} github_token: ${{ secrets.GITHUB_TOKEN }} pr_title: Regenerate README file pr_body: "**This is an automated pull-request**\n\nRefreshes the `README.md` file with the latest changes to the docblocks in the source code." From 7660702d030a0f36f5c605120bf0df7df532879b Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 11 Aug 2022 18:40:56 +0000 Subject: [PATCH 04/28] Update file(s) from wp-cli/.github --- .github/workflows/regenerate-readme.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 8283590..39725d6 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -76,7 +76,7 @@ jobs: - name: Regenerate README.md file run: | wp package install "wp-cli/scaffold-package-command:^2" - wp scaffold package-readme --force . + wp scaffold package-readme --branch=${{ github.event.repository.default_branch }} --force . - name: Check if there are changes id: changes From 96ccc7c163fbe565241b816ed525925efae3eaf5 Mon Sep 17 00:00:00 2001 From: schlessera Date: Mon, 15 Aug 2022 10:28:57 +0000 Subject: [PATCH 05/28] Update file(s) from wp-cli/.github --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 0149e31..e1b5c33 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -118,7 +118,7 @@ jobs: sudo apt-get update sudo apt-get install ghostscript -y - - name: Set up PHP envirnoment + - name: Set up PHP environment if: steps.check_files.outputs.files_exists == 'true' uses: shivammathur/setup-php@v2 with: From fb405000dc99a6afea1e598218a69fe65e521791 Mon Sep 17 00:00:00 2001 From: Paul Ryan Date: Thu, 18 Aug 2022 10:42:02 -1000 Subject: [PATCH 06/28] Fix divide-by-zero warning if no active/inactive plugins found --- inc/checks/class-plugin-deactivated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/checks/class-plugin-deactivated.php b/inc/checks/class-plugin-deactivated.php index eec2515..9a0a3aa 100644 --- a/inc/checks/class-plugin-deactivated.php +++ b/inc/checks/class-plugin-deactivated.php @@ -30,7 +30,7 @@ public function run() { } $threshold = (int) $this->threshold_percentage; - if ( ( $inactive / ( $inactive + $active ) ) > ( $threshold / 100 ) ) { + if ( $inactive + $active > 0 && ( $inactive / ( $inactive + $active ) ) > ( $threshold / 100 ) ) { $this->set_status( 'warning' ); $this->set_message( "Greater than {$threshold} percent of plugins are deactivated." ); } else { From 733f6e2f4acf9c97f294415e13d94b62dc3282ba Mon Sep 17 00:00:00 2001 From: Paul Ryan Date: Thu, 18 Aug 2022 10:42:38 -1000 Subject: [PATCH 07/28] Include network-activated plugins in checks See for valid list of plugin statuses: https://developer.wordpress.org/cli/commands/plugin/list/ --- inc/checks/class-plugin-active-count.php | 2 +- inc/checks/class-plugin-deactivated.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/checks/class-plugin-active-count.php b/inc/checks/class-plugin-active-count.php index 49d4b46..d670768 100644 --- a/inc/checks/class-plugin-active-count.php +++ b/inc/checks/class-plugin-active-count.php @@ -21,7 +21,7 @@ public function run() { $active = 0; foreach ( self::get_plugins() as $plugin ) { - if ( 'active' === $plugin['status'] ) { + if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) { $active++; } } diff --git a/inc/checks/class-plugin-deactivated.php b/inc/checks/class-plugin-deactivated.php index 9a0a3aa..fa72a5d 100644 --- a/inc/checks/class-plugin-deactivated.php +++ b/inc/checks/class-plugin-deactivated.php @@ -22,7 +22,7 @@ public function run() { $active = 0; $inactive = 0; foreach ( self::get_plugins() as $plugin ) { - if ( 'active' === $plugin['status'] ) { + if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) { $active++; } elseif ( 'inactive' === $plugin['status'] ) { $inactive++; From d382e92abbffbd4ae9bc935ae0077637f85ab02b Mon Sep 17 00:00:00 2001 From: Paul Ryan Date: Thu, 18 Aug 2022 14:12:32 -1000 Subject: [PATCH 08/28] Test coverage for PR #167 --- features/check-plugin-active-count.feature | 9 +++++++++ features/check-plugin-deactivated.feature | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 3047b1b..7493185 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -33,3 +33,12 @@ Feature: Check whether a high number of plugins are activated Then STDOUT should be a table containing rows: | name | status | message | | plugin-active-count | warning | Number of active plugins (4) exceeds threshold (3). | + + Scenario: Include network-enabled plugins in active plugin count + Given a WP multisite installation + And I run `wp plugin activate --network --all` + + When I run `wp doctor check plugin-active-count` + Then STDOUT should be a table containing rows: + | name | status | message | + | plugin-active-count | success | Number of active plugins (2) is less than threshold (80). | diff --git a/features/check-plugin-deactivated.feature b/features/check-plugin-deactivated.feature index b8dee11..754e0ac 100644 --- a/features/check-plugin-deactivated.feature +++ b/features/check-plugin-deactivated.feature @@ -42,3 +42,21 @@ Feature: Check whether a high percentage of plugins are deactivated Then STDOUT should be a table containing rows: | name | status | message | | plugin-deactivated | warning | Greater than 60 percent of plugins are deactivated. | + + Scenario: Gracefully handle no plugins installed + Given a WP install + And I run `wp plugin uninstall --all` + + When I run `wp doctor check plugin-deactivated` + Then STDOUT should be a table containing rows: + | name | status | message | + | plugin-deactivated | success | Less than 40 percent of plugins are deactivated. | + + Scenario: Gracefully handle only network-enabled plugins installed and activated + Given a WP multisite installation + And I run `wp plugin activate --network --all` + + When I run `wp doctor check plugin-deactivated` + Then STDOUT should be a table containing rows: + | name | status | message | + | plugin-deactivated | success | Less than 40 percent of plugins are deactivated. | From 28b3afb653a32ea4adc30edc5c021ef7dc2157f9 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 19 Aug 2022 04:59:26 -0700 Subject: [PATCH 09/28] Add `allow-plugins` statement --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f0482f6..ac1649f 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,10 @@ "php": "5.6" }, "process-timeout": 7200, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "extra": { "branch-alias": { From 211599b61659ca3e4e3c14ae242361a97bfb9221 Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 6 Oct 2022 21:27:31 +0000 Subject: [PATCH 10/28] Update file(s) from wp-cli/.github --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e1b5c33..8c77597 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -162,6 +162,8 @@ jobs: - name: Check Behat environment if: steps.check_files.outputs.files_exists == 'true' + env: + WP_VERSION: '${{ matrix.wp }}' run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat - name: Run Behat From 62537e35ba76df0ef43b65ddb846bd32d86e83a7 Mon Sep 17 00:00:00 2001 From: schlessera Date: Mon, 17 Oct 2022 18:10:42 +0000 Subject: [PATCH 11/28] Update file(s) from wp-cli/.github --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b60e661..d6c7b8b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,11 @@ updates: open-pull-requests-limit: 10 labels: - scope:distribution + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + labels: + - scope:distribution + From fd9e91d9b5a07ccf53fc3ce77c5676d4080a3771 Mon Sep 17 00:00:00 2001 From: schlessera Date: Mon, 17 Oct 2022 18:31:40 +0000 Subject: [PATCH 12/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 4 ++-- .github/workflows/regenerate-readme.yml | 2 +- .github/workflows/testing.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index c791c8f..37473a7 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check existence of composer.json file id: check_composer_file @@ -59,7 +59,7 @@ jobs: steps: - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check existence of composer.json & phpcs.xml.dist files id: check_files diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 39725d6..782b873 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -25,7 +25,7 @@ jobs: if: ${{ github.repository_owner == 'wp-cli' && ! contains(fromJson('[".github", "wp-cli", "wp-cli-bundle", "wp-super-cache-cli", "php-cli-tools", "wp-config-transformer"]'), github.event.repository.name) }} steps: - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up PHP envirnoment uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8c77597..e76b321 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check existence of composer.json file id: check_files @@ -104,7 +104,7 @@ jobs: steps: - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check existence of composer.json & behat.yml files id: check_files From d0f684133e9779c89864595f72cb543860bbbcc4 Mon Sep 17 00:00:00 2001 From: schlessera Date: Mon, 17 Oct 2022 20:16:36 +0000 Subject: [PATCH 13/28] Update file(s) from wp-cli/.github --- .github/workflows/regenerate-readme.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 782b873..a8beff2 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -52,16 +52,15 @@ jobs: git config --global user.name "Alain Schlesser" - name: Check if remote branch exists - id: remote-branch - run: echo ::set-output name=exists::$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1") + run: echo "REMOTE_BRANCH_EXISTS=$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1")" >> $GITHUB_ENV - name: Create branch to base pull request on - if: steps.remote-branch.outputs.exists == 0 + if: env.REMOTE_BRANCH_EXISTS == 0 run: | git checkout -b regenerate-readme - name: Fetch existing branch to add commits to - if: steps.remote-branch.outputs.exists == 1 + if: env.REMOTE_BRANCH_EXISTS == 1 run: | git fetch --all --prune git checkout regenerate-readme @@ -79,11 +78,10 @@ jobs: wp scaffold package-readme --branch=${{ github.event.repository.default_branch }} --force . - name: Check if there are changes - id: changes - run: echo ::set-output name=changed::$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1") + run: echo "CHANGES_DETECTED=$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")" >> $GITHUB_ENV - name: Commit changes - if: steps.changes.outputs.changed == 1 + if: env.CHANGES_DETECTED == 1 run: | git add README.md git commit -m "Regenerate README file - $(date +'%Y-%m-%d')" @@ -91,8 +89,8 @@ jobs: - name: Create pull request if: | - steps.changes.outputs.changed == 1 && - steps.remote-branch.outputs.exists == 0 + env.CHANGES_DETECTED == 1 && + env.REMOTE_BRANCH_EXISTS == 0 uses: repo-sync/pull-request@v2 with: source_branch: regenerate-readme From 3416d7af2cc552dbde4be695ac32d6aa0e57b245 Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 27 Oct 2022 15:08:19 +0000 Subject: [PATCH 14/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 8 ++++---- .github/workflows/regenerate-readme.yml | 2 +- .github/workflows/testing.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 37473a7..00dc2e6 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -24,7 +24,7 @@ jobs: - name: Check existence of composer.json file id: check_composer_file - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "composer.json" @@ -45,7 +45,7 @@ jobs: - name: Check existence of vendor/bin/parallel-lint file id: check_linter_file - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "vendor/bin/parallel-lint" @@ -63,7 +63,7 @@ jobs: - name: Check existence of composer.json & phpcs.xml.dist files id: check_files - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "composer.json, phpcs.xml.dist" @@ -84,7 +84,7 @@ jobs: - name: Check existence of vendor/bin/phpcs file id: check_phpcs_binary_file - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "vendor/bin/phpcs" diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index a8beff2..a69320e 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -36,7 +36,7 @@ jobs: - name: Check existence of composer.json file id: check_composer_file - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "composer.json" diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e76b321..08bb81f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -29,7 +29,7 @@ jobs: - name: Check existence of composer.json file id: check_files - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "composer.json, phpunit.xml.dist" @@ -108,7 +108,7 @@ jobs: - name: Check existence of composer.json & behat.yml files id: check_files - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@v2 with: files: "composer.json, behat.yml" From 7e8cc7d5b97fcb5a1914bbe0a072033f8b5d26c1 Mon Sep 17 00:00:00 2001 From: schlessera Date: Fri, 4 Nov 2022 19:31:47 +0000 Subject: [PATCH 15/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 85 +----------- .github/workflows/regenerate-readme.yml | 95 +------------- .github/workflows/testing.yml | 165 +----------------------- 3 files changed, 8 insertions(+), 337 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 00dc2e6..89fd2c2 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -7,87 +7,6 @@ on: - main - master -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: - - lint: #----------------------------------------------------------------------- - name: Lint PHP files - runs-on: ubuntu-latest - steps: - - name: Check out source code - uses: actions/checkout@v3 - - - name: Check existence of composer.json file - id: check_composer_file - uses: andstor/file-existence-action@v2 - with: - files: "composer.json" - - - name: Set up PHP environment - if: steps.check_composer_file.outputs.files_exists == 'true' - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - tools: cs2pr - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Composer dependencies & cache dependencies - if: steps.check_composer_file.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" - env: - COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - - - name: Check existence of vendor/bin/parallel-lint file - id: check_linter_file - uses: andstor/file-existence-action@v2 - with: - files: "vendor/bin/parallel-lint" - - - name: Run Linter - if: steps.check_linter_file.outputs.files_exists == 'true' - run: vendor/bin/parallel-lint -j 10 . --exclude vendor --checkstyle | cs2pr - - phpcs: #---------------------------------------------------------------------- - name: PHPCS - runs-on: ubuntu-latest - - steps: - - name: Check out source code - uses: actions/checkout@v3 - - - name: Check existence of composer.json & phpcs.xml.dist files - id: check_files - uses: andstor/file-existence-action@v2 - with: - files: "composer.json, phpcs.xml.dist" - - - name: Set up PHP environment - if: steps.check_files.outputs.files_exists == 'true' - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - tools: cs2pr - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Composer dependencies & cache dependencies - if: steps.check_files.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" - env: - COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - - - name: Check existence of vendor/bin/phpcs file - id: check_phpcs_binary_file - uses: andstor/file-existence-action@v2 - with: - files: "vendor/bin/phpcs" - - - name: Run PHPCS - if: steps.check_phpcs_binary_file.outputs.files_exists == 'true' - run: vendor/bin/phpcs -q --report=checkstyle | cs2pr + code-quality: + uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@85be2d1b154ddf1b2f03166c93bc75a27fb3daf1 diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index a69320e..877cc20 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -7,96 +7,9 @@ on: - main - master paths-ignore: - - 'features/**' - - 'README.md' - -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - + - "features/**" + - "README.md" jobs: - - regenerate-readme: #---------------------------------------------------------- - name: Regenerate README.md file - runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'wp-cli' && ! contains(fromJson('[".github", "wp-cli", "wp-cli-bundle", "wp-super-cache-cli", "php-cli-tools", "wp-config-transformer"]'), github.event.repository.name) }} - steps: - - name: Check out source code - uses: actions/checkout@v3 - - - name: Set up PHP envirnoment - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Check existence of composer.json file - id: check_composer_file - uses: andstor/file-existence-action@v2 - with: - files: "composer.json" - - - name: Install Composer dependencies & cache dependencies - if: steps.check_composer_file.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" - env: - COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - - - name: Configure git user - run: | - git config --global user.email "alain.schlesser@gmail.com" - git config --global user.name "Alain Schlesser" - - - name: Check if remote branch exists - run: echo "REMOTE_BRANCH_EXISTS=$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1")" >> $GITHUB_ENV - - - name: Create branch to base pull request on - if: env.REMOTE_BRANCH_EXISTS == 0 - run: | - git checkout -b regenerate-readme - - - name: Fetch existing branch to add commits to - if: env.REMOTE_BRANCH_EXISTS == 1 - run: | - git fetch --all --prune - git checkout regenerate-readme - git pull --no-rebase - - - name: Install WP-CLI - run: | - curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar - sudo mv wp-cli-nightly.phar /usr/local/bin/wp - sudo chmod +x /usr/local/bin/wp - - - name: Regenerate README.md file - run: | - wp package install "wp-cli/scaffold-package-command:^2" - wp scaffold package-readme --branch=${{ github.event.repository.default_branch }} --force . - - - name: Check if there are changes - run: echo "CHANGES_DETECTED=$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")" >> $GITHUB_ENV - - - name: Commit changes - if: env.CHANGES_DETECTED == 1 - run: | - git add README.md - git commit -m "Regenerate README file - $(date +'%Y-%m-%d')" - git push origin regenerate-readme - - - name: Create pull request - if: | - env.CHANGES_DETECTED == 1 && - env.REMOTE_BRANCH_EXISTS == 0 - uses: repo-sync/pull-request@v2 - with: - source_branch: regenerate-readme - destination_branch: ${{ github.event.repository.default_branch }} - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_title: Regenerate README file - pr_body: "**This is an automated pull-request**\n\nRefreshes the `README.md` file with the latest changes to the docblocks in the source code." - pr_reviewer: schlessera - pr_label: scope:documentation + regenerate-readme: + uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@85be2d1b154ddf1b2f03166c93bc75a27fb3daf1 diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 08bb81f..e937ef1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -7,167 +7,6 @@ on: - main - master -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: - - unit: #----------------------------------------------------------------------- - name: Unit test / PHP ${{ matrix.php }} - strategy: - fail-fast: false - matrix: - php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] - runs-on: ubuntu-20.04 - - steps: - - name: Check out source code - uses: actions/checkout@v3 - - - name: Check existence of composer.json file - id: check_files - uses: andstor/file-existence-action@v2 - with: - files: "composer.json, phpunit.xml.dist" - - - name: Set up PHP environment - if: steps.check_files.outputs.files_exists == 'true' - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php }}' - coverage: none - tools: composer,cs2pr - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Composer dependencies & cache dependencies - if: steps.check_files.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" - env: - COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - - - name: Setup problem matcher to provide annotations for PHPUnit - if: steps.check_files.outputs.files_exists == 'true' - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Run PHPUnit - if: steps.check_files.outputs.files_exists == 'true' - run: composer phpunit - - functional: #---------------------------------------------------------------------- - name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }} - strategy: - fail-fast: false - matrix: - php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] - wp: ['latest'] - mysql: ['8.0'] - include: - - php: '5.6' - wp: 'trunk' - mysql: '8.0' - - php: '5.6' - wp: 'trunk' - mysql: '5.7' - - php: '5.6' - wp: 'trunk' - mysql: '5.6' - - php: '7.4' - wp: 'trunk' - mysql: '8.0' - - php: '8.0' - wp: 'trunk' - mysql: '8.0' - - php: '8.0' - wp: 'trunk' - mysql: '5.7' - - php: '8.0' - wp: 'trunk' - mysql: '5.6' - - php: '8.1' - wp: 'trunk' - mysql: '8.0' - - php: '5.6' - wp: '3.7' - mysql: '5.6' - runs-on: ubuntu-20.04 - - services: - mysql: - image: mysql:${{ matrix.mysql }} - ports: - - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" - - steps: - - name: Check out source code - uses: actions/checkout@v3 - - - name: Check existence of composer.json & behat.yml files - id: check_files - uses: andstor/file-existence-action@v2 - with: - files: "composer.json, behat.yml" - - - name: Install Ghostscript - if: steps.check_files.outputs.files_exists == 'true' - run: | - sudo apt-get update - sudo apt-get install ghostscript -y - - - name: Set up PHP environment - if: steps.check_files.outputs.files_exists == 'true' - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php }}' - extensions: gd, imagick, mysql, zip - coverage: none - tools: composer - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Change ImageMagick policy to allow pdf->png conversion. - if: steps.check_files.outputs.files_exists == 'true' - run: | - sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml - - - name: Install Composer dependencies & cache dependencies - if: steps.check_files.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" - env: - COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} - - - name: Start MySQL server - if: steps.check_files.outputs.files_exists == 'true' - run: sudo systemctl start mysql - - - name: Configure DB environment - if: steps.check_files.outputs.files_exists == 'true' - run: | - echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV - echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV - echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV - echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV - echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV - echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV - echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV - echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV - - - name: Prepare test database - if: steps.check_files.outputs.files_exists == 'true' - run: composer prepare-tests - - - name: Check Behat environment - if: steps.check_files.outputs.files_exists == 'true' - env: - WP_VERSION: '${{ matrix.wp }}' - run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat - - - name: Run Behat - if: steps.check_files.outputs.files_exists == 'true' - env: - WP_VERSION: '${{ matrix.wp }}' - run: composer behat || composer behat-rerun + test: + uses: wp-cli/.github/.github/workflows/reusable-testing.yml@85be2d1b154ddf1b2f03166c93bc75a27fb3daf1 From 0969da0d24a0e3360eda5a1770f99e282a966d8f Mon Sep 17 00:00:00 2001 From: schlessera Date: Fri, 4 Nov 2022 22:15:14 +0000 Subject: [PATCH 16/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 2 +- .github/workflows/regenerate-readme.yml | 2 +- .github/workflows/testing.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 89fd2c2..07e4fd1 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -9,4 +9,4 @@ on: jobs: code-quality: - uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@85be2d1b154ddf1b2f03166c93bc75a27fb3daf1 + uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 877cc20..c633d9d 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -12,4 +12,4 @@ on: jobs: regenerate-readme: - uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@85be2d1b154ddf1b2f03166c93bc75a27fb3daf1 + uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e937ef1..3c5083d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -9,4 +9,4 @@ on: jobs: test: - uses: wp-cli/.github/.github/workflows/reusable-testing.yml@85be2d1b154ddf1b2f03166c93bc75a27fb3daf1 + uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main From f405a828475ffe75f07eea5f38fe364c86c52fca Mon Sep 17 00:00:00 2001 From: schlessera Date: Tue, 3 Jan 2023 15:24:59 +0000 Subject: [PATCH 17/28] Update file(s) from wp-cli/.github --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 3c5083d..5d43d67 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -6,6 +6,8 @@ on: branches: - main - master + schedule: + - cron: '0 0 * * *' # Run every day. jobs: test: From d59a3f5a44ccabea1837e3ee1587382eb5eb1e31 Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 5 Jan 2023 19:51:43 +0000 Subject: [PATCH 18/28] Update file(s) from wp-cli/.github --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 5d43d67..1044b79 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -7,7 +7,7 @@ on: - main - master schedule: - - cron: '0 0 * * *' # Run every day. + - cron: '17 1 * * *' # Run every day on a seemly random time. jobs: test: From 1f30c044e484d7bc8a3cf8fd3962e63c321abb47 Mon Sep 17 00:00:00 2001 From: schlessera Date: Wed, 11 Jan 2023 08:51:45 +0000 Subject: [PATCH 19/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 2 ++ .github/workflows/regenerate-readme.yml | 2 ++ .github/workflows/testing.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 07e4fd1..0f841fc 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -10,3 +10,5 @@ on: jobs: code-quality: uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main + secrets: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index c633d9d..8feb576 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -13,3 +13,5 @@ on: jobs: regenerate-readme: uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main + secrets: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1044b79..32cc3a2 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,3 +12,5 @@ on: jobs: test: uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main + secrets: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9da7710cab78e14774546d76be1328c9ffdaebe0 Mon Sep 17 00:00:00 2001 From: schlessera Date: Thu, 12 Jan 2023 04:35:03 +0000 Subject: [PATCH 20/28] Update file(s) from wp-cli/.github --- .github/workflows/code-quality.yml | 2 -- .github/workflows/regenerate-readme.yml | 2 -- .github/workflows/testing.yml | 2 -- 3 files changed, 6 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 0f841fc..07e4fd1 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -10,5 +10,3 @@ on: jobs: code-quality: uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main - secrets: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/regenerate-readme.yml b/.github/workflows/regenerate-readme.yml index 8feb576..c633d9d 100644 --- a/.github/workflows/regenerate-readme.yml +++ b/.github/workflows/regenerate-readme.yml @@ -13,5 +13,3 @@ on: jobs: regenerate-readme: uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main - secrets: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 32cc3a2..1044b79 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,5 +12,3 @@ on: jobs: test: uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main - secrets: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0daa684c69cd3411281a72879c64f5d0b3214409 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 19 Jan 2023 05:03:45 -0800 Subject: [PATCH 21/28] Update `runcommand.io` links to corresponding pages on my site --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd0eecd..08f0acb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Quick links: [Overview](#overview) | [Using](#using) | [Installing](#installing) `wp doctor` lets you easily run a series of configurable checks to diagnose what's ailing with WordPress. -Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://runcommand.io/to/doctor-default-checks/), and [supports customized `doctor.yml` files](https://runcommand.io/to/customize-doctor-config/) to define the checks that are most important to you. +Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://danielbachhuber.com/tip/doctor-default-checks/), and [supports customized `doctor.yml` files](https://danielbachhuber.com/tip/customize-doctor-config/) to define the checks that are most important to you. Each check includes a name, status (either "success", "warning", or "error"), and a human-readable message. For example, `cron-count` is a check to ensure WP Cron hasn't exploded with jobs: From d09200db49e200f239d218ada26740b7a0771af6 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 19 Jan 2023 05:44:15 -0800 Subject: [PATCH 22/28] Switch to WP-CLI handbook links --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08f0acb..3430274 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Quick links: [Overview](#overview) | [Using](#using) | [Installing](#installing) `wp doctor` lets you easily run a series of configurable checks to diagnose what's ailing with WordPress. -Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://danielbachhuber.com/tip/doctor-default-checks/), and [supports customized `doctor.yml` files](https://danielbachhuber.com/tip/customize-doctor-config/) to define the checks that are most important to you. +Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://make.wordpress.org/cli/handbook/doctor-default-checks/), and [supports customized `doctor.yml` files](https://make.wordpress.org/cli/handbook/doctor-customize-config/) to define the checks that are most important to you. Each check includes a name, status (either "success", "warning", or "error"), and a human-readable message. For example, `cron-count` is a check to ensure WP Cron hasn't exploded with jobs: From c5593f15958124c82025a7e9558daff90d34018d Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 20 Jan 2023 09:30:31 -0800 Subject: [PATCH 23/28] Update guide links to their final destinations (#175) --- README.md | 2 +- bin/readme/overview-body.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3430274..5785f84 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Quick links: [Overview](#overview) | [Using](#using) | [Installing](#installing) `wp doctor` lets you easily run a series of configurable checks to diagnose what's ailing with WordPress. -Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://make.wordpress.org/cli/handbook/doctor-default-checks/), and [supports customized `doctor.yml` files](https://make.wordpress.org/cli/handbook/doctor-customize-config/) to define the checks that are most important to you. +Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://make.wordpress.org/cli/handbook/guides/doctor/doctor-default-checks/), and [supports customized `doctor.yml` files](https://make.wordpress.org/cli/handbook/guides/doctor/doctor-customize-config/) to define the checks that are most important to you. Each check includes a name, status (either "success", "warning", or "error"), and a human-readable message. For example, `cron-count` is a check to ensure WP Cron hasn't exploded with jobs: diff --git a/bin/readme/overview-body.md b/bin/readme/overview-body.md index ca77124..081f749 100644 --- a/bin/readme/overview-body.md +++ b/bin/readme/overview-body.md @@ -1,6 +1,6 @@ `wp doctor` lets you easily run a series of configurable checks to diagnose what's ailing with WordPress. -Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://runcommand.io/to/doctor-default-checks/), and [supports customized `doctor.yml` files](https://runcommand.io/to/customize-doctor-config/) to define the checks that are most important to you. +Without `wp doctor`, your team has to rely on their memory to manually debug problems. With `wp doctor`, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. `wp doctor` [comes with dozens of checks out of the box](https://make.wordpress.org/cli/handbook/guides/doctor/doctor-default-checks/), and [supports customized `doctor.yml` files](https://make.wordpress.org/cli/handbook/guides/doctor/doctor-customize-config/) to define the checks that are most important to you. Each check includes a name, status (either "success", "warning", or "error"), and a human-readable message. For example, `cron-count` is a check to ensure WP Cron hasn't exploded with jobs: From 391e74557c3424564c52bb7d51601592f7f4f2cb Mon Sep 17 00:00:00 2001 From: joeldcanfield <53883478+joeldcanfield@users.noreply.github.com> Date: Mon, 30 Jan 2023 05:02:46 -0700 Subject: [PATCH 24/28] Update class-cache-flush.php (#176) checks use of the function, not number of occurrences --- inc/checks/class-cache-flush.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/checks/class-cache-flush.php b/inc/checks/class-cache-flush.php index fb53da8..69d1de7 100644 --- a/inc/checks/class-cache-flush.php +++ b/inc/checks/class-cache-flush.php @@ -7,7 +7,7 @@ use RecursiveIteratorIterator; /** - * Detects the number of occurrences of the `wp_cache_flush()` function. + * Detects any use of the `wp_cache_flush()` function. */ class Cache_Flush extends File_Contents { From 13e64bc9ffc2de60d6f7fe58f332f372b204e5e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Feb 2023 04:32:26 -0800 Subject: [PATCH 25/28] Update wp-cli/wp-cli-tests requirement from ^2.1 to ^3.2 (#177) Updates the requirements on [wp-cli/wp-cli-tests](https://github.com/wp-cli/wp-cli-tests) to permit the latest version. - [Release notes](https://github.com/wp-cli/wp-cli-tests/releases) - [Commits](https://github.com/wp-cli/wp-cli-tests/compare/v2.1.0...v3.2.0) --- updated-dependencies: - dependency-name: wp-cli/wp-cli-tests dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ac1649f..0d77d97 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "wp-cli/wp-cli": "^2.1" }, "require-dev": { - "wp-cli/wp-cli-tests": "^2.1" + "wp-cli/wp-cli-tests": "^3.2" }, "config": { "platform": { From e4190a54b8d5d39ba7f1ff6ee451639450b828cc Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 15 Mar 2023 04:35:52 -0700 Subject: [PATCH 26/28] Fix deprecation notice in PHP 8.2 (#179) --- inc/class-command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/class-command.php b/inc/class-command.php index a5565c5..6000ed2 100644 --- a/inc/class-command.php +++ b/inc/class-command.php @@ -209,7 +209,7 @@ function( $check ) { $should_error = ! empty( $results_with_error ); if ( $should_error && 'table' === $assoc_args['format'] ) { $check_count = count( $results_with_error ); - $error_message = 1 === $check_count ? "1 check reports 'error'." : "${check_count} checks report 'error'."; + $error_message = 1 === $check_count ? "1 check reports 'error'." : sprintf( "%d checks report 'error'.", $check_count ); } else { $error_message = null; } From bdef7f2b56bd76d9d4a3326032d1b1004144a4f6 Mon Sep 17 00:00:00 2001 From: schlessera Date: Sat, 27 May 2023 14:31:44 +0000 Subject: [PATCH 27/28] Update file(s) from wp-cli/.github --- .editorconfig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index fa483b1..84f918e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,6 +4,8 @@ # WordPress Coding Standards # https://make.wordpress.org/core/handbook/coding-standards/ +# From https://github.com/WordPress/wordpress-develop/blob/trunk/.editorconfig with a couple of additions. + root = true [*] @@ -13,13 +15,12 @@ insert_final_newline = true trim_trailing_whitespace = true indent_style = tab -[{.jshintrc,*.json,*.yml,*.feature}] +[{*.yml,*.feature,.jshintrc,*.json}] indent_style = space indent_size = 2 +[*.md] +trim_trailing_whitespace = false + [{*.txt,wp-config-sample.php}] end_of_line = crlf - -[composer.json] -indent_style = space -indent_size = 4 From ad8446bede9b2630daa68baf776c5bc43a460d86 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 31 Aug 2023 12:34:39 +0200 Subject: [PATCH 28/28] Update to WPCS v3 (#181) * Update `wp-cli/wp-cli-tests` * Add `phpcbf` composer script * Auto-fix all newly reported issues * Rename ignored sniff * Rename parameter * Ignore unused parameter --- command.php | 10 +++++----- composer.json | 3 ++- inc/checks/class-autoload-options-size.php | 2 -- inc/checks/class-check.php | 1 - inc/checks/class-constant-definition.php | 12 ++++-------- inc/checks/class-core-update.php | 2 -- inc/checks/class-core-verify-checksums.php | 1 - inc/checks/class-cron-count.php | 1 - inc/checks/class-cron-duplicates.php | 3 +-- inc/checks/class-cron.php | 1 - inc/checks/class-file-type.php | 2 -- inc/checks/class-file.php | 1 - inc/checks/class-option-value.php | 6 ++---- inc/checks/class-plugin-active-count.php | 4 +--- inc/checks/class-plugin-deactivated.php | 6 ++---- inc/checks/class-plugin-status.php | 1 - inc/checks/class-plugin-update.php | 4 +--- inc/checks/class-plugin.php | 1 - inc/checks/class-theme-update.php | 4 +--- inc/class-checks.php | 3 +-- inc/class-command.php | 9 ++++----- 21 files changed, 24 insertions(+), 53 deletions(-) diff --git a/command.php b/command.php index 8d10b60..87070d6 100644 --- a/command.php +++ b/command.php @@ -5,19 +5,19 @@ } spl_autoload_register( - function( $class ) { - $class = ltrim( $class, '\\' ); - if ( 0 !== stripos( $class, 'runcommand\\Doctor\\' ) ) { + function ( $class_name ) { + $class_name = ltrim( $class_name, '\\' ); + if ( 0 !== stripos( $class_name, 'runcommand\\Doctor\\' ) ) { return; } - $parts = explode( '\\', $class ); + $parts = explode( '\\', $class_name ); array_shift( $parts ); // Don't need "runcommand\Doctor" array_shift( $parts ); $last = array_pop( $parts ); // File should be 'class-[...].php' $last = 'class-' . $last . '.php'; $parts[] = $last; - $file = dirname( __FILE__ ) . '/inc/' . str_replace( '_', '-', strtolower( implode( '/', $parts ) ) ); + $file = __DIR__ . '/inc/' . str_replace( '_', '-', strtolower( implode( '/', $parts ) ) ); if ( file_exists( $file ) ) { require $file; } diff --git a/composer.json b/composer.json index 0d77d97..fe75f1f 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "wp-cli/wp-cli": "^2.1" }, "require-dev": { - "wp-cli/wp-cli-tests": "^3.2" + "wp-cli/wp-cli-tests": "^4" }, "config": { "platform": { @@ -66,6 +66,7 @@ "behat-rerun": "rerun-behat-tests", "lint": "run-linter-tests", "phpcs": "run-phpcs-tests", + "phpcbf": "run-phpcbf-cleanup", "phpunit": "run-php-unit-tests", "prepare-tests": "install-package-tests", "test": [ diff --git a/inc/checks/class-autoload-options-size.php b/inc/checks/class-autoload-options-size.php index 16ee392..a614826 100644 --- a/inc/checks/class-autoload-options-size.php +++ b/inc/checks/class-autoload-options-size.php @@ -37,7 +37,6 @@ public function run() { $this->set_status( 'success' ); $this->set_message( "Autoloaded options size ({$human_total}) is less than threshold ({$human_threshold})." ); } - } private static function format_bytes( $size, $precision = 2 ) { @@ -45,5 +44,4 @@ private static function format_bytes( $size, $precision = 2 ) { $suffixes = array( '', 'kb', 'mb', 'g', 't' ); return round( pow( 1024, $base - floor( $base ) ), $precision ) . $suffixes[ floor( $base ) ]; } - } diff --git a/inc/checks/class-check.php b/inc/checks/class-check.php index 6f4d36b..9b9b1a6 100644 --- a/inc/checks/class-check.php +++ b/inc/checks/class-check.php @@ -99,5 +99,4 @@ public function get_results() { 'message' => $this->_message, ); } - } diff --git a/inc/checks/class-constant-definition.php b/inc/checks/class-constant-definition.php index 12787d8..3eb648b 100644 --- a/inc/checks/class-constant-definition.php +++ b/inc/checks/class-constant-definition.php @@ -69,14 +69,12 @@ public function run() { $this->set_status( 'error' ); $this->set_message( "Constant '{$this->constant}' is defined '{$human_actual}' but expected to not be falsy." ); } - } else { - if ( ! $this->falsy ) { + } elseif ( ! $this->falsy ) { $this->set_status( 'success' ); $this->set_message( "Constant '{$this->constant}' is not defined falsy." ); - } else { - $this->set_status( 'error' ); - $this->set_message( "Constant '{$this->constant}' is defined '{$human_actual}' but expected to be falsy." ); - } + } else { + $this->set_status( 'error' ); + $this->set_message( "Constant '{$this->constant}' is defined '{$human_actual}' but expected to be falsy." ); } } return; @@ -118,7 +116,6 @@ public function run() { $human_expected = self::human_value( $this->value ); $this->set_message( "Constant '{$this->constant}' is defined '{$human_actual}' but expected to be '{$human_expected}'." ); } - } private static function human_value( $value ) { @@ -129,5 +126,4 @@ private static function human_value( $value ) { } return $value; } - } diff --git a/inc/checks/class-core-update.php b/inc/checks/class-core-update.php index fbb2cbd..6d2bbbc 100644 --- a/inc/checks/class-core-update.php +++ b/inc/checks/class-core-update.php @@ -37,7 +37,5 @@ public function run() { $this->set_status( 'success' ); $this->set_message( 'WordPress is at the latest version.' ); } - } - } diff --git a/inc/checks/class-core-verify-checksums.php b/inc/checks/class-core-verify-checksums.php index 07dc5bc..1e3f662 100644 --- a/inc/checks/class-core-verify-checksums.php +++ b/inc/checks/class-core-verify-checksums.php @@ -30,5 +30,4 @@ public function run() { $this->set_message( "WordPress doesn't verify against its checksums." ); } } - } diff --git a/inc/checks/class-cron-count.php b/inc/checks/class-cron-count.php index dbbe710..3922987 100644 --- a/inc/checks/class-cron-count.php +++ b/inc/checks/class-cron-count.php @@ -26,5 +26,4 @@ public function run() { $this->set_message( 'Total number of cron jobs is within normal operating expectations.' ); } } - } diff --git a/inc/checks/class-cron-duplicates.php b/inc/checks/class-cron-duplicates.php index 13ef01e..8ba031d 100644 --- a/inc/checks/class-cron-duplicates.php +++ b/inc/checks/class-cron-duplicates.php @@ -24,7 +24,7 @@ public function run() { if ( ! isset( $job_counts[ $job['hook'] ] ) ) { $job_counts[ $job['hook'] ] = 0; } - $job_counts[ $job['hook'] ]++; + ++$job_counts[ $job['hook'] ]; if ( $job_counts[ $job['hook'] ] >= $this->threshold_count ) { $excess_duplicates = true; } @@ -37,5 +37,4 @@ public function run() { $this->set_message( 'All cron job counts are within normal operating expectations.' ); } } - } diff --git a/inc/checks/class-cron.php b/inc/checks/class-cron.php index a6865a8..c70c5df 100644 --- a/inc/checks/class-cron.php +++ b/inc/checks/class-cron.php @@ -20,5 +20,4 @@ protected static function get_crons() { self::$crons = ! empty( $ret ) ? json_decode( $ret, true ) : array(); return self::$crons; } - } diff --git a/inc/checks/class-file-type.php b/inc/checks/class-file-type.php index 65e9eac..1d18e95 100644 --- a/inc/checks/class-file-type.php +++ b/inc/checks/class-file-type.php @@ -30,7 +30,6 @@ public function run() { $this->set_message( "All '{$this->extension}' files passed assertion that symlink is '{$symlink}'." ); } } - } public function check_file( SplFileInfo $file ) { @@ -42,5 +41,4 @@ public function check_file( SplFileInfo $file ) { } } } - } diff --git a/inc/checks/class-file.php b/inc/checks/class-file.php index 3c708ee..22aad9e 100644 --- a/inc/checks/class-file.php +++ b/inc/checks/class-file.php @@ -56,5 +56,4 @@ public function get_options() { 'path' => $this->path, ); } - } diff --git a/inc/checks/class-option-value.php b/inc/checks/class-option-value.php index cc8584b..c8cada2 100644 --- a/inc/checks/class-option-value.php +++ b/inc/checks/class-option-value.php @@ -41,7 +41,7 @@ public function run() { $actual_value = get_option( $this->option ); if ( isset( $this->value ) ) { - if ( $actual_value == $this->value ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Keep existing behavior. + if ( $actual_value == $this->value ) { // phpcs:ignore Universal.Operators.StrictComparisons -- Keep existing behavior. $status = 'success'; $message = "Option '{$this->option}' is '{$this->value}' as expected."; } else { @@ -49,7 +49,7 @@ public function run() { $message = "Option '{$this->option}' is '{$actual_value}' but expected to be '{$this->value}'."; } } elseif ( isset( $this->value_is_not ) ) { - if ( $actual_value == $this->value_is_not ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Keep existing behavior. + if ( $actual_value == $this->value_is_not ) { // phpcs:ignore Universal.Operators.StrictComparisons -- Keep existing behavior. $status = 'error'; $message = "Option '{$this->option}' is '{$actual_value}' and expected not to be."; } else { @@ -77,7 +77,5 @@ public function run() { # code... break; } - } - } diff --git a/inc/checks/class-plugin-active-count.php b/inc/checks/class-plugin-active-count.php index d670768..22e2cb5 100644 --- a/inc/checks/class-plugin-active-count.php +++ b/inc/checks/class-plugin-active-count.php @@ -22,7 +22,7 @@ public function run() { $active = 0; foreach ( self::get_plugins() as $plugin ) { if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) { - $active++; + ++$active; } } @@ -34,7 +34,5 @@ public function run() { $this->set_status( 'success' ); $this->set_message( "Number of active plugins ({$active}) is less than threshold ({$threshold})." ); } - } - } diff --git a/inc/checks/class-plugin-deactivated.php b/inc/checks/class-plugin-deactivated.php index fa72a5d..24e5077 100644 --- a/inc/checks/class-plugin-deactivated.php +++ b/inc/checks/class-plugin-deactivated.php @@ -23,9 +23,9 @@ public function run() { $inactive = 0; foreach ( self::get_plugins() as $plugin ) { if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) { - $active++; + ++$active; } elseif ( 'inactive' === $plugin['status'] ) { - $inactive++; + ++$inactive; } } @@ -37,7 +37,5 @@ public function run() { $this->set_status( 'success' ); $this->set_message( "Less than {$threshold} percent of plugins are deactivated." ); } - } - } diff --git a/inc/checks/class-plugin-status.php b/inc/checks/class-plugin-status.php index f41f116..7c19c3d 100644 --- a/inc/checks/class-plugin-status.php +++ b/inc/checks/class-plugin-status.php @@ -66,5 +66,4 @@ public function run() { $this->set_message( "Plugin '{$this->name}' is '{$current_status}' as expected." ); } } - } diff --git a/inc/checks/class-plugin-update.php b/inc/checks/class-plugin-update.php index 8cb474c..7966aa5 100644 --- a/inc/checks/class-plugin-update.php +++ b/inc/checks/class-plugin-update.php @@ -14,7 +14,7 @@ public function run() { $update_count = 0; foreach ( $plugins as $plugin ) { if ( 'available' === $plugin['update'] ) { - $update_count++; + ++$update_count; } } @@ -28,7 +28,5 @@ public function run() { $this->set_status( 'success' ); $this->set_message( 'Plugins are up to date.' ); } - } - } diff --git a/inc/checks/class-plugin.php b/inc/checks/class-plugin.php index 2bad7c1..e7ac8d6 100644 --- a/inc/checks/class-plugin.php +++ b/inc/checks/class-plugin.php @@ -20,5 +20,4 @@ protected static function get_plugins() { self::$plugins = ! empty( $ret ) ? json_decode( $ret, true ) : array(); return self::$plugins; } - } diff --git a/inc/checks/class-theme-update.php b/inc/checks/class-theme-update.php index 2a203de..2db40ef 100644 --- a/inc/checks/class-theme-update.php +++ b/inc/checks/class-theme-update.php @@ -17,7 +17,7 @@ public function run() { $update_count = 0; foreach ( $themes as $theme ) { if ( 'available' === $theme['update'] ) { - $update_count++; + ++$update_count; } } @@ -31,7 +31,5 @@ public function run() { $this->set_status( 'success' ); $this->set_message( 'Themes are up to date.' ); } - } - } diff --git a/inc/class-checks.php b/inc/class-checks.php index 57cd10f..dd13f13 100644 --- a/inc/class-checks.php +++ b/inc/class-checks.php @@ -34,7 +34,7 @@ public static function register_config( $file ) { if ( ! empty( $check_data['_']['inherit'] ) ) { $inherited = $check_data['_']['inherit']; if ( 'default' === $inherited ) { - $inherited = dirname( dirname( __FILE__ ) ) . '/doctor.yml'; + $inherited = dirname( __DIR__ ) . '/doctor.yml'; } $inherited = self::absolutize( $inherited, dirname( $file ) ); if ( isset( $check_data['_']['skipped_checks'] ) ) { @@ -129,5 +129,4 @@ private static function absolutize( $path, $base ) { } return $path; } - } diff --git a/inc/class-command.php b/inc/class-command.php index 6000ed2..70b81eb 100644 --- a/inc/class-command.php +++ b/inc/class-command.php @@ -185,7 +185,7 @@ static function () { $check_count = count( $results ); $results = array_filter( $results, - function( $check ) { + function ( $check ) { return in_array( $check['status'], array( 'warning', 'error' ), true ); } ); @@ -202,7 +202,7 @@ function( $check ) { $results_with_error = array_filter( $results, - function( $check ) { + function ( $check ) { return 'error' === $check['status']; } ); @@ -309,7 +309,7 @@ private function load_wordpress_with_template() { WP_CLI::add_wp_hook( 'wp_redirect', - function( $to ) { + function ( $to ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter ob_start(); debug_print_backtrace(); $message = ob_get_clean(); @@ -372,7 +372,6 @@ private static function remove_decorations( $comment ) { * Get the path to the default config file */ private static function get_default_config() { - return dirname( dirname( __FILE__ ) ) . '/doctor.yml'; + return dirname( __DIR__ ) . '/doctor.yml'; } - }