-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added the possibility to specify editions as input argument * Upgraded Fixer and PHPStan
- Loading branch information
Showing
7 changed files
with
81 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
composer.lock | ||
.php_cs.cache | ||
.phpunit.result.cache | ||
.php-cs-fixer.cache | ||
dependencies.json | ||
dependencies.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory; | ||
|
||
$configFactory = new InternalConfigFactory(); | ||
$configFactory->withRules([ | ||
'declare_strict_types' => false, | ||
]); | ||
|
||
return $configFactory | ||
->buildConfig() | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in( | ||
array_filter([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
], 'is_dir') | ||
) | ||
->files()->name('*.php') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Offset 'head' does not exist on array\\|string\\.$#" | ||
count: 2 | ||
message: "#^Offset 'base' does not exist on array\\|string\\.$#" | ||
count: 3 | ||
path: src/Command/LinkDependenciesCommand.php | ||
|
||
- | ||
message: "#^Property Ibexa\\\\Platform\\\\ContiniousIntegrationScripts\\\\Command\\\\LinkDependenciesCommand\\:\\:\\$token \\(string\\|null\\) does not accept array\\<string\\>\\|string\\|null\\.$#" | ||
count: 1 | ||
message: "#^Offset 'head' does not exist on array\\|string\\.$#" | ||
count: 4 | ||
path: src/Command/LinkDependenciesCommand.php | ||
|
||
- | ||
message: "#^Parameter \\#1 \\$productVersion of method Ibexa\\\\Platform\\\\ContiniousIntegrationScripts\\\\Command\\\\RunRegressionCommand\\:\\:mapProductVersionToPageBuilder\\(\\) expects string, array\\<string\\>\\|string\\|null given\\.$#" | ||
count: 1 | ||
path: src/Command/RunRegressionCommand.php | ||
|
||
- | ||
message: "#^Property Ibexa\\\\Platform\\\\ContiniousIntegrationScripts\\\\Command\\\\RunRegressionCommand\\:\\:\\$token \\(string\\|null\\) does not accept array\\<string\\>\\|string\\|null\\.$#" | ||
count: 1 | ||
path: src/Command/RunRegressionCommand.php | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,8 @@ static function (string $answer): string { | |
throw new \RuntimeException( | ||
sprintf( | ||
'Unrecognised version format: %s. Please use format X.Y instead, e.g. 3.3, 4.4, 4.5', | ||
$answer) | ||
$answer | ||
) | ||
); | ||
} | ||
|
||
|
@@ -79,17 +80,7 @@ static function (string $answer): string { | |
if (!$input->getArgument('productEditions')) { | ||
$productEditions = $io->ask('Please enter the Ibexa DXP edition(s)', 'oss', static function (string $answer): array { | ||
$editions = explode(',', $answer); | ||
foreach ($editions as $edition) { | ||
if (!in_array($edition, self::PRODUCT_EDITIONS)) { | ||
throw new \RuntimeException( | ||
sprintf( | ||
'Unrecognised edition: %s. Please choose one of: %s', | ||
$edition, | ||
implode(',', self::PRODUCT_EDITIONS) | ||
) | ||
); | ||
} | ||
} | ||
self::validateEditions($editions); | ||
|
||
return $editions; | ||
}); | ||
|
@@ -105,6 +96,11 @@ public function execute(InputInterface $input, OutputInterface $output): int | |
$productVersion = $input->getArgument('productVersion'); | ||
$productEditions = $input->getArgument('productEditions'); | ||
|
||
if (!is_array($productEditions)) { | ||
$productEditions = explode(',', $productEditions); | ||
$this->validateEditions($productEditions); | ||
} | ||
|
||
$this->validate(); | ||
|
||
$regressionBranchName = uniqid('tmp_regression_', true); | ||
|
@@ -122,13 +118,15 @@ private function createRegressionPullRequest(string $productEdition, string $bas | |
try { | ||
$repo = $this->repository->cloneRepository( | ||
sprintf('[email protected]:%s/%s.git', self::REPO_OWNER, $productEdition), | ||
null, ['-b' => $baseBranch] | ||
null, | ||
['-b' => $baseBranch] | ||
); | ||
} catch (GitException $exception) { | ||
// fallback to HTTPS if SSH fails | ||
$repo = $this->repository->cloneRepository( | ||
sprintf('https://github.com/%s/%s.git', self::REPO_OWNER, $productEdition), | ||
null, ['-b' => $baseBranch] | ||
null, | ||
['-b' => $baseBranch] | ||
); | ||
} | ||
|
||
|
@@ -158,7 +156,8 @@ private function createRegressionPullRequest(string $productEdition, string $bas | |
'head' => $regressionBranchName, | ||
'body' => 'Please add your description here.', | ||
'draft' => 'true', | ||
]); | ||
] | ||
); | ||
|
||
$io->success(sprintf('Created PR, please see: %s', $response['_links']['html']['href'])); | ||
|
||
|
@@ -223,7 +222,7 @@ private function waitUntilBranchExists(string $productEdition, string $branchNam | |
} | ||
} | ||
|
||
private function getBaseBranch($productEdition, string $productVersion): string | ||
private function getBaseBranch(string $productEdition, string $productVersion): string | ||
{ | ||
try { | ||
$this->githubClient->repo()->branches(self::REPO_OWNER, $productEdition, $productVersion); | ||
|
@@ -233,4 +232,22 @@ private function getBaseBranch($productEdition, string $productVersion): string | |
return 'master'; | ||
} | ||
} | ||
|
||
/** | ||
* @param iterable<string> $editions | ||
*/ | ||
private static function validateEditions(iterable $editions): void | ||
{ | ||
foreach ($editions as $edition) { | ||
if (!in_array($edition, self::PRODUCT_EDITIONS)) { | ||
throw new \RuntimeException( | ||
sprintf( | ||
'Unrecognised edition: %s. Please choose one of: %s', | ||
$edition, | ||
implode(',', self::PRODUCT_EDITIONS) | ||
) | ||
); | ||
} | ||
} | ||
} | ||
} |