-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dbdabd3
Showing
32 changed files
with
3,399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
* text=auto eol=lf | ||
|
||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
.gitignore export-ignore | ||
.php_cs export-ignore | ||
.travis.yml export-ignore | ||
bin/ export-ignore | ||
CHANGELOG.md export-ignore | ||
LICENSE.md export-ignore | ||
phpunit.xml.dist export-ignore | ||
README.md export-ignore | ||
tests/ export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# How to contribute | ||
|
||
Thanks for considering to contribute to `composer-multitest`. Please follow these simple guidelines: | ||
|
||
- All code __MUST__ follow the PSR-2 coding standard. Please see [PSR-2](http://www.php-fig.org/psr/psr-2/) for more details. | ||
|
||
- Coding standard compliance __MUST__ be ensured before committing or opening pull requests by running `composer cm:cs-fix` or `composer cm:cs-lint` in the root directory of this repository. | ||
|
||
- All upstreamed contributions __MUST__ use [feature / topic branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows) to ease merging. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
vendor/ | ||
coverage-reports/ | ||
composer.lock | ||
.php_cs.cache | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__); | ||
|
||
$rules = [ | ||
'psr0' => false, | ||
'@PSR2' => true, | ||
'short_array_syntax' => true, | ||
'phpdoc_order' => true, | ||
'ordered_imports' => true, | ||
]; | ||
|
||
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRules($rules) | ||
->finder($finder) | ||
->setUsingCache(true) | ||
->setCacheFile($cacheDir . '/.php_cs.cache'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
language: php | ||
|
||
git: | ||
depth: 2 | ||
|
||
matrix: | ||
include: | ||
- php: hhvm | ||
- php: nightly | ||
- php: 7.1 | ||
env: LINT=true | ||
- php: 7.0 | ||
env: DISABLE_XDEBUG=true | ||
- php: 5.6 | ||
env: DISABLE_XDEBUG=true | ||
fast_finish: true | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.php-cs-fixer | ||
|
||
notifications: | ||
email: false | ||
|
||
before_script: | ||
- if [[ $DISABLE_XDEBUG = true ]]; then | ||
phpenv config-rm xdebug.ini; | ||
fi | ||
- travis_retry composer self-update | ||
- travis_retry composer install --no-interaction | ||
- travis_retry composer dump-autoload --optimize | ||
|
||
script: | ||
# Use custom script to avoid the risk of terminating the build process | ||
- ./bin/travis/fail-non-feature-topic-branch-pull-request | ||
# Verify coding standard compliance only once | ||
- if [[ $LINT = true ]]; then | ||
composer cm:cs-lint; | ||
fi | ||
- if [[ $(( $TRAVIS_BUILD_NUMBER % 25 )) = 0 ]]; then | ||
composer cm:test-all; | ||
else | ||
composer cm:test; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
#### v1.0.0 `2016-10-20` | ||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Raphael Stolt | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# composer-multitest | ||
[![Build Status](https://secure.travis-ci.org/raphaelstolt/composer-multitest.png)](http://travis-ci.org/raphaelstolt/composer-multitest) | ||
[![Version](http://img.shields.io/packagist/v/stolt/composer-multitest.svg?style=flat)](https://packagist.org/packages/stolt/composer-multitest) | ||
![PHP Version](http://img.shields.io/badge/php-5.6+-ff69b4.svg) | ||
[![composer.lock available](https://poser.pugx.org/stolt/composer-multitest/composerlock)](https://packagist.org/packages/stolt/composer-multitest) | ||
|
||
`composer-multitest` is a Composer script that runs a `test` or `spec` Composer script against multiple PHP versions managed by [PHPBrew](https://github.com/phpbrew) or [phpenv](https://github.com/phpenv/phpenv). Kind of a local [Travis CI](https://travis-ci.org/). | ||
|
||
## Assumptions | ||
As `composer-multitest` utilizes phpenv and PHPBrew it's assumed that at least one of them is installed and manages several PHP versions. It will first look for phpenv managed versions and when this fails it will subsequently look for PHPBrew managed ones. | ||
|
||
The versions to test against are read from the local Travis CI configuration so it's assumed that one is present. Versions present in the Travis CI configuration not having a phpenv or PHPBrew managed version will __not__ be executed. | ||
|
||
The Composer scripts `composer-multitest` will run __MUST__ be named `test` or `spec` and they __can__ be defined in a Composer script namespace like `library:test|spec`. | ||
|
||
## Installation | ||
The Composer script should be installed as a development dependency through Composer. | ||
|
||
``` bash | ||
composer require --dev stolt/composer-multitest | ||
``` | ||
|
||
## Usage | ||
Once installed add the Composer script to the existing `composer.json` and use it afterwards via `composer multitest`. | ||
|
||
``` json | ||
{ | ||
"scripts": { | ||
"multitest": "Stolt\\Composer\\Multitest::run" | ||
}, | ||
} | ||
``` | ||
|
||
## Example output | ||
The follow console output shows an example multitest run against two PHP versions. | ||
``` bash | ||
❯ composer multitest | ||
> Stolt\Composer\Multitest::run | ||
>> Switching to 'php-7.0.4'. | ||
>> Running 'composer lpv:test'. | ||
PHPUnit 5.6.1 by Sebastian Bergmann and contributors. | ||
|
||
................................................................. 65 / 96 ( 67%) | ||
............................... 96 / 96 (100%) | ||
|
||
Time: 591 ms, Memory: 12.25MB | ||
|
||
OK (96 tests, 150 assertions) | ||
|
||
>> Switching to 'php-5.6.19'. | ||
>> Running 'composer lpv:test'. | ||
PHPUnit 5.6.1 by Sebastian Bergmann and contributors. | ||
|
||
................................................................. 65 / 96 ( 67%) | ||
............................... 96 / 96 (100%) | ||
|
||
Time: 591 ms, Memory: 12.25MB | ||
|
||
OK (96 tests, 150 assertions) | ||
|
||
>> Switching back to 'php-5.6.19'. | ||
❯ echo $? | ||
0 | ||
❯ | ||
``` | ||
|
||
#### Running tests without integration tests | ||
``` bash | ||
composer cm:test | ||
``` | ||
|
||
#### Running all tests | ||
``` bash | ||
composer cm:test-all | ||
``` | ||
|
||
#### License | ||
This Composer script is licensed under the MIT license. Please see [LICENSE](LICENSE.md) for more details. | ||
|
||
#### Changelog | ||
Please see [CHANGELOG](CHANGELOG.md) for more details. | ||
|
||
#### Contributing | ||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
set -e | ||
if [[ $TRAVIS_PULL_REQUEST_BRANCH = master ]]; then | ||
echo "Please open pull request from a feature / topic branch."; | ||
exit 1; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "stolt/composer-multitest", | ||
"description": "Composer script to run a Composer test or spec script against all versions managed by PHPBrew or phpenv.", | ||
"keywords": ["composer script", "phpbrew", "phpenv", "multitest", "local ci"], | ||
"homepage": "https://github.com/raphaelstolt/composer-phpbrew-multitest", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Raphael Stolt", | ||
"email": "raphael.stolt@gmail.com" | ||
} | ||
], | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "stable", | ||
"require": { | ||
"php": ">=5.6", | ||
"symfony/process": "^3.1", | ||
"symfony/yaml": "^3.1" | ||
}, | ||
"require-dev": { | ||
"composer/composer": "^1.0", | ||
"friendsofphp/php-cs-fixer": "2.0.0-alpha", | ||
"mockery/mockery": "^0.9.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Stolt\\Composer\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Stolt\\Composer\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"cm:test": "phpunit", | ||
"cm:test-with-coverage": "phpunit --coverage-html coverage-reports", | ||
"cm:cs-fix": "php-cs-fixer fix . -vv || true", | ||
"cm:cs-lint": "php-cs-fixer fix --diff --verbose --dry-run" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="true" | ||
syntaxCheck="false"> | ||
<testsuites> | ||
<testsuite name="composer-phpbrew-multitest"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Stolt\Composer\Configuration; | ||
|
||
use Stolt\Composer\Configuration\Composer\Exceptions\ScriptNotResolvable; | ||
use Stolt\Composer\Configuration\Exceptions\Blank; | ||
use Stolt\Composer\Configuration\Exceptions\NonExistent; | ||
use Symfony\Component\Process\Process; | ||
|
||
class Composer | ||
{ | ||
const CONFIGURATION = 'composer.json'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $expectedScriptNames = ['test', 'spec']; | ||
|
||
/** | ||
* Get the configured test or spec Composer script. | ||
* | ||
* @throws Stolt\Composer\Configuration\Exceptions\Blank | ||
* @throws Stolt\Composer\Configuration\Exceptions\NonExistent | ||
* @throws Stolt\Composer\Configuration\Composer\Exceptions\ScriptNotResolvable | ||
* @return Symfony\Component\Process\Process | ||
*/ | ||
public function getTestOrSpecComposerScript() | ||
{ | ||
$composerConfiguration = getcwd() | ||
. DIRECTORY_SEPARATOR | ||
. self::CONFIGURATION; | ||
|
||
if (!file_exists(self::CONFIGURATION)) { | ||
$message = "Couldn't find a " . self::CONFIGURATION . "."; | ||
throw new NonExistent($message); | ||
} | ||
|
||
$configuration = file_get_contents($composerConfiguration); | ||
|
||
if (trim($configuration) === '') { | ||
$message = 'The ' . self::CONFIGURATION . ' is empty.'; | ||
throw new Blank($message); | ||
} | ||
|
||
$composerConfiguration = json_decode($configuration, true); | ||
|
||
if (isset($composerConfiguration['scripts'])) { | ||
foreach ($composerConfiguration['scripts'] as $name => $script) { | ||
if (strstr($name, 'test') && substr($name, -4) === 'test') { | ||
return new Process('composer ' . $name); | ||
} | ||
if (strstr($name, 'spec') && substr($name, -4) === 'spec') { | ||
return new Process('composer ' . $name); | ||
} | ||
} | ||
|
||
$message = 'Unable to resolve test or spec Composer script.'; | ||
throw new ScriptNotResolvable($message); | ||
} | ||
|
||
$message = 'There a no Composer scripts defined.'; | ||
throw new ScriptNotResolvable($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Stolt\Composer\Configuration\Composer\Exceptions; | ||
|
||
class NoScriptsDefined extends \Exception | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Configuration/Composer/Exceptions/ScriptNotResolvable.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Stolt\Composer\Configuration\Composer\Exceptions; | ||
|
||
class ScriptNotResolvable extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Stolt\Composer\Configuration\Exceptions; | ||
|
||
class Blank extends \Exception | ||
{ | ||
} |
Oops, something went wrong.