Skip to content

Commit

Permalink
Merge pull request #324 from spryker-sdk/bugfix/supesc-873/spryker-co…
Browse files Browse the repository at this point in the history
…de-upgrader-issues

SUPESC-873 Fixed missing constant error.
  • Loading branch information
olhalivitchuk authored Sep 20, 2024
2 parents d7bbb50 + 78d8487 commit 94fee02
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
10 changes: 10 additions & 0 deletions config/Upgrade/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ services:

orm_models_regenerate.step:
class: Upgrade\Application\Strategy\Common\Step\OrmModelsRegenerateStep
arguments:
- '@process.runner'
- '@file.system'
- '@configuration.provider'

integrator.step:
class: Upgrade\Application\Strategy\Common\Step\IntegratorStep
Expand Down Expand Up @@ -231,6 +235,12 @@ services:
configuration.provider:
class: Upgrade\Infrastructure\Configuration\ConfigurationProvider

process.runner:
class: SprykerSdk\Utils\Infrastructure\Service\ProcessRunnerService

file.system:
class: SprykerSdk\Utils\Infrastructure\Service\Filesystem

Upgrade\Infrastructure\VersionControlSystem\SourceCodeProvider\SourceCodeProvider:
class: Upgrade\Infrastructure\VersionControlSystem\SourceCodeProvider\SourceCodeProvider
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,23 @@ public function getPullRequestReviewers(): array;

/**
* Specification:
* - Defines whether to run PHPStan per directory or analyze all files at once.
* - Defines whether to run PHPStan per directory or analyze all files at once.
*
* @return bool
*/
public function isPhpStanOptimizationRun(): bool;

/**
* Specification:
* - Defines whether error traces in error messages should be truncated before adding them to a PR.
* - Defines whether Dynamic Multistore feature is enabled in Spryker.
*
* @return bool
*/
public function isSprykerDynamicStoreModeEnabled(): bool;

/**
* Specification:
* - Defines whether error traces in error messages should be truncated before adding them to a PR.
*
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
use Upgrade\Application\Dto\StepsResponseDto;
use Upgrade\Application\Dto\ValidatorViolationDto;
use Upgrade\Application\Strategy\StepInterface;
use Upgrade\Infrastructure\Configuration\ConfigurationProvider;

class OrmModelsRegenerateStep implements StepInterface
{
/**
* @var \Upgrade\Infrastructure\Configuration\ConfigurationProvider
*/
protected ConfigurationProvider $configurationProvider;

/**
* @var string
*/
Expand Down Expand Up @@ -57,11 +63,16 @@ class OrmModelsRegenerateStep implements StepInterface
/**
* @param \SprykerSdk\Utils\Infrastructure\Service\ProcessRunnerServiceInterface $processRunner
* @param \Symfony\Component\Filesystem\Filesystem $filesystem
* @param \Upgrade\Infrastructure\Configuration\ConfigurationProvider $configurationProvider
*/
public function __construct(ProcessRunnerServiceInterface $processRunner, Filesystem $filesystem)
{
public function __construct(
ProcessRunnerServiceInterface $processRunner,
Filesystem $filesystem,
ConfigurationProvider $configurationProvider
) {
$this->processRunner = $processRunner;
$this->filesystem = $filesystem;
$this->configurationProvider = $configurationProvider;
}

/**
Expand Down Expand Up @@ -100,7 +111,10 @@ protected function handle(StepsResponseDto $stepsExecutionDto): StepsResponseDto
}

foreach (static::COMMAND_LIST as $command) {
$response = $this->processRunner->run([static::PROJECT_CONSOLE_PATH, $command], ['APPLICATION_ENV' => 'development']);
$response = $this->processRunner->run([static::PROJECT_CONSOLE_PATH, $command], [
'APPLICATION_ENV' => 'development',
'SPRYKER_DYNAMIC_STORE_MODE' => $this->configurationProvider->isSprykerDynamicStoreModeEnabled(),
]);
if ($response->getExitCode()) {
$message = $response->getErrorOutput() ?: $response->getOutput();
$stepsExecutionDto->addBlocker(
Expand Down
10 changes: 10 additions & 0 deletions src/Upgrade/Infrastructure/Configuration/ConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ public function isPhpStanOptimizationRun(): bool
return EnvFetcher::getBool('PHPSTAN_OPTIMIZATION_RUN', false);
}

/**
* {@inheritDoc}
*
* @return bool
*/
public function isSprykerDynamicStoreModeEnabled(): bool
{
return EnvFetcher::getBool('SPRYKER_DYNAMIC_STORE_MODE', false);
}

/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Upgrade\Application\Dto\StepsResponseDto;
use Upgrade\Application\Strategy\Common\Step\OrmModelsRegenerateStep;
use Upgrade\Domain\Entity\Package;
use Upgrade\Infrastructure\Configuration\ConfigurationProvider;

class OrmModelsRegenerateStepTest extends TestCase
{
Expand All @@ -35,7 +36,11 @@ public function testRunSuccess(): void
$processRunnerMock->expects($this->atLeastOnce())->method('run');

// Arrange
$step = new OrmModelsRegenerateStep($processRunnerMock, new Filesystem());
$step = new OrmModelsRegenerateStep(
$processRunnerMock,
new Filesystem(),
new ConfigurationProvider(),
);

// Act
$step->run($stepsExecutionDto);
Expand All @@ -54,7 +59,11 @@ public function testRunWhenComposerLockDiffNotExists(): void
$processRunnerMock->expects($this->never())->method('run');

// Arrange
$step = new OrmModelsRegenerateStep($processRunnerMock, new Filesystem());
$step = new OrmModelsRegenerateStep(
$processRunnerMock,
new Filesystem(),
new ConfigurationProvider(),
);

// Act
$step->run($stepsExecutionDto);
Expand All @@ -69,7 +78,11 @@ public function testRunWhenCommandFailed(): void
$stepsExecutionDto = new StepsResponseDto(true);
$stepsExecutionDto->setComposerLockDiff($this->createComposerLockDiffDto());
$processRunnerMock = $this->createProcessRunnerServiceMock();
$step = new OrmModelsRegenerateStep($processRunnerMock, new Filesystem());
$step = new OrmModelsRegenerateStep(
$processRunnerMock,
new Filesystem(),
new ConfigurationProvider(),
);

// Act
$response = $step->run($stepsExecutionDto);
Expand Down

0 comments on commit 94fee02

Please sign in to comment.