Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions .github/workflows/e2e_with_cache.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

declare(strict_types=1);

use OndraM\CiDetector\CiDetector;
use Rector\Bootstrap\ExtensionConfigResolver;
use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -27,12 +25,6 @@
$rectorConfig->cacheDirectory(sys_get_temp_dir() . '/rector_cached_files');
$rectorConfig->containerCacheDirectory(sys_get_temp_dir());

// use faster in-memory cache in CI.
// CI always starts from scratch, therefore IO intensive caching is not worth it
if (new CiDetector()->isCiDetected()) {
$rectorConfig->cacheClass(MemoryCacheStorage::class);
}

// load internal rector-* extension configs
$extensionConfigResolver = new ExtensionConfigResolver();
foreach ($extensionConfigResolver->provide() as $extensionConfigFile) {
Expand Down
1 change: 0 additions & 1 deletion e2e/applied-rule-removed-node-with-cache/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions e2e/applied-rule-removed-node-with-cache/composer.json

This file was deleted.

40 changes: 0 additions & 40 deletions e2e/applied-rule-removed-node-with-cache/expected-output.diff

This file was deleted.

19 changes: 0 additions & 19 deletions e2e/applied-rule-removed-node-with-cache/rector.php

This file was deleted.

12 changes: 0 additions & 12 deletions e2e/applied-rule-removed-node-with-cache/src/AlwaysTrue.php

This file was deleted.

This file was deleted.

49 changes: 0 additions & 49 deletions e2e/e2eTestRunnerWithCache.php

This file was deleted.

1 change: 0 additions & 1 deletion e2e/timeout-file-not-cached/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions e2e/timeout-file-not-cached/composer.json

This file was deleted.

7 changes: 0 additions & 7 deletions e2e/timeout-file-not-cached/expected-output.diff

This file was deleted.

18 changes: 0 additions & 18 deletions e2e/timeout-file-not-cached/rector.php

This file was deleted.

9 changes: 0 additions & 9 deletions e2e/timeout-file-not-cached/src/SomeFixturePrinter.php

This file was deleted.

1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ parameters:
- rules-tests
- utils
- scripts
- e2e/e2eTestRunnerWithCache.php
- e2e/e2eTestRunner.php

scanDirectories:
Expand Down
25 changes: 11 additions & 14 deletions src/Caching/CacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Caching;

use OndraM\CiDetector\CiDetector;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Configuration\Option;
Expand All @@ -22,24 +23,20 @@ public function __construct(
*/
public function create(): Cache
{
$cacheDirectory = SimpleParameterProvider::provideStringParameter(Option::CACHE_DIR);

$cacheClass = FileCacheStorage::class;

if (SimpleParameterProvider::hasParameter(Option::CACHE_CLASS)) {
$cacheClass = SimpleParameterProvider::provideStringParameter(Option::CACHE_CLASS);
// in CI the workspace is ephemeral and usually starts from scratch,
// so a file cache that is never read again is only wasted IO → use faster in-memory cache
if (new CiDetector()->isCiDetected()) {
return new Cache(new MemoryCacheStorage());
}

if ($cacheClass === FileCacheStorage::class) {
// ensure cache directory exists
if (! $this->fileSystem->exists($cacheDirectory)) {
$this->fileSystem->mkdir($cacheDirectory);
}
$cacheDirectory = SimpleParameterProvider::provideStringParameter(Option::CACHE_DIR);

$fileCacheStorage = new FileCacheStorage($cacheDirectory, $this->fileSystem);
return new Cache($fileCacheStorage);
// ensure cache directory exists
if (! $this->fileSystem->exists($cacheDirectory)) {
$this->fileSystem->mkdir($cacheDirectory);
}

return new Cache(new MemoryCacheStorage());
$fileCacheStorage = new FileCacheStorage($cacheDirectory, $this->fileSystem);
return new Cache($fileCacheStorage);
}
}
7 changes: 5 additions & 2 deletions src/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,14 @@ public function containerCacheDirectory(string $directoryPath): void
/**
* @param class-string<CacheStorageInterface> $cacheClass
*/
#[Deprecated(message: <<<'TXT'
Cache storage is selected automatically: file cache locally, in-memory cache in CI,
where the ephemeral workspace makes writing a cache that is never re-read wasted IO.
The passed value is ignored.
TXT)]
public function cacheClass(string $cacheClass): void
{
Assert::isAOf($cacheClass, CacheStorageInterface::class);

SimpleParameterProvider::setParameter(Option::CACHE_CLASS, $cacheClass);
}

/**
Expand Down
12 changes: 0 additions & 12 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

namespace Rector\Configuration;

use Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;

final class Option
{
public const string SOURCE = 'source';
Expand Down Expand Up @@ -145,15 +142,6 @@ final class Option
*/
public const string CACHE_DIR = 'cache_dir';

/**
* Cache backend. Most of the time we cache in files, but in ephemeral environment (e.g. CI), a faster `MemoryCacheStorage` can be useful.
* @internal Use RectorConfig::cacheClass() instead
*
* @var class-string<CacheStorageInterface>
* @internal
*/
public const string CACHE_CLASS = FileCacheStorage::class;

public const string DEBUG = 'debug';

public const string XDEBUG = 'xdebug';
Expand Down
Loading
Loading