diff --git a/.github/workflows/TestStatic.yml b/.github/workflows/TestStatic.yml index ab07be88..12511639 100644 --- a/.github/workflows/TestStatic.yml +++ b/.github/workflows/TestStatic.yml @@ -52,7 +52,7 @@ jobs: - name: Verify files were created run: | - test -f phpcs.xml + test -f phpcs.xml.dist - name: Fix settings.php run: | diff --git a/README.md b/README.md index 15f7f4f2..f26251e2 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ for a Drupal site, including: - [Setup](#setup-1) - [Testing](#testing) - [Static Tests](#static-tests) - - [Excluding Files from PHP_CodeSniffer](#excluding-files-from-php_codesniffer) + - [Altering PHP_CodeSniffer Configuration](#altering-php_codesniffer-configuration) - [Functional Tests](#functional-tests) - [PHPUnit](#phpunit) - [Nightwatch](#nightwatch) @@ -41,6 +41,7 @@ for a Drupal site, including: - [Pantheon](#pantheon-2) - [Tugboat](#tugboat) - [Contributor Docs](#contributor-docs) + - [Local Development](#local-development) - [Peer Review Guidelines for Automated Updates](#peer-review-guidelines-for-automated-updates) - [Handling Version Ranges](#handling-version-ranges) - [Handling Test Failures](#handling-test-failures) @@ -228,34 +229,18 @@ All the below static code analysis tests can be run with `task test:static` | PHPCS | task test:phpcs | Runs PHPCS with Drupal coding standards provided by [Coder module](https://www.drupal.org/project/coder | -#### Excluding Files from PHP_CodeSniffer - -`phpcs.xml` can be altered using Drupal's -[composer scaffold](https://www.drupal.org/docs/develop/using-composer/using-drupals-composer-scaffold#toc_4). +#### Altering PHP_CodeSniffer Configuration +- Create `phpcs.xml` to override the `phpcs.xml.dist` file with overrides being done in: + ``` + + + ``` - Edit `phpcs.xml` in the root of your project, e.g. to add an exclude pattern: ``` web/sites/sites.php ``` -- Create a patch file - ``` - diff -urN vendor/lullabot/drainpipe-dev/scaffold/phpcs.xml phpcs.xml > patches/custom/phpcs.xml.patch - ``` -- Add the patch to `composer.json` - ``` - "scripts": { - "pre-drupal-scaffold-cmd": [ - "if [ -f \"phpcs.xml\" ]; then rm phpcs.xml; fi" - ], - "post-drupal-scaffold-cmd": [ - "if [ -f \"phpcs.xml\" ]; then patch phpcs.xml < patches/custom/phpcs.xml.patch; fi" - ] - }, - ``` - The pre hook is needed otherwise the composer scaffold attempts to re-patch a file it no longer has control over when running `composer install --no-dev` -- Delete the `vendor` directory and `phpcs.xml` and then run `composer install` - to verify everything works as expected ### Functional Tests @@ -681,6 +666,10 @@ Peer Reviewing by looking at PR code changes is nice. Testing PR code changes on real sites is extra beneficial. +### Local Development + +In order to test local changes follow the instructions for the [test script](./docs/test-script.md). + ### Peer Review Guidelines for Automated Updates These are guidelines for conducting peer reviews on automated dependency update pull requests created by Renovate. diff --git a/docs/test-script.md b/docs/test-script.md index ae1e0b36..ec54d934 100644 --- a/docs/test-script.md +++ b/docs/test-script.md @@ -3,7 +3,7 @@ A test script is available in `tests/local-test.sh` to setup a Drupal site with Drainpipe packages installed from your local checkout. -Go to the directory above `drainpipe` and run the `tests/local-hest.sh` script +Go to the directory above `drainpipe` and run the `tests/local-test.sh` script to setup a new test site e.g. ``` ❯ pwd diff --git a/drainpipe-dev/composer.json b/drainpipe-dev/composer.json index a69fb84f..57fb3782 100644 --- a/drainpipe-dev/composer.json +++ b/drainpipe-dev/composer.json @@ -48,7 +48,7 @@ "[web-root]/sites/sites.php": "scaffold/nightwatch/sites.php", "[project-root]/.ddev/docker-compose.selenium.yaml": "scaffold/nightwatch/docker-compose.selenium.yaml", "[project-root]/test/nightwatch/example.nightwatch.js": "scaffold/nightwatch/example.nightwatch.js", - "[project-root]/phpcs.xml": "scaffold/phpcs.xml" + "[project-root]/phpcs.xml.dist": "scaffold/phpcs.xml.dist" } } }, diff --git a/drainpipe-dev/scaffold/phpcs.xml b/drainpipe-dev/scaffold/phpcs.xml.dist similarity index 100% rename from drainpipe-dev/scaffold/phpcs.xml rename to drainpipe-dev/scaffold/phpcs.xml.dist diff --git a/tasks/test.yml b/tasks/test.yml index 5608db95..e5fabfa4 100644 --- a/tasks/test.yml +++ b/tasks/test.yml @@ -137,8 +137,7 @@ tasks: desc: Runs PHPCS with Drupal Coding Standards summary: | Check your code against Drupal's coding standards. To override the default - ruleset, copy vendor/lullabot/drainpipe/scaffold/phpcs.xml to phpcs.xml - in the root of your project and edit as needed. + ruleset, create a phpcs.xml file and extend phpcs.xml.dist cmds: - | {{ .FUNC_ENSURE_DIRS }}