Skip to content

Commit

Permalink
ENH Don't include installer if it's not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 26, 2024
1 parent 0e30080 commit e304cd2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
5 changes: 0 additions & 5 deletions consts.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@
];

const NO_INSTALLER_UNLOCKSTEPPED_REPOS = [
'vendor-plugin',
'recipe-plugin',
'api.silverstripe.org',
'cow',
'silverstripe-config',
'markdown-php-codesniffer',
];

const CMS_TO_REPO_MAJOR_VERSIONS = [
Expand Down
13 changes: 12 additions & 1 deletion job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,20 @@ public function getInstallerVersion(): string
}
}
}
// has a lockstepped .x-dev requirement in composer.json
if (file_exists($this->composerJsonPath)) {
$json = json_decode(file_get_contents($this->composerJsonPath));
// We shouldn't try to infer the installer version for regular repositories
// that weren't already detected via the const-based logic above
$silverstripeRepoTypes = [
'silverstripe-vendormodule',
'silverstripe-module',
'silverstripe-recipe',
'silverstripe-theme',
];
if (!isset($json->type) || !in_array($json->type, $silverstripeRepoTypes)) {
return '';
}
// has a lockstepped .x-dev requirement in composer.json
foreach (LOCKSTEPPED_REPOS as $lockedSteppedRepo) {
$composerRepo = 'silverstripe/' . str_replace('silverstripe-', '', $lockedSteppedRepo);
if (isset($json->require->{$composerRepo})) {
Expand Down
40 changes: 40 additions & 0 deletions tests/JobCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ public function testComposerInstall(
string $composerInstall,
string $configPlatformPhp,
string $frameworkVersion,
string $repoType,
array $expected
): void {
$yml = implode("\n", [
Expand All @@ -830,6 +831,9 @@ public function testComposerInstall(
$creator = new JobCreator();
$creator->composerJsonPath = '__composer.json';
$composer = new stdClass();
if ($repoType) {
$composer->type = $repoType;
}
$composer->require = new stdClass();
$composer->require->{'silverstripe/framework'} = $frameworkVersion;
if ($configPlatformPhp) {
Expand All @@ -855,6 +859,7 @@ public function provideComposerInstall(): array
'true',
'',
'4.x-dev',
'silverstripe-module',
[
'7.4 mysql57 phpunit all'
]
Expand All @@ -863,6 +868,7 @@ public function provideComposerInstall(): array
'true',
'',
'5.x-dev',
'silverstripe-vendormodule',
[
'8.1 mysql57 phpunit all'
]
Expand All @@ -871,6 +877,7 @@ public function provideComposerInstall(): array
'true',
'21.99',
'5.x-dev',
'silverstripe-recipe',
[
'21.99 mysql57 phpunit all'
]
Expand All @@ -879,6 +886,7 @@ public function provideComposerInstall(): array
'true',
'fish',
'5.x-dev',
'silverstripe-theme',
[
'8.1 mysql57 phpunit all'
]
Expand All @@ -887,6 +895,7 @@ public function provideComposerInstall(): array
'false',
'',
'4.x-dev',
'silverstripe-module',
[
'7.4 prf-low mysql57 phpunit all',
'8.0 mysql57pdo phpunit all',
Expand All @@ -897,6 +906,7 @@ public function provideComposerInstall(): array
'false',
'',
'5.x-dev',
'silverstripe-vendormodule',
[
'8.1 prf-low mysql57 phpunit all',
'8.2 mariadb phpunit all',
Expand All @@ -907,6 +917,7 @@ public function provideComposerInstall(): array
'false',
'21.99',
'5.x-dev',
'silverstripe-recipe',
[
'8.1 prf-low mysql57 phpunit all',
'8.2 mariadb phpunit all',
Expand All @@ -917,6 +928,7 @@ public function provideComposerInstall(): array
'false',
'fish',
'5.x-dev',
'silverstripe-theme',
[
'8.1 prf-low mysql57 phpunit all',
'8.2 mariadb phpunit all',
Expand All @@ -927,6 +939,7 @@ public function provideComposerInstall(): array
'false',
'',
'5.1.x-dev',
'silverstripe-module',
[
'8.1 prf-low mysql57 phpunit all',
'8.1 mariadb phpunit all',
Expand All @@ -937,6 +950,7 @@ public function provideComposerInstall(): array
'false',
'21.99',
'5.1.x-dev',
'silverstripe-vendormodule',
[
'8.1 prf-low mysql57 phpunit all',
'8.1 mariadb phpunit all',
Expand All @@ -947,6 +961,7 @@ public function provideComposerInstall(): array
'false',
'fish',
'5.1.x-dev',
'silverstripe-recipe',
[
'8.1 prf-low mysql57 phpunit all',
'8.1 mariadb phpunit all',
Expand All @@ -957,6 +972,7 @@ public function provideComposerInstall(): array
'false',
'',
'5.2.x-dev',
'silverstripe-theme',
[
'8.1 prf-low mysql57 phpunit all',
'8.2 mariadb phpunit all',
Expand All @@ -967,6 +983,7 @@ public function provideComposerInstall(): array
'false',
'21.99',
'5.2.x-dev',
'silverstripe-module',
[
'8.1 prf-low mysql57 phpunit all',
'8.2 mariadb phpunit all',
Expand All @@ -977,12 +994,35 @@ public function provideComposerInstall(): array
'false',
'fish',
'5.2.x-dev',
'silverstripe-vendormodule',
[
'8.1 prf-low mysql57 phpunit all',
'8.2 mariadb phpunit all',
'8.3 mysql80 phpunit all',
]
],
'composerupgrade_invalidphpversion_notmodule' => [
'false',
'fish',
'*',
'package',
[
'7.4 prf-low mysql57 phpunit all',
'8.0 mariadb phpunit all',
'8.1 mysql80 phpunit all',
]
],
'composerupgrade_invalidphpversion_notmodule' => [
'false',
'fish',
'*',
'',
[
'7.4 prf-low mysql57 phpunit all',
'8.0 mariadb phpunit all',
'8.1 mysql80 phpunit all',
]
],
];
}
}

0 comments on commit e304cd2

Please sign in to comment.