diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ae1a734867..87028490033 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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`. diff --git a/docs/how_to_persist_cache_between_ci_runs.md b/docs/how_to_persist_cache_between_ci_runs.md new file mode 100644 index 00000000000..c29f251f796 --- /dev/null +++ b/docs/how_to_persist_cache_between_ci_runs.md @@ -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. diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index e5c0af058c4..006264e14cc 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -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 */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 9fa751b55c0..4153c55eb25 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit91356739d019fd700ce892ebe9e8ae4d::getLoader(); +return ComposerAutoloaderInitff43ab1ebcf50e1ed96f418f59a928e9::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 24ce66c8183..8b577ca2636 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -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; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index f854be28201..21c1a7378da 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -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); }