javihgil / composer-ci-tools
Library to integrate some testing and developing tools into composer scripts
Requires
- php: >=5.3.3
- symfony/filesystem: ~2.3|~3.0
- symfony/options-resolver: ~2.3|~3.0
- symfony/process: ~2.3|~3.0
Requires (Dev)
- asm89/twig-lint: dev-master
- composer/composer: 1.1.*
- friendsofphp/php-cs-fixer: ~1.12
- hexmedia/yaml-linter: 0.1
- leaphub/phpcs-symfony2-standard: ~2.0
- mockery/mockery: ~0.9
- phpunit/phpunit: 4.8.*
- sebastian/phpcpd: 2.0.*
- sensiolabs/security-checker: ~3.0
- squizlabs/php_codesniffer: ~2.0
- symfony/finder: ~2.3|~3.0
Suggests
- asm89/twig-lint: Twig lint for no symfony projects
- friendsofphp/php-cs-fixer: Fix Code Style. More info in http://cs.sensiolabs.org/
- hexmedia/yaml-linter: Yaml lint for no symfony projects
- leaphub/phpcs-symfony2-standard: Symfony2 standard for PHP_CodeSniffer
- phpunit/phpunit: Use a specific local version of phpunit
- sebastian/phpcpd: Copy paste detector
- sensiolabs/security-checker: Check for reported vulnerabilities in project dependencies
- squizlabs/PHP_CodeSniffer: Code style checks
- symfony/finder: Install symfony/finder to use this scripts in Windows platforms
README
This library provides a easy way to integrate some common developing and testing tasks in the middle of composer workflow.
The advantage of include your CI scripts into composer configuration is to use a unique tool (that is also installed) that integrates the development and testing logic.
Configure
$ composer require javihgil/composer-ci-tools:~1.0 --dev
Usage
This is an example composer.json:
{
"extra": {
"ci-tools": {
"global": {
"log-format": " <fg=cyan>> %s</>"
},
"phpunit": {
"report-config": "phpunit-reports.xml"
},
"git": {
"commit-msg-regex": "/^[a-z\\s\\-0-9\\.]{20,}$/i",
"commit-msg-error": "The commit message must be at least 20 characters long"
},
"phpcs" : {
"standard": "PSR2",
}
}
},
"scripts": {
"post-install-cmd": [
"Jhg\\ComposerCiTools\\GitHooksInstaller::preCommit",
"Jhg\\ComposerCiTools\\GitHooksInstaller::commitMsg"
],
"pre-commit-hook": [
"Jhg\\ComposerCiTools\\Lint::php",
"Jhg\\ComposerCiTools\\PhpUnit::test"
],
"commit-msg-hook": [
"Jhg\\ComposerCiTools\\Git::commitMsgRegex"
],
"test": [
"@composer validate",
"Jhg\\ComposerCiTools\\PhpCsFixer::fix",
"Jhg\\ComposerCiTools\\Lint::phpLazy",
"Jhg\\ComposerCiTools\\PhpUnit::test",
"Jhg\\ComposerCiTools\\SecurityChecker::check"
],
"report": [
"@composer install",
"Jhg\\ComposerCiTools\\PhpUnit::report"
"Jhg\\ComposerCiTools\\PhpCs::report"
]
}
}
This composer.json provides a test and a report task. These can be executed with:
$ composer test
./composer.json is valid
> Jhg\ComposerCiTools\Lint::php
> No syntax errors detected in ./src/Script/Lint.php
> No syntax errors detected in ./src/Script/SecurityChecker.php
> No syntax errors detected in ./src/Script/Gulp.php
> No syntax errors detected in ./src/Script/AbstractScriptHandler.php
> No syntax errors detected in ./src/Script/Write.php
> No syntax errors detected in ./src/Script/GitHooksInstaller.php
> No syntax errors detected in ./src/Script/PhpCpd.php
> No syntax errors detected in ./src/Script/PhpCsFixer.php
> No syntax errors detected in ./src/Script/PhpUnit.php
> No syntax errors detected in ./src/Script/PhpCs.php
> Jhg\ComposerCiTools\PhpUnit::test
> PHPUnit 4.8.24 by Sebastian Bergmann and contributors.
> Time: 41 ms, Memory: 4.50Mb
> No tests executed!
$ composer report
> Jhg\ComposerCiTools\PhpUnit::report
> PHPUnit 4.8.24 by Sebastian Bergmann and contributors.
> Time: 850 ms, Memory: 7.00Mb
>
> No tests executed!
> Generating code coverage report in HTML format ...
> done
Also uses a preCommit GIT hook, that is configured after install command execution. Every pre-commit Hook lauched by GIT will execute the pre-commit-hook task. In this example, the behaviour is that before commiting in git php syntax will be verified and PhpUnit tests passed.
Reference
Global configurations
Commands
Misc
- Create custom script
- Composer useful configurations
- Symfony usual configuration
- Common problems
- Examples
Note for Windows users
Windows platform is not fully supported. This tool is not tested under Windows environments.
License
This project is licensed under the terms of the MIT license. See the LICENSE file.