Skip to content

Commit

Permalink
Composer: Update script names (#741)
Browse files Browse the repository at this point in the history
* Composer: Update script names

Better align with suggested script names at https://github.com/php-pds/composer-script-names

* Composer: Add script descriptions

These appear when calling `composer list`.

* Composer: Remove install-codestandards script

This is no longer needed; the list of installed code standards for PHPCS is reliably updated on `composer install` and `composer update`.

* Composer: Remove script and call PHPCS directly

Has the advantages of:
 - working on Windows machines.
 - extra CLI args such as `--sniffs` can be passed when calling `composer cs`.
  • Loading branch information
GaryJones authored Jan 31, 2023
1 parent 5e805d6 commit 24af5df
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
14 changes: 8 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions bin/phpcs

This file was deleted.

30 changes: 19 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 24af5df

Please sign in to comment.