Просмотр исходного кода

DX: Introduce Composer scripts as common DX (#6839)

Greg Korba 1 год назад
Родитель
Сommit
f3f35bda66
3 измененных файлов с 61 добавлено и 9 удалено
  1. 6 7
      CONTRIBUTING.md
  2. 54 0
      composer.json
  3. 1 2
      phpstan.dist.neon

+ 6 - 7
CONTRIBUTING.md

@@ -26,13 +26,12 @@ Symfony projects for instance).
 * Create a new branch, e.g. `feature-foo` or `bugfix-bar`.
 * Make changes.
 * If you are adding functionality or fixing a bug - add a test! Prefer adding new test cases over modifying existing ones.
-* Make sure there is no wrong file permissions in the repository: `./dev-tools/check_file_permissions.sh`.
-* Make sure there is no trailing spaces in the code: `./dev-tools/check_trailing_spaces.sh`.
-* Update documentation: `php dev-tools/doc.php`. This requires the highest version of PHP supported by PHP CS Fixer. If it is not installed on your system, you can run it in a Docker container instead: `docker-compose run php-8.2 php dev-tools/doc.php`.
-* Install dev tools: `dev-tools/install.sh`
-* Run static analysis using PHPStan: `php -d memory_limit=256M dev-tools/vendor/bin/phpstan analyse`
-* Check if tests pass: `vendor/bin/phpunit`.
-* Fix project itself: `php php-cs-fixer fix`.
+* Make sure there is dev environment is correct: `composer dev-tools:check`.
+* Update documentation: `composer docs`. This requires the highest version of PHP supported by PHP CS Fixer. If it is not installed on your system, you can run it in a Docker container instead: `docker-compose run php-8.2 php dev-tools/doc.php`.
+* Install dev tools: `composer dev-tools:install`.
+* Run [PHPStan](https://phpstan.org/user-guide/getting-started): `composer phpstan`.
+* Check if tests pass: `composer test`.
+* Fix project itself: `composer cs:fix`.
 
 ## Working With Docker
 

+ 54 - 0
composer.json

@@ -78,5 +78,59 @@
             "ergebnis/composer-normalize": true
         },
         "sort-packages": true
+    },
+    "scripts": {
+        "cs:check": "@php php-cs-fixer fix --dry-run --diff",
+        "cs:fix": "@php php-cs-fixer fix",
+        "dev-tools:check": [
+            "./dev-tools/check_file_permissions.sh",
+            "./dev-tools/check_trailing_spaces.sh"
+        ],
+        "dev-tools:docs": "@php dev-tools/doc.php",
+        "dev-tools:install": "@composer -d dev-tools install",
+        "docs": "@dev-tools:docs",
+        "mess-detector": "@php dev-tools/vendor/bin/phpmd . ansi phpmd.xml",
+        "phpstan": "@php -d memory_limit=256M dev-tools/vendor/bin/phpstan analyse",
+        "phpstan:baseline": "@php -d memory_limit=256M dev-tools/vendor/bin/phpstan analyse --generate-baseline=./dev-tools/phpstan/baseline.php",
+        "qa": "@quality-assurance",
+        "quality-assurance": [
+            "Composer\\Config::disableProcessTimeout",
+            "@sa",
+            "@test"
+        ],
+        "sa": "@static-analysis",
+        "static-analysis": [
+            "@phpstan",
+            "@cs:check"
+        ],
+        "test": "@test:all",
+        "test:all": [
+            "Composer\\Config::disableProcessTimeout",
+            "paraunit run --testsuite all"
+        ],
+        "test:coverage": [
+            "Composer\\Config::disableProcessTimeout",
+            "paraunit run --testsuite coverage"
+        ]
+    },
+    "scripts-descriptions": {
+        "cs:check": "Check coding standards",
+        "cs:diff": "Check coding standards in modified files",
+        "cs:diff-fix": "Fix coding standards in modified files",
+        "cs:fix": "Fix coding standards",
+        "dev-tools:check": "Check DEV environment's requirements",
+        "dev-tools:docs": "Regenerate docs",
+        "dev-tools:install": "Install DEV tools",
+        "docs": "Regenerate docs",
+        "mess-detector": "Analyse code with Mess Detector",
+        "phpstan": "Run PHPStan analysis",
+        "phpstan:baseline": "Dump PHPStan baseline file - use only for updating, do not add new errors when possible",
+        "qa": "Run QA suite",
+        "quality-assurance": "Run QA suite",
+        "sa": "Run static analysis",
+        "static-analysis": "Run static analysis",
+        "test": "Run tests",
+        "test:all": "Run all tests",
+        "test:coverage": "Run tool-related tests"
     }
 }

+ 1 - 2
phpstan.dist.neon

@@ -1,8 +1,7 @@
 includes:
     - dev-tools/vendor/phpstan/phpstan/conf/bleedingEdge.neon
 
-    # Baseline, should only shrink! To regenerate it, just execute:
-    # dev-tools/vendor/bin/phpstan analyse --generate-baseline=dev-tools/phpstan/baseline.php
+    # Baseline, should only shrink! To regenerate it, just execute `composer phpstan:baseline`.
     - dev-tools/phpstan/baseline.php
 
 parameters: