Updated Rector to commit 87d8ac84d83e29f2d1d7479cdde69272bdf8a9e9

87d8ac84d8 Explain how to persist Rector caches between CI runs (#2906)
This commit is contained in:
Tomas Votruba 2022-09-04 15:50:34 +00:00
parent 9d01c06e33
commit 7030aef611
6 changed files with 62 additions and 14 deletions

View File

@ -47,3 +47,6 @@ Do you want to **contribute a failing test**? [This tutorial will show you how](
```
We would be happy to accept PRs that follow these guidelines.
## Repository layout
Documentation goes into `build/target-repository/docs`.

View File

@ -0,0 +1,45 @@
# How To Persist Cache Between CI Runs
While parsing your application code, Rector generates objects representing that code. It caches these objects for later reuse, so it doesn't have to parse the entire application again, by detecting which files have changed since the last Rector run.
When running Rector in a Continuous Integration (CI) system such as [GitHub Actions](https://github.com/features/actions), the default implementation [uses an in-memory cache](https://github.com/rectorphp/rector/blob/1d28ca109ca536e8034c3c756ee61c65e6e63c8a/config/config.php#L89-L94). This means the next job that runs, will have to parse all code from scratch.
```php
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
return static function (RectorConfig $rectorConfig): void {
// ... your config
// Ensure file system caching is used instead of in-memory.
$rectorConfig->cacheClass(FileCacheStorage::class);
// Specify a path that works locally as well as on CI job runners.
$rectorConfig->cacheDirectory('./var/cache/rector');
};
```
Note that this caches relative to the repository directory, so it's the same directory on build as on development (and other environments). The actual path, when not specified, may vary per (runner) OS.
## Debugging the cache locally
Generate the cache on your development machine, by running the command:
```bash
vendor/bin/rector process --dry-run --config=rector.php
```
You can find it in your repository directory under `./var/cache/rector/`, containing folders like `0a`, `0b`, `0c`, ... containing the cache objects representing the latest run.
This, preferably prepended with `php `, command is also what your CI action should run, after mapping the cache directory from an earlier run.
## GitHub Actions
On GitHub Actions, you can use the [built-in cache action](https://github.com/actions/cache) as a step to point to a path that you want cached between jobs:
```yaml
- name: Rector Cache
uses: actions/cache@v3
with:
path: ./var/cache/rector
key: ${{ runner.os }}-rector-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-rector-
- name: Rector Dry Run
run: php vendor/bin/rector process --dry-run --config=rector.php
```
In this key configuration, runs on branches inherit the cache from their parent, if any.

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'bdee76597b93b0c75a70d767caed6f16cd8ae403';
public const PACKAGE_VERSION = '87d8ac84d83e29f2d1d7479cdde69272bdf8a9e9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-09-04 17:45:44';
public const RELEASE_DATE = '2022-09-04 17:46:40';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d::getLoader();
return ComposerAutoloaderInitff43ab1ebcf50e1ed96f418f59a928e9::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d
class ComposerAutoloaderInitff43ab1ebcf50e1ed96f418f59a928e9
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitff43ab1ebcf50e1ed96f418f59a928e9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitff43ab1ebcf50e1ed96f418f59a928e9', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitff43ab1ebcf50e1ed96f418f59a928e9::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitff43ab1ebcf50e1ed96f418f59a928e9::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire91356739d019fd700ce892ebe9e8ae4d($fileIdentifier, $file);
composerRequireff43ab1ebcf50e1ed96f418f59a928e9($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d
* @param string $file
* @return void
*/
function composerRequire91356739d019fd700ce892ebe9e8ae4d($fileIdentifier, $file)
function composerRequireff43ab1ebcf50e1ed96f418f59a928e9($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d
class ComposerStaticInitff43ab1ebcf50e1ed96f418f59a928e9
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3093,9 +3093,9 @@ class ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit91356739d019fd700ce892ebe9e8ae4d::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitff43ab1ebcf50e1ed96f418f59a928e9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitff43ab1ebcf50e1ed96f418f59a928e9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitff43ab1ebcf50e1ed96f418f59a928e9::$classMap;
}, null, ClassLoader::class);
}