Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-5637: supports backports #300

Merged
merged 8 commits into from
Dec 28, 2023
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
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage:
ignore:
- "**/*Dto.php"
- "src/Codebase/Application/Dto/*.php"
- "src/ReleaseApp/Domain/Entities/*.php"
- "src/DynamicEvaluator/**/Dto/*.php"
- "src/DynamicEvaluator/Presentation/**.php"
- "src/ReleaseApp/Infrastructure/Shared/Dto/*.php"
Expand Down
17 changes: 12 additions & 5 deletions config/Upgrade/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ services:
class: Upgrade\Application\Strategy\Common\Step\SendReportStep

feature_dev_master.fixer:
class: Upgrade\Application\Strategy\Composer\Fixer\FeatureDevMasterPackageFixerStep
class: Upgrade\Application\Strategy\Composer\Fixer\FeatureDevMasterPackageUpgradeFixer

feature_package.fixer:
class: Upgrade\Application\Strategy\Composer\Fixer\FeaturePackageFixerStep
class: Upgrade\Application\Strategy\Composer\Fixer\FeaturePackageUpgradeFixer

backport.fixer:
class: Upgrade\Application\Strategy\Composer\Fixer\BackportUpgradeFixer

composer.step_executor:
class: Upgrade\Application\Executor\StepExecutor
Expand All @@ -127,8 +130,6 @@ services:
- '@create_pr.step'
- '@checkout.step'
- '@send_report.step'
- - '@feature_dev_master.fixer'
- '@feature_package.fixer'

composer.strategy:
class: Upgrade\Application\Strategy\Composer\ComposerStrategy
Expand All @@ -153,8 +154,14 @@ services:
- '@create_pr.step'
- '@checkout.step'
- '@send_report.step'
release_group_upgrader.upgrader:
class: Upgrade\Application\Strategy\ReleaseApp\Processor\ReleaseGroupUpgrader
arguments:
- '@Upgrade\Application\Strategy\ReleaseApp\Processor\ModuleFetcher'
- '@monolog.logger'
- - '@feature_dev_master.fixer'
- '@feature_package.fixer'
- '@backport.fixer'

create_empty_pr.step_executor:
class: Upgrade\Application\Executor\StepExecutor
Expand Down Expand Up @@ -300,7 +307,7 @@ services:
arguments:
- '@Upgrade\Application\Strategy\ReleaseApp\Validator\ReleaseGroupSoftValidator'
- '@Upgrade\Application\Strategy\ReleaseApp\Validator\ThresholdSoftValidator'
- '@Upgrade\Application\Strategy\ReleaseApp\Processor\ModuleFetcher'
- '@release_group_upgrader.upgrader'
- '@Upgrade\Application\Strategy\ReleaseApp\ReleaseGroupFilter\ReleaseGroupFilter'
- '@event_dispatcher'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function updateStatisticPostRequire(StepsResponseDto $stepsResponseDto):
}
}

$stepsResponseDto->getModelStatisticDto()->setIntersectingModels($intersectedModuleNames);
$stepsResponseDto->getModelStatisticDto()->setIntersectingModules($intersectedModuleNames);
$stepsResponseDto->getModelStatisticDto()->setTotalIntersectingModels($totalIntersectingModels);

return $stepsResponseDto;
Expand Down
31 changes: 31 additions & 0 deletions src/ReleaseApp/Domain/Entities/UpgradeInstructionsReleaseGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class UpgradeInstructionsReleaseGroup
*/
protected const MODULES_KEY = 'modules';

/**
* @var string
*/
protected const BACKPORTS_KEY = 'backports';

/**
* @var string
*/
Expand Down Expand Up @@ -92,6 +97,11 @@ class UpgradeInstructionsReleaseGroup
*/
protected ?UpgradeInstructionModuleCollection $moduleCollection = null;

/**
* @var \ReleaseApp\Domain\Entities\Collection\UpgradeInstructionModuleCollection|null
*/
protected ?UpgradeInstructionModuleCollection $backportModuleCollection = null;

/**
* @var \ReleaseApp\Domain\Entities\UpgradeInstructionMeta|null
*/
Expand Down Expand Up @@ -185,6 +195,27 @@ public function getModuleCollection(): UpgradeInstructionModuleCollection
return $this->moduleCollection;
}

/**
* @return \ReleaseApp\Domain\Entities\Collection\UpgradeInstructionModuleCollection
*/
public function getBackportModuleCollection(): UpgradeInstructionModuleCollection
{
if ($this->backportModuleCollection) {
return $this->backportModuleCollection;
}

$moduleList = [];
if (!isset($this->body[static::BACKPORTS_KEY])) {
return new UpgradeInstructionModuleCollection();
}
foreach ($this->body[static::BACKPORTS_KEY] as $name => $moduleData) {
$moduleList[] = new UpgradeInstructionModule($moduleData, $name);
}
$this->backportModuleCollection = new UpgradeInstructionModuleCollection($moduleList);

return $this->backportModuleCollection;
}

/**
* @return \ReleaseApp\Domain\Entities\UpgradeInstructionMeta|null
*/
Expand Down
16 changes: 16 additions & 0 deletions src/ReleaseApp/Infrastructure/Shared/Dto/ReleaseGroupDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,16 @@ class ReleaseGroupDto
*/
protected bool $manualActionNeeded;

/**
* @var \ReleaseApp\Infrastructure\Shared\Dto\Collection\ModuleDtoCollection
*/
protected ModuleDtoCollection $backportModuleCollection;

/**
* @param int $id
* @param string $name
* @param \ReleaseApp\Infrastructure\Shared\Dto\Collection\ModuleDtoCollection $moduleCollection
* @param \ReleaseApp\Infrastructure\Shared\Dto\Collection\ModuleDtoCollection $backportModuleCollection
* @param \DateTimeInterface $released
* @param bool $containsProjectChanges
* @param string $link
Expand All @@ -96,6 +102,7 @@ public function __construct(
int $id,
string $name,
ModuleDtoCollection $moduleCollection,
ModuleDtoCollection $backportModuleCollection,
DateTimeInterface $released,
bool $containsProjectChanges,
string $link,
Expand All @@ -110,6 +117,7 @@ public function __construct(
$this->released = $released;
$this->link = $link;
$this->moduleCollection = $moduleCollection;
$this->backportModuleCollection = $backportModuleCollection;
$this->containsProjectChanges = $containsProjectChanges;
$this->hasConflict = $hasConflict;
$this->rating = $rating;
Expand Down Expand Up @@ -144,6 +152,14 @@ public function setModuleCollection(ModuleDtoCollection $moduleCollection): void
$this->moduleCollection = $moduleCollection;
}

/**
* @return \ReleaseApp\Infrastructure\Shared\Dto\Collection\ModuleDtoCollection
*/
public function getBackportModuleCollection(): ModuleDtoCollection
{
return $this->backportModuleCollection;
}

/**
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected function mapReleaseGroupDto(UpgradeInstructionsReleaseGroup $releaseGr
$releaseGroup->getId(),
$releaseGroup->getName(),
$this->buildModuleTransferCollection($releaseGroup),
$this->buildBackportModuleTransferCollection($releaseGroup),
$releaseGroup->getReleased(),
$releaseGroup->hasProjectChanges(),
$this->getReleaseGroupLink($releaseGroup->getId()),
Expand Down Expand Up @@ -111,6 +112,24 @@ protected function buildModuleTransferCollection(UpgradeInstructionsReleaseGroup
return $dataProviderModuleCollection;
}

/**
* @param \ReleaseApp\Domain\Entities\UpgradeInstructionsReleaseGroup $releaseGroup
*
* @return \ReleaseApp\Infrastructure\Shared\Dto\Collection\ModuleDtoCollection
*/
protected function buildBackportModuleTransferCollection(UpgradeInstructionsReleaseGroup $releaseGroup): ModuleDtoCollection
{
$releaseGroupModuleCollection = $releaseGroup->getBackportModuleCollection();

$dataProviderModuleCollection = new ModuleDtoCollection();
foreach ($releaseGroupModuleCollection->toArray() as $module) {
$dataProviderModule = new ModuleDto($module->getName(), $module->getVersion(), $module->getType());
$dataProviderModuleCollection->add($dataProviderModule);
}

return $dataProviderModuleCollection;
}

/**
* @param int $id
*
Expand Down
18 changes: 9 additions & 9 deletions src/Upgrade/Application/Dto/ModelStatisticDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ class ModelStatisticDto
/**
* @var array<string>
*/
protected array $intersectingModels = [];
protected array $intersectingModules = [];

/**
* @param int $totalOverwrittenModels
* @param int $totalChangedModels
* @param int $totalIntersectingModels
* @param array<string> $intersectingModels
* @param array<string> $intersectingModules
*/
public function __construct(int $totalOverwrittenModels = 0, int $totalChangedModels = 0, int $totalIntersectingModels = 0, array $intersectingModels = [])
public function __construct(int $totalOverwrittenModels = 0, int $totalChangedModels = 0, int $totalIntersectingModels = 0, array $intersectingModules = [])
{
$this->totalOverwrittenModels = $totalOverwrittenModels;
$this->totalChangedModels = $totalChangedModels;
$this->totalIntersectingModels = $totalIntersectingModels;
$this->intersectingModels = $intersectingModels;
$this->intersectingModules = $intersectingModules;
}

/**
Expand Down Expand Up @@ -102,18 +102,18 @@ public function setTotalIntersectingModels(int $totalIntersectingModels): void
/**
* @return array<string>
*/
public function getIntersectingModels(): array
public function getIntersectingModules(): array
{
return $this->intersectingModels;
return $this->intersectingModules;
}

/**
* @param array<string> $intersectingModels
* @param array<string> $intersectingModules
*
* @return void
*/
public function setIntersectingModels(array $intersectingModels): void
public function setIntersectingModules(array $intersectingModules): void
{
$this->intersectingModels = $intersectingModels;
$this->intersectingModules = $intersectingModules;
}
}
30 changes: 19 additions & 11 deletions src/Upgrade/Application/Dto/StepsResponseDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class StepsResponseDto extends ResponseDto
protected ModelStatisticDto $modelStatisticDto;

/**
* @var int
* @var \ReleaseApp\Infrastructure\Shared\Dto\ReleaseGroupDto|null
*/
protected int $currentReleaseGroupId = self::UNDEFINED_RELEASE_GROUP_ID;
protected ?ReleaseGroupDto $currentReleaseGroup = null;

/**
* @var bool
Expand Down Expand Up @@ -262,7 +262,7 @@ public function getIntegratorResponseDtoByReleaseGroupId(int $releaseGroupId): ?
*/
public function addIntegratorResponseDto(IntegratorResponseDto $integratorResponseDto): void
{
$this->integratorResponseCollection[$this->currentReleaseGroupId] = $integratorResponseDto;
$this->integratorResponseCollection[$this->getCurrentReleaseGroupId()] = $integratorResponseDto;
}

/**
Expand Down Expand Up @@ -292,7 +292,7 @@ public function setPullRequestId(?int $pullRequestId)
*/
public function addBlocker(ValidatorViolationDto $blockerInfo): void
{
$currentReleaseGroupId = $this->currentReleaseGroupId;
$currentReleaseGroupId = $this->getCurrentReleaseGroupId();

if (!isset($this->blockers[$currentReleaseGroupId])) {
$this->blockers[$currentReleaseGroupId] = [];
Expand All @@ -308,7 +308,7 @@ public function addBlocker(ValidatorViolationDto $blockerInfo): void
*/
public function removeBlockersByTitle(string $title): void
{
$currentReleaseGroupId = $this->currentReleaseGroupId;
$currentReleaseGroupId = $this->getCurrentReleaseGroupId();

if (!isset($this->blockers[$currentReleaseGroupId])) {
return;
Expand Down Expand Up @@ -413,7 +413,7 @@ public function getLastAppliedReleaseGroup(): ?ReleaseGroupDto
}

/**
* @return array<\ReleaseApp\Infrastructure\Shared\Dto\ReleaseGroupDto>
* @return array<int, \ReleaseApp\Infrastructure\Shared\Dto\ReleaseGroupDto>
*/
public function getAppliedReleaseGroups(): array
{
Expand Down Expand Up @@ -441,22 +441,30 @@ public function addAppliedReleaseGroup(ReleaseGroupDto $appliedReleaseGroup): vo
$this->appliedReleaseGroups[$appliedReleaseGroup->getId()] = $appliedReleaseGroup;
}

/**
* @return \ReleaseApp\Infrastructure\Shared\Dto\ReleaseGroupDto|null
*/
public function getCurrentReleaseGroup(): ?ReleaseGroupDto
{
return $this->currentReleaseGroup;
}

/**
* @return int
*/
public function getCurrentReleaseGroupId(): int
{
return $this->currentReleaseGroupId;
return $this->currentReleaseGroup ? $this->currentReleaseGroup->getId() : static::UNDEFINED_RELEASE_GROUP_ID;
}

/**
* @param int $currentReleaseGroupId
* @param \ReleaseApp\Infrastructure\Shared\Dto\ReleaseGroupDto $currentReleaseGroup
*
* @return void
*/
public function setCurrentReleaseGroupId(int $currentReleaseGroupId): void
public function setCurrentReleaseGroup(ReleaseGroupDto $currentReleaseGroup): void
{
$this->currentReleaseGroupId = $currentReleaseGroupId;
$this->currentReleaseGroup = $currentReleaseGroup;
}

/**
Expand Down Expand Up @@ -484,7 +492,7 @@ public function getViolationsByReleaseGroupId(int $releaseGroupId): array
*/
public function addViolation(ViolationDtoInterface $violation): void
{
$currentReleaseGroupId = $this->currentReleaseGroupId;
$currentReleaseGroupId = $this->getCurrentReleaseGroupId();

if (!isset($this->violations[$currentReleaseGroupId])) {
$this->violations[$currentReleaseGroupId] = [];
Expand Down
Loading
Loading