Updated Rector to commit 58e7624357

58e7624357 [scoped] Run e2e parallel, suck in existing tests (#16)
This commit is contained in:
Tomas Votruba 2021-05-11 16:11:30 +00:00
parent 4b5959fb1e
commit a3f9df34d6
19 changed files with 336 additions and 108 deletions

View File

@ -1,4 +1,4 @@
name: Rector Run
name: Along Other Packages
on:
pull_request: null
@ -7,7 +7,7 @@ on:
- main
jobs:
rector_run:
along_other_packages:
runs-on: ubuntu-latest
strategy:
@ -16,21 +16,17 @@ jobs:
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
commands:
-
name: 'Finalize Entity'
install: composer require doctrine/orm
run: vendor/bin/rector process ../tests/fixture-finalize --config ../ci/rector-finalize.php --ansi
name: 'Composer Dependency'
install: composer require symfony/console:2.8 --ansi
run: vendor/bin/rector list --debug --ansi
-
name: 'Composer Dependency'
install: composer require symfony/console 2.8
run: vendor/bin/rector list --debug --ansi
name: 'PHP Parser 3.1'
install: composer require nikic/php-parser:^3.1 --ansi
-
name: 'Along PHPStan'
install: composer require phpstan/phpstan:0.12.86 --dev --ansi
run: |
vendor/bin/rector list --ansi
vendor/bin/phpstan -h --ansi
name: "PHP ${{ matrix.php_version }}"
@ -42,19 +38,19 @@ jobs:
php-version: ${{ matrix.php_version }}
coverage: none
# wait for deploy to packagist
- run: sleep 70
- run: |
mkdir standalone
cd standalone
# wait for deploy to packagist
sleep 70
- run: |
cd standalone
# run
composer require rector/rector:dev-main --dev --ansi
${{ matrix.commands.install }}
working-directory: standalone
-
run: |
cd standalone
${{ matrix.commands.run }}
run: vendor/bin/rector list --ansi
working-directory: standalone

View File

@ -1,3 +1,6 @@
# This workflow runs system tests: Use the Rector application from the source
# checkout to process "fixture" projects in tests/system-tests
# to see if those can be processed successfully
name: End to End tests
on:
@ -12,39 +15,28 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0']
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
directory:
- 'e2e/attributes'
- 'e2e/dont-execute-code'
- 'e2e/finalize'
- 'e2e/parse-php7-code'
- 'e2e/parse-php8-code'
name: End to end test - ${{ matrix.directory }}
name: PHP ${{ matrix.php }} system tests
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov
php-version: ${{ matrix.php_version }}
coverage: none
# This workflow runs system tests: Use the Rector application from the source
# checkout to process "fixture" projects in tests/system-tests
# to see if those can be processed successfully
-
run: composer install --ansi
working-directory: ${{ matrix.directory }}
- name: Generate Composer autoloaders in fixture directories
run: |
for FIXTURE in `find e2e -mindepth 1 -maxdepth 1 -type d`; do
(cd $FIXTURE; composer install --no-progress --ansi)
done
- name: Run system tests
run: |
HAS_FAILURES=0
for FIXTURE in `find e2e -mindepth 1 -maxdepth 1 -type d`; do
echo "-----> Running $FIXTURE <-----"
if (cd $FIXTURE; ../../bin/rector process --dry-run --clear-cache); then
echo "-----> Result: OK <-----"
else
echo "-----> Result: FAILED <-----"
HAS_FAILURES=1
fi
done
exit $HAS_FAILURES
-
run: ../../bin/rector process --dry-run --ansi
working-directory: ${{ matrix.directory }}

View File

@ -1,21 +0,0 @@
name: PHP 8 Attributes
on:
pull_request: null
push:
branches:
- main
jobs:
php8_attributes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
- run: bin/rector process tests/fixture-php8-attributes --config ci/rector-attributes.php --ansi

View File

@ -1,25 +0,0 @@
name: PHP Parser 3
on:
pull_request: null
push:
branches:
- main
jobs:
php_parser_3:
runs-on: ubuntu-latest
steps:
-
uses: shivammathur/setup-php@v2
with:
php-version: 7.1
coverage: none
# wait for deploy to packagist
- run: sleep 70
- run: composer require nikic/php-parser:^3.1 --ansi
- run: composer require rector/rector:dev-main --dev --ansi
- run: vendor/bin/rector list --ansi

View File

@ -0,0 +1,5 @@
{
"autoload-dev": {
"directories": ["stubs"]
}
}

16
e2e/attributes/rector.php Normal file
View File

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Symfony\Set\SymfonySetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SymfonySetList::SYMFONY_52);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
$parameters->set(Option::SOURCE, [__DIR__ . '/src']);
};

View File

@ -0,0 +1,13 @@
<?php
use Symfony\Component\Routing\Annotation\Route;
class SomeController
{
/**
* @Route()
*/
public function someMethod()
{
}
}

View File

@ -0,0 +1,177 @@
<?php
/** @changelog https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/Annotation/Route.php */
declare(strict_types=1);
namespace Symfony\Component\Routing\Annotation;
if (class_exists('Symfony\Component\Routing\Annotation\Route')) {
return;
}
/**
* @Annotation
* @Target({"CLASS", "METHOD"})
*/
class Route
{
private $path;
private $localizedPaths = [];
private $name;
private $requirements = [];
private $options = [];
private $defaults = [];
private $host;
private $methods = [];
private $schemes = [];
private $condition;
private $locale;
private $format;
private $utf8;
/**
* @param array $data An array of key/value parameters
*
* @throws \BadMethodCallException
*/
public function __construct(array $data)
{
if (isset($data['localized_paths'])) {
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', \get_class($this)));
}
if (isset($data['value'])) {
$data[\is_array($data['value']) ? 'localized_paths' : 'path'] = $data['value'];
unset($data['value']);
}
if (isset($data['path']) && \is_array($data['path'])) {
$data['localized_paths'] = $data['path'];
unset($data['path']);
}
if (isset($data['locale'])) {
$data['defaults']['_locale'] = $data['locale'];
unset($data['locale']);
}
if (isset($data['format'])) {
$data['defaults']['_format'] = $data['format'];
unset($data['format']);
}
if (isset($data['utf8'])) {
$data['options']['utf8'] = filter_var($data['utf8'], FILTER_VALIDATE_BOOLEAN) ?: false;
unset($data['utf8']);
}
foreach ($data as $key => $value) {
$method = 'set'.str_replace('_', '', $key);
if (!method_exists($this, $method)) {
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, \get_class($this)));
}
$this->$method($value);
}
}
public function setPath($path)
{
$this->path = $path;
}
public function getPath()
{
return $this->path;
}
public function setLocalizedPaths(array $localizedPaths)
{
$this->localizedPaths = $localizedPaths;
}
public function getLocalizedPaths(): array
{
return $this->localizedPaths;
}
public function setHost($pattern)
{
$this->host = $pattern;
}
public function getHost()
{
return $this->host;
}
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setRequirements($requirements)
{
$this->requirements = $requirements;
}
public function getRequirements()
{
return $this->requirements;
}
public function setOptions($options)
{
$this->options = $options;
}
public function getOptions()
{
return $this->options;
}
public function setDefaults($defaults)
{
$this->defaults = $defaults;
}
public function getDefaults()
{
return $this->defaults;
}
public function setSchemes($schemes)
{
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
}
public function getSchemes()
{
return $this->schemes;
}
public function setMethods($methods)
{
$this->methods = \is_array($methods) ? $methods : [$methods];
}
public function getMethods()
{
return $this->methods;
}
public function setCondition($condition)
{
$this->condition = $condition;
}
public function getCondition()
{
return $this->condition;
}
}

View File

@ -0,0 +1,10 @@
{
"autoload": {
"psr-4": {
"Rector\\e2e\\": "src"
}
},
"require-dev": {
"doctrine/orm": "^2.7"
}
}

11
e2e/finalize/rector.php Normal file
View File

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(FinalizeClassesWithoutChildrenRector::class);
};

View File

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Rector\e2e;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class SkipSomeEntity
{
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Rector\e2e;
class SomeClassWithoutChildren
{
}

View File

@ -0,0 +1,7 @@
{
"autoload": {
"psr-4": {
"Foo\\": "src"
}
}
}

View File

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__.'/src']);
$containerConfigurator->import(SetList::PHP_53);
};

View File

@ -0,0 +1,10 @@
<?php
namespace Foo;
class Foo
{
public function __construct(
public string $property = 'value',
) {}
}

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264::getLoader();
return ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264
class ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7195c74efd61d60849353b7e230e5264::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitdb1c54988d45f3f5809e48373d975091::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit7195c74efd61d60849353b7e230e5264::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire7195c74efd61d60849353b7e230e5264($fileIdentifier, $file);
composerRequiredb1c54988d45f3f5809e48373d975091($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire7195c74efd61d60849353b7e230e5264($fileIdentifier, $file)
function composerRequiredb1c54988d45f3f5809e48373d975091($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit7195c74efd61d60849353b7e230e5264
class ComposerStaticInitdb1c54988d45f3f5809e48373d975091
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3465,9 +3465,9 @@ class ComposerStaticInit7195c74efd61d60849353b7e230e5264
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7195c74efd61d60849353b7e230e5264::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7195c74efd61d60849353b7e230e5264::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7195c74efd61d60849353b7e230e5264::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitdb1c54988d45f3f5809e48373d975091::$classMap;
}, null, ClassLoader::class);
}

View File

@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
spl_autoload_call('RectorPrefix20210511\CheckoutEntityFactory');
}
if (!class_exists('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', false) && !interface_exists('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', false) && !trait_exists('ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264', false)) {
spl_autoload_call('RectorPrefix20210511\ComposerAutoloaderInit7195c74efd61d60849353b7e230e5264');
if (!class_exists('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', false) && !interface_exists('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', false) && !trait_exists('ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091', false)) {
spl_autoload_call('RectorPrefix20210511\ComposerAutoloaderInitdb1c54988d45f3f5809e48373d975091');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210511\Doctrine\Inflector\Inflector');
@ -95,9 +95,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210511\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire7195c74efd61d60849353b7e230e5264')) {
function composerRequire7195c74efd61d60849353b7e230e5264() {
return \RectorPrefix20210511\composerRequire7195c74efd61d60849353b7e230e5264(...func_get_args());
if (!function_exists('composerRequiredb1c54988d45f3f5809e48373d975091')) {
function composerRequiredb1c54988d45f3f5809e48373d975091() {
return \RectorPrefix20210511\composerRequiredb1c54988d45f3f5809e48373d975091(...func_get_args());
}
}
if (!function_exists('parseArgs')) {