From 83c807d07aac362da4cdc996af42371695a6bb3f Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 19 Jun 2025 21:13:17 +0100 Subject: [PATCH 1/2] Add `composer` commands --- .scripts/{build.sh => create-plugin-zip.sh} | 6 ----- DEPLOYMENT.md | 19 +++++++------- TESTING.md | 29 ++++++++++++++++++++- composer.json | 21 ++++++++++++++- 4 files changed, 57 insertions(+), 18 deletions(-) rename .scripts/{build.sh => create-plugin-zip.sh} (85%) diff --git a/.scripts/build.sh b/.scripts/create-plugin-zip.sh similarity index 85% rename from .scripts/build.sh rename to .scripts/create-plugin-zip.sh index 2ffa4b61e..c7d170886 100644 --- a/.scripts/build.sh +++ b/.scripts/create-plugin-zip.sh @@ -1,9 +1,3 @@ -# Build ACTIONS-FILTERS.md -php create-actions-filters-docs.php - -# Generate .pot file -php -n $(which wp) i18n make-pot ../ ../languages/convertkit.pot - # Remove vendor directory cd .. rm -rf vendor diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 551ce4179..52ac2df1a 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -12,16 +12,6 @@ An *approved* Pull Request is when a PR passes all tests **and** has been approv In your Git client / command line, create a new branch called `release-x.x.x`, where `x.x.x` is the version number. -## Generate Localization File and Action/Filter Documentation - -On your local machine, switch to the new release branch. - -Run the `.scripts/build.sh` script, which will: - -- Generate the `languages/convertkit.pot` file -- Generate the [ACTIONS-FILTERS.md](ACTIONS-FILTERS.md) file -- Produce a `convertkit.zip` Plugin file, which may be used for any manual testing on other environments - ## Update the Plugin's Version Number We follow [Semantic Versioning](https://semver.org/). @@ -44,6 +34,15 @@ what took place in this version. Each line in the changelog should start with `Added`, `Fix` or `Updated`. +## Generate Localization File and Action/Filter Documentation + +On your local machine, switch to the new release branch. + +Run `composer create-release-assets`, which will: + +- Generate the `languages/convertkit.pot` file +- Generate the [ACTIONS-FILTERS.md](ACTIONS-FILTERS.md) file + ## Commit Changes Commit the updated files, which should comprise of: diff --git a/TESTING.md b/TESTING.md index e71e07494..05e5a4179 100644 --- a/TESTING.md +++ b/TESTING.md @@ -16,6 +16,18 @@ If you haven't yet set up your local development environment with the Kit Plugin If you haven't yet created a branch and made any code changes to the Plugin, refer to the [Development Guide](DEVELOPMENT.md) +> **Familiar with wp-browser, Codeception, PHP Coding Standards and PHPStan?** +> Write your tests +> Run tests using `composer test [folder]/[cest]` or `composer test-integration [test]` +> Run PHP Coding Standards using `composer phpcs` and `composer phpcs-tests` +> Run static analysis using `composer phpstan` +> [Submit a Pull Request](https://github.com/ConvertKit/convertkit-wordpress/compare). + +## + +- Write your tests +- `composer test + ## Write (or modify) a test If your work creates new functionality, write a test. @@ -377,6 +389,13 @@ To register your own helper function, add it to the `tests/Support/Helper/Wpunit ## Run Tests +> **Quick Commands** +> `composer test`: Run all End to End tests +> `composer test general`: Run all tests in the EndToEnd/general folder +> `composer test general/ActivateDeactivatePluginCest`: Run all tests in the EndToEnd/general/ActivateDeactivatePluginCest file +> `composer test-integration`: Run all Integration tests +> `composer test-integration APITest`: Run the Integration/APITest tests + Once you have written your code and test(s), run the tests to make sure there are no errors. If ChromeDriver isn't running, open a new Terminal window and enter the following command: @@ -392,13 +411,15 @@ vendor/bin/codecept build vendor/bin/codecept run EndToEnd vendor/bin/codecept run Integration ``` - If a test fails, you can inspect the output and screenshot at `tests/_output`. Any errors should be corrected by making applicable code or test changes. ## Run PHP CodeSniffer +> **Quick Command** +> `composer phpcs`: Run PHP Coding Standards on Plugin files + [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) checks that all Plugin code meets the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/). @@ -428,6 +449,9 @@ Need to change the PHP or WordPress coding standard rules applied? Either: ## Run PHPStan +> **Quick Command** +> `composer phpstan`: Run PHPStan static analysis on Plugin files + [PHPStan](https://phpstan.org) performs static analysis on the Plugin's PHP code. This ensures: - DocBlocks declarations are valid and uniform @@ -449,6 +473,9 @@ False positives [can be excluded by configuring](https://phpstan.org/user-guide/ ## Run PHP CodeSniffer for Tests +> **Quick Command** +> `composer phpcs-tests`: Run PHP Coding Standards on test files + In the Plugin's directory, run the following command to run PHP_CodeSniffer, which will check the code meets Coding Standards as defined in the `phpcs.tests.xml` configuration: diff --git a/composer.json b/composer.json index a622b9356..7af318254 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "convertkit/convertkit-wordpress", - "description": "ConvertKit WordPress Plugin", + "description": "Kit WordPress Plugin", "type": "project", "license": "GPLv3", "require": { @@ -16,6 +16,25 @@ }, "minimum-stability": "dev", "prefer-stable": true, + "scripts": { + "create-release-assets": [ + "php -n $(which wp) i18n make-pot . languages/convertkit.pot", + "@php .scripts/create-actions-filters-docs.php" + ], + "create-pot": "php -n $(which wp) i18n make-pot . languages/convertkit.pot", + "create-dev-docs": "@php .scripts/create-actions-filters-docs.php", + "phpcs": "vendor/bin/phpcs ./ -s -v", + "phpcs-tests": "vendor/bin/phpcs ./tests --standard=phpcs.tests.xml -s -v", + "phpstan": "vendor/bin/phpstan analyse --memory-limit=1250M", + "test": [ + "vendor/bin/codecept build", + "vendor/bin/codecept run EndToEnd @additional_args --fail-fast" + ], + "test-integration": [ + "vendor/bin/codecept build", + "vendor/bin/codecept run Integration @additional_args --fail-fast" + ] + }, "archive": { "exclude": [ "!vendor/*", From cac43b844f7ea02e9b848c90bf1bbea15e081177 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 23 Jun 2025 13:11:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Don=E2=80=99t=20append=20arguments=20to=20`?= =?UTF-8?q?codecept=20build`=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7af318254..0b79e95a7 100644 --- a/composer.json +++ b/composer.json @@ -27,11 +27,11 @@ "phpcs-tests": "vendor/bin/phpcs ./tests --standard=phpcs.tests.xml -s -v", "phpstan": "vendor/bin/phpstan analyse --memory-limit=1250M", "test": [ - "vendor/bin/codecept build", + "vendor/bin/codecept build @no_additional_args", "vendor/bin/codecept run EndToEnd @additional_args --fail-fast" ], "test-integration": [ - "vendor/bin/codecept build", + "vendor/bin/codecept build @no_additional_args", "vendor/bin/codecept run Integration @additional_args --fail-fast" ] },