From fd2241dbe4ff80c08aea586c97088ad5233c349b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Tue, 29 Sep 2020 16:54:10 +0300 Subject: [PATCH] pre-commit hook with auto install --- .gitignore | 2 ++ .travis.yml | 2 +- composer.json | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3dd436d..2532da4 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ phpunit.xml /nbproject .env .php_cs.cache +cghooks.lock + diff --git a/.travis.yml b/.travis.yml index 3df4a5c..d60a5ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_script: - flags="-o" - composer install $flags -script: composer run-script test +script: composer run-script ci after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/composer.json b/composer.json index 65d48d9..bbf75a0 100644 --- a/composer.json +++ b/composer.json @@ -35,14 +35,26 @@ "guzzlehttp/guzzle": "^7.1", "phpcompatibility/php-compatibility": "*", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "vlucas/phpdotenv": "^5.2" + "vlucas/phpdotenv": "^5.2", + "brainmaestro/composer-git-hooks": "^2.8" }, "scripts": { + "cghooks": "vendor/bin/cghooks", + "post-install-cmd": "cghooks add --ignore-lock", + "post-update-cmd": "cghooks update", "phpunit": "./vendor/bin/phpunit -c phpunit.xml.dist", "phpmd": "./vendor/bin/phpmd src text controversial,design,./phpmd.xml", "phpcs": "./vendor/bin/phpcs -p src --runtime-set testVersion 7.3", - "phpcbf": "./vendor/bin/phpcbf -p src", - "test": "composer run-script phpcs && composer run-script phpmd && composer run-script phpunit" + "lint": "composer run-script phpcs && composer run-script phpmd", + "ci": "composer run-script lint && composer run-script phpunit" + }, + "extra": { + "hooks": { + "pre-commit": [ + "echo => Running code quality tools...", + "composer run-script lint" + ] + } }, "prefer-stable": true, "license": "MIT"