diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f652edc9..42e7700b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -34,11 +34,13 @@ This package contains Composer scripts to quickly run the developer checks which After `composer install`, you can do: - - `composer test`: **Run all checks and tests** - this should pass cleanly before you submit a pull request. - - `composer lint`: Just run PHP and XML linters. - - `composer phpcs`: Just run PHPCS against this package. - - `composer phpunit`: Just run the unit tests. - - `composer ruleset`: Just run the ruleset tests. +- `composer lint`: Lint PHP and XML files in against parse errors. +- `composer cs`: Check the code style and code quality of the codebase via PHPCS. +- `composer test`: Run the unit tests for the VIPCS sniffs. +- `composer test-coverage`: Run the unit tests for the VIPCS sniffs with coverage enabled. +- `composer test-ruleset`: Run the ruleset tests for the VIPCS sniffs. +- `composer feature-completeness`: Check if all the VIPCS sniffs have tests. +- `composer check`: Run all checks (lint, CS, feature completeness) and tests - this should pass cleanly before you submit a pull request. ## Branches @@ -190,7 +192,7 @@ The ruleset tests, previously named here as _integration tests_, are our way of An example where it might not would be when a ruleset references a local sniff or a sniff from upstream (WPCS or PHPCS), but that the violation code, sniff name or category name has changed. Without a ruleset test, this would go unnoticed. -The `composer test` or `composer ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages. +The `composer check` or `composer test-ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages. When adding or changing a sniff, the ruleset test files should be updated to match. diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index 6c20a10d..6dbeb9a2 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -74,4 +74,4 @@ jobs: # For now, just check that all sniffs have unit tests. # At a later stage the documentation check can be activated. - name: Check sniff feature completeness - run: composer check-complete + run: composer feature-completeness diff --git a/bin/phpcs b/bin/phpcs deleted file mode 100755 index 5fe70f99..00000000 --- a/bin/phpcs +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -# -# Run PHPCS against VIP Coding Standards. -# -# This ensures that the code in the Sniffs and Tests follow the rules -# defined in the custom ruleset for this repo, `.phpcs.xml.dist`. -# -# EXAMPLE TO RUN LOCALLY: -# -# ./bin/phpcs - -"$(pwd)/vendor/bin/phpcs" diff --git a/composer.json b/composer.json index 87c1f5e9..3b99fc37 100644 --- a/composer.json +++ b/composer.json @@ -35,26 +35,34 @@ } }, "scripts": { - "install-codestandards": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run", - "ruleset": "bin/ruleset-tests", + "test-ruleset": "bin/ruleset-tests", "lint": [ "bin/php-lint", "bin/xml-lint" ], - "phpcs": "bin/phpcs", - "phpunit": "bin/unit-tests", - "coverage": "bin/unit-tests-coverage", - "check-complete": [ + "cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs", + "test": "bin/unit-tests", + "test-coverage": "bin/unit-tests-coverage", + "feature-completeness": [ "@php ./vendor/phpcsstandards/phpcsdevtools/bin/phpcs-check-feature-completeness -q ./WordPressVIPMinimum" ], - "test": [ + "check": [ "@lint", - "@ruleset", - "@phpunit", - "@phpcs", - "@check-complete" + "@tests-ruleset", + "@tests", + "@cs", + "@feature-completeness" ] }, + "scripts-descriptions": { + "lint": "VIPCS: Lint PHP and XML files in against parse errors.", + "cs": "VIPCS: Check the code style and code quality of the codebase via PHPCS.", + "test": "VIPCS: Run the unit tests for the VIPCS sniffs.", + "test-coverage": "VIPCS: Run the unit tests for the VIPCS sniffs with coverage enabled.", + "test-ruleset": "VIPCS: Run the ruleset tests for the VIPCS sniffs.", + "feature-completeness": "VIPCS: Check if all the VIPCS sniffs have tests.", + "check": "VIPCS: Run all checks (lint, CS, feature completeness) and tests." + }, "support": { "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki",