diff --git a/consts.php b/consts.php index c8f79c7..53d8c69 100644 --- a/consts.php +++ b/consts.php @@ -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 = [ diff --git a/job_creator.php b/job_creator.php index 899c95d..1066fe6 100644 --- a/job_creator.php +++ b/job_creator.php @@ -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})) { diff --git a/tests/JobCreatorTest.php b/tests/JobCreatorTest.php index 425c403..21e8d32 100644 --- a/tests/JobCreatorTest.php +++ b/tests/JobCreatorTest.php @@ -762,6 +762,7 @@ public function testGetInstallerVersionCMS5FromComposer( string $githubRepository, string $branch, array $composerDeps, + string $repoType, string $expected ): void { if (!function_exists('yaml_parse')) { @@ -778,6 +779,9 @@ public function testGetInstallerVersionCMS5FromComposer( $creator = new JobCreator(); $creator->composerJsonPath = '__composer.json'; $composer = new stdClass(); + if ($repoType) { + $composer->type = $repoType; + } $composer->require = new stdClass(); foreach ($composerDeps as $dep => $version) { $composer->require->{$dep} = $version; @@ -795,18 +799,21 @@ public function provideGetInstallerVersionCMS5FromComposer(): array $currentMinor = $this->getCurrentMinorInstallerVersion('4') . '.x-dev'; return [ // priority given to branch name - ['myaccount/silverstripe-framework', '4', [], '4.x-dev'], - ['myaccount/silverstripe-framework', '4.10', [], '4.10.x-dev'], - ['myaccount/silverstripe-framework', 'burger', [], $currentMinor], - ['myaccount/silverstripe-framework', '5', [], '5.x-dev'], - ['myaccount/silverstripe-framework', '5.10', [], '5.10.x-dev'], + ['myaccount/silverstripe-framework', '4', [], 'silverstripe-module', '4.x-dev'], + ['myaccount/silverstripe-framework', '4.10', [], 'silverstripe-vendormodule', '4.10.x-dev'], + ['myaccount/silverstripe-framework', 'burger', [], 'silverstripe-theme', $currentMinor], + ['myaccount/silverstripe-framework', '5', [], 'silverstripe-recipe', '5.x-dev'], + ['myaccount/silverstripe-framework', '5.10', [], 'silverstripe-vendormodule', '5.10.x-dev'], // fallback to looking at deps in composer.json, use current minor of installer .x-dev - ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.x-dev'], '5.x-dev'], - ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.0.x-dev'], '5.0.x-dev'], - ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^5'], '5.2.x-dev'], - ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], '5.2.x-dev'], - ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], '5.2.x-dev'], - ['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], '5.x-dev'], + ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.x-dev'], 'silverstripe-module', '5.x-dev'], + ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.0.x-dev'], 'silverstripe-vendormodule', '5.0.x-dev'], + ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^5'], 'silverstripe-theme', '5.2.x-dev'], + ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], 'silverstripe-recipe', '5.2.x-dev'], + ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], 'silverstripe-vendormodule', '5.2.x-dev'], + ['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], 'silverstripe-vendormodule', '5.x-dev'], + ['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], 'package', ''], + ['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], '', ''], + ['myaccount/silverstripe-somemodule', '3', [], '', ''], ]; } @@ -817,6 +824,7 @@ public function testComposerInstall( string $composerInstall, string $configPlatformPhp, string $frameworkVersion, + string $repoType, array $expected ): void { $yml = implode("\n", [ @@ -830,6 +838,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) { @@ -855,6 +866,7 @@ public function provideComposerInstall(): array 'true', '', '4.x-dev', + 'silverstripe-module', [ '7.4 mysql57 phpunit all' ] @@ -863,6 +875,7 @@ public function provideComposerInstall(): array 'true', '', '5.x-dev', + 'silverstripe-vendormodule', [ '8.1 mysql57 phpunit all' ] @@ -871,6 +884,7 @@ public function provideComposerInstall(): array 'true', '21.99', '5.x-dev', + 'silverstripe-recipe', [ '21.99 mysql57 phpunit all' ] @@ -879,6 +893,7 @@ public function provideComposerInstall(): array 'true', 'fish', '5.x-dev', + 'silverstripe-theme', [ '8.1 mysql57 phpunit all' ] @@ -887,6 +902,7 @@ public function provideComposerInstall(): array 'false', '', '4.x-dev', + 'silverstripe-module', [ '7.4 prf-low mysql57 phpunit all', '8.0 mysql57pdo phpunit all', @@ -897,6 +913,7 @@ public function provideComposerInstall(): array 'false', '', '5.x-dev', + 'silverstripe-vendormodule', [ '8.1 prf-low mysql57 phpunit all', '8.2 mariadb phpunit all', @@ -907,6 +924,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', @@ -917,6 +935,7 @@ public function provideComposerInstall(): array 'false', 'fish', '5.x-dev', + 'silverstripe-theme', [ '8.1 prf-low mysql57 phpunit all', '8.2 mariadb phpunit all', @@ -927,6 +946,7 @@ public function provideComposerInstall(): array 'false', '', '5.1.x-dev', + 'silverstripe-module', [ '8.1 prf-low mysql57 phpunit all', '8.1 mariadb phpunit all', @@ -937,6 +957,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', @@ -947,6 +968,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', @@ -957,6 +979,7 @@ public function provideComposerInstall(): array 'false', '', '5.2.x-dev', + 'silverstripe-theme', [ '8.1 prf-low mysql57 phpunit all', '8.2 mariadb phpunit all', @@ -967,6 +990,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', @@ -977,12 +1001,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_notmodule1' => [ + 'false', + 'fish', + '*', + 'package', + [ + '7.4 prf-low mysql57 phpunit all', + '8.0 mysql57pdo phpunit all', + '8.1 mysql80 phpunit all', + ] + ], + 'composerupgrade_invalidphpversion_notmodule2' => [ + 'false', + 'fish', + '*', + '', + [ + '7.4 prf-low mysql57 phpunit all', + '8.0 mysql57pdo phpunit all', + '8.1 mysql80 phpunit all', + ] + ], ]; } }