From a779f0d49c465c01b21e93d4c0f99d8c98f4393d Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 21 Feb 2024 13:50:50 +1300 Subject: [PATCH] ENH Support for CMS 6 --- consts.php | 44 ++++++++++ job_creator.php | 10 ++- tests/JobCreatorTest.php | 176 +++++++++++++++++++++++++++++++++------ 3 files changed, 203 insertions(+), 27 deletions(-) diff --git a/consts.php b/consts.php index 3ba697c..33e4306 100644 --- a/consts.php +++ b/consts.php @@ -41,6 +41,11 @@ '8.2', '8.3', ], + '6' => [ + '8.1', + '8.2', + '8.3', + ], ]; const DB_MYSQL_57 = 'mysql57'; @@ -162,6 +167,45 @@ 'silverstripe-versioned-admin' => '2', 'vendor-plugin' => '2', ], + '6' => [ + 'MinkFacebookWebDriver' => '3', + 'recipe-authoring-tools' => '3', + 'recipe-blog' => '3', + 'recipe-ccl' => '4', + 'recipe-cms' => '6', + 'recipe-collaboration' => '3', + 'recipe-content-blocks' => '4', + 'recipe-core' => '6', + 'recipe-form-building' => '3', + 'recipe-kitchen-sink' => '6', + 'recipe-plugin' => '3', + 'recipe-reporting-tools' => '3', + 'recipe-services' => '3', + 'recipe-testing' => '4', + 'silverstripe-installer' => '6', + 'silverstripe-admin' => '3', + 'silverstripe-asset-admin' => '3', + 'silverstripe-assets' => '3', + 'silverstripe-behat-extension' => '6', + 'silverstripe-campaign-admin' => '3', + 'silverstripe-cms' => '6', + 'silverstripe-errorpage' => '3', + 'silverstripe-event-dispatcher' => '2', + 'silverstripe-framework' => '6', + 'silverstripe-frameworktest' => '2', + 'silverstripe-graphql' => '6', + 'silverstripe-login-forms' => '6', + 'silverstripe-mimevalidator' => '4', + 'silverstripe-registry' => '4', + 'silverstripe-reports' => '6', + 'silverstripe-serve' => '4', + 'silverstripe-session-manager' => '3', + 'silverstripe-siteconfig' => '6', + 'silverstripe-testsession' => '4', + 'silverstripe-versioned' => '3', + 'silverstripe-versioned-admin' => '3', + 'vendor-plugin' => '3', + ], ]; // use hardcoded.php to bulk update update this after creating a .cow.pat.json diff --git a/job_creator.php b/job_creator.php index 5cbfbb0..ee1ec5a 100644 --- a/job_creator.php +++ b/job_creator.php @@ -93,6 +93,14 @@ public function getInstallerVersion(): string // fallback to use the next-minor or latest-minor version of installer $installerVersions = array_keys(INSTALLER_TO_PHP_VERSIONS); $installerVersions = array_filter($installerVersions, fn($version) => substr($version, 0, 1) === $cmsMajor); + + // Force CMS 6 branches to only return 6.x-dev instead of 6.0.x-dev + // as the 6.0 branches won't exist until the first beta release + // remove this code when the 6.0 branches exist + if ($cmsMajor == '6') { + return '6.x-dev'; + } + if (preg_match('#^[1-9]+[0-9]*$#', $branch)) { // next-minor e.g. 4 return $cmsMajor . '.x-dev'; @@ -394,7 +402,7 @@ private function createPhpunitJobs( 'phpunit' => true, 'phpunit_suite' => $suite, ]); - } elseif ($this->getCmsMajor() === '5') { + } else { // phpunit tests for cms 5 are run on php 8.1, 8.2 or 8.3 and mysql 8.0 or mariadb $phpToDB = $this->generatePhpToDBMap(); foreach ($phpToDB as $php => $db) { diff --git a/tests/JobCreatorTest.php b/tests/JobCreatorTest.php index f1c9a50..273e731 100644 --- a/tests/JobCreatorTest.php +++ b/tests/JobCreatorTest.php @@ -62,6 +62,9 @@ public function provideCreateJob(): array ['myaccount/silverstripe-installer', '5', 99, [], [ 'php' => max(INSTALLER_TO_PHP_VERSIONS['5']) ]], + ['myaccount/silverstripe-installer', '6', 99, [], [ + 'php' => max(INSTALLER_TO_PHP_VERSIONS['6']) + ]], ]; } @@ -92,9 +95,9 @@ private function getCurrentMinorInstallerVersion(string $cmsMajor): string public function provideGetInstallerVersion(): array { - $nextMinor = '4.x-dev'; - $nextMinorRelease = 'dev-' . $this->getCurrentMinorInstallerVersion('4') . '-release'; - $currentMinor = $this->getCurrentMinorInstallerVersion('4') . '.x-dev'; + $nextMinorCms4 = '4.x-dev'; + $nextMinorCms4Release = 'dev-' . $this->getCurrentMinorInstallerVersion('4') . '-release'; + $currentMinorCms4 = $this->getCurrentMinorInstallerVersion('4') . '.x-dev'; return [ // no-installer repo ['myaccount/recipe-cms', '4', ''], @@ -105,50 +108,59 @@ public function provideGetInstallerVersion(): array ['myaccount/recipe-cms', 'pulls/burger/myfeature', ''], ['myaccount/recipe-cms', '4-release', ''], ['myaccount/recipe-cms', '4.10-release', ''], + ['myaccount/recipe-cms', '5', ''], + ['myaccount/recipe-cms', '5.1', ''], + ['myaccount/recipe-cms', '6', ''], // lockstepped repo with 4.* naming ['myaccount/silverstripe-framework', '4', '4.x-dev'], ['myaccount/silverstripe-framework', '4.10', '4.10.x-dev'], - ['myaccount/silverstripe-framework', 'burger', $currentMinor], + ['myaccount/silverstripe-framework', 'burger', $currentMinorCms4], ['myaccount/silverstripe-framework', 'pulls/4/mybugfix', '4.x-dev'], ['myaccount/silverstripe-framework', 'pulls/4.10/mybugfix', '4.10.x-dev'], - ['myaccount/silverstripe-framework', 'pulls/burger/myfeature', $currentMinor], + ['myaccount/silverstripe-framework', 'pulls/burger/myfeature', $currentMinorCms4], ['myaccount/silverstripe-framework', '4-release', 'dev-4-release'], ['myaccount/silverstripe-framework', '4.10-release', 'dev-4.10-release'], ['myaccount/silverstripe-framework', 'pulls/4.10-release/some-change', 'dev-4.10-release'], + ['myaccount/silverstripe-framework', '5', '5.x-dev'], + ['myaccount/silverstripe-framework', '5.1', '5.1.x-dev'], + ['myaccount/silverstripe-framework', '6', '6.x-dev'], // lockstepped repo with 1.* naming ['myaccount/silverstripe-admin', '1', '4.x-dev'], ['myaccount/silverstripe-admin', '1.10', '4.10.x-dev'], - ['myaccount/silverstripe-admin', 'burger', $currentMinor], + ['myaccount/silverstripe-admin', 'burger', $currentMinorCms4], ['myaccount/silverstripe-admin', 'pulls/1/mybugfix', '4.x-dev'], ['myaccount/silverstripe-admin', 'pulls/1.10/mybugfix', '4.10.x-dev'], - ['myaccount/silverstripe-admin', 'pulls/burger/myfeature', $currentMinor], + ['myaccount/silverstripe-admin', 'pulls/burger/myfeature', $currentMinorCms4], ['myaccount/silverstripe-admin', '1-release', 'dev-4-release'], ['myaccount/silverstripe-admin', '1.10-release', 'dev-4.10-release'], ['myaccount/silverstripe-admin', 'pulls/1.10-release/some-change', 'dev-4.10-release'], + ['myaccount/silverstripe-admin', '2', '5.x-dev'], + ['myaccount/silverstripe-admin', '2.1', '5.1.x-dev'], + ['myaccount/silverstripe-admin', '3', '6.x-dev'], // non-lockedstepped repo - ['myaccount/silverstripe-tagfield', '2', $nextMinor], - ['myaccount/silverstripe-tagfield', '2.9', $currentMinor], - ['myaccount/silverstripe-tagfield', 'burger', $currentMinor], - ['myaccount/silverstripe-tagfield', 'pulls/2/mybugfix', $nextMinor], - ['myaccount/silverstripe-tagfield', 'pulls/2.9/mybugfix', $currentMinor], - ['myaccount/silverstripe-tagfield', 'pulls/burger/myfeature', $currentMinor], + ['myaccount/silverstripe-tagfield', '2', $nextMinorCms4], + ['myaccount/silverstripe-tagfield', '2.9', $currentMinorCms4], + ['myaccount/silverstripe-tagfield', 'burger', $currentMinorCms4], + ['myaccount/silverstripe-tagfield', 'pulls/2/mybugfix', $nextMinorCms4], + ['myaccount/silverstripe-tagfield', 'pulls/2.9/mybugfix', $currentMinorCms4], + ['myaccount/silverstripe-tagfield', 'pulls/burger/myfeature', $currentMinorCms4], ['myaccount/silverstripe-tagfield', '2-release', 'dev-' . $this->getCurrentMinorInstallerVersion('4') . '-release'], - ['myaccount/silverstripe-tagfield', '2.9-release', $nextMinorRelease], - ['myaccount/silverstripe-tagfield', 'pulls/2.9-release/some-change', $nextMinorRelease], + ['myaccount/silverstripe-tagfield', '2.9-release', $nextMinorCms4Release], + ['myaccount/silverstripe-tagfield', 'pulls/2.9-release/some-change', $nextMinorCms4Release], // hardcoded repo version - ['myaccount/silverstripe-session-manager', '1', $nextMinor], + ['myaccount/silverstripe-session-manager', '1', $nextMinorCms4], ['myaccount/silverstripe-session-manager', '1.2', '4.10.x-dev'], - ['myaccount/silverstripe-session-manager', 'burger', $currentMinor], + ['myaccount/silverstripe-session-manager', 'burger', $currentMinorCms4], ['myaccount/silverstripe-session-manager', '1.2-release', 'dev-4.10-release'], // hardcoded repo version using array - ['myaccount/silverstripe-html5', '2', $nextMinor], + ['myaccount/silverstripe-html5', '2', $nextMinorCms4], ['myaccount/silverstripe-html5', '2.2', '4.10.x-dev'], ['myaccount/silverstripe-html5', '2.3', '4.10.x-dev'], ['myaccount/silverstripe-html5', '2.4', '4.11.x-dev'], - ['myaccount/silverstripe-html5', 'burger', $currentMinor], + ['myaccount/silverstripe-html5', 'burger', $currentMinorCms4], // force installer unlockedstepped repo - ['myaccount/silverstripe-serve', '2', $nextMinor], - ['myaccount/silverstripe-behat-extension', '2', $nextMinor], + ['myaccount/silverstripe-serve', '2', $nextMinorCms4], + ['myaccount/silverstripe-behat-extension', '2', $nextMinorCms4], ]; } @@ -309,6 +321,73 @@ public function provideCreateJson(): array ], ] ], + // general test for v6 + [ + implode("\n", [ + $this->getGenericYml(), + << '6.x-dev', + 'php' => '8.1', + 'db' => DB_MYSQL_57, + 'composer_require_extra' => '', + 'composer_args' => '--prefer-lowest', + 'name_suffix' => '', + 'phpunit' => 'true', + 'phpunit_suite' => 'all', + 'phplinting' => 'false', + 'phpcoverage' => 'false', + 'endtoend' => 'false', + 'endtoend_suite' => 'root', + 'endtoend_config' => '', + 'js' => 'false', + 'needs_full_setup' => 'true', + 'name' => '8.1 prf-low mysql57 phpunit all', + ], + [ + 'installer_version' => '6.x-dev', + 'php' => '8.2', + 'db' => DB_MARIADB, + 'composer_require_extra' => '', + 'composer_args' => '', + 'name_suffix' => '', + 'phpunit' => 'true', + 'phpunit_suite' => 'all', + 'phplinting' => 'false', + 'phpcoverage' => 'false', + 'endtoend' => 'false', + 'endtoend_suite' => 'root', + 'endtoend_config' => '', + 'js' => 'false', + 'needs_full_setup' => 'true', + 'name' => '8.2 mariadb phpunit all', + ], + [ + 'installer_version' => '6.x-dev', + 'php' => '8.3', + 'db' => DB_MYSQL_80, + 'composer_require_extra' => '', + 'composer_args' => '', + 'name_suffix' => '', + 'phpunit' => 'true', + 'phpunit_suite' => 'all', + 'phplinting' => 'false', + 'phpcoverage' => 'false', + 'endtoend' => 'false', + 'endtoend_suite' => 'root', + 'endtoend_config' => '', + 'js' => 'false', + 'needs_full_setup' => 'true', + 'name' => '8.3 mysql80 phpunit all', + ], + ] + ], // general test for v5.1 [ implode("\n", [ @@ -774,9 +853,9 @@ public function provideGraphql3(): array } /** - * @dataProvider provideGetInstallerVersionCMS5FromComposer + * @dataProvider provideGetInstallerVersionFromComposer */ - public function testGetInstallerVersionCMS5FromComposer( + public function testGetInstallerVersionFromComposer( string $githubRepository, string $branch, array $composerDeps, @@ -812,17 +891,20 @@ public function testGetInstallerVersionCMS5FromComposer( } } - public function provideGetInstallerVersionCMS5FromComposer(): array + public function provideGetInstallerVersionFromComposer(): array { - $currentMinor = $this->getCurrentMinorInstallerVersion('4') . '.x-dev'; + $currentMinorCms4 = $this->getCurrentMinorInstallerVersion('4') . '.x-dev'; return [ // priority given to branch name ['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', 'burger', [], 'silverstripe-theme', $currentMinorCms4], ['myaccount/silverstripe-framework', '5', [], 'silverstripe-recipe', '5.x-dev'], ['myaccount/silverstripe-framework', '5.10', [], 'silverstripe-vendormodule', '5.10.x-dev'], + ['myaccount/silverstripe-framework', '6', [], 'silverstripe-recipe', '6.x-dev'], + ['myaccount/silverstripe-framework', '6.10', [], 'silverstripe-vendormodule', '6.10.x-dev'], // fallback to looking at deps in composer.json, use current minor of installer .x-dev + // CMS 5 ['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'], @@ -832,6 +914,17 @@ public function provideGetInstallerVersionCMS5FromComposer(): array ['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], 'package', ''], ['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], '', ''], ['myaccount/silverstripe-somemodule', '3', [], '', ''], + // CMS 6 - note some of the 6.x-dev $expected will need to change once once + // the `6.0` branches are created - currently only `6` branches exist + ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '6.x-dev'], 'silverstripe-module', '6.x-dev'], + ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '6.0.x-dev'], 'silverstripe-vendormodule', '6.0.x-dev'], + ['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^6'], 'silverstripe-theme', '6.x-dev'], + ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^6'], 'silverstripe-recipe', '6.x-dev'], + ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^3'], 'silverstripe-vendormodule', '6.x-dev'], + ['myaccount/silverstripe-somemodule', '4', ['silverstripe/framework' => '^6'], 'silverstripe-vendormodule', '6.x-dev'], + ['myaccount/silverstripe-somemodule', '4', ['silverstripe/framework' => '^6'], 'package', ''], + ['myaccount/silverstripe-somemodule', '4', ['silverstripe/framework' => '^6'], '', ''], + ['myaccount/silverstripe-somemodule', '4', [], '', ''], ]; } @@ -898,6 +991,15 @@ public function provideComposerInstall(): array '8.1 mysql57 phpunit all' ] ], + 'composerinstall_nophpversion_framework6' => [ + 'true', + '', + '6.x-dev', + 'silverstripe-vendormodule', + [ + '8.1 mysql57 phpunit all' + ] + ], 'composerinstall_definedphpversion_framework5' => [ 'true', '21.99', @@ -938,6 +1040,17 @@ public function provideComposerInstall(): array '8.3 mysql80 phpunit all', ] ], + 'composerupgrade_nophpversion_framework6' => [ + 'false', + '', + '6.x-dev', + 'silverstripe-vendormodule', + [ + '8.1 prf-low mysql57 phpunit all', + '8.2 mariadb phpunit all', + '8.3 mysql80 phpunit all', + ] + ], 'composerupgrade_definedphpversion_framework5' => [ 'false', '21.99', @@ -960,6 +1073,17 @@ public function provideComposerInstall(): array '8.3 mysql80 phpunit all', ] ], + 'composerupgrade_invalidphpversion_framework6' => [ + 'false', + 'fish', + '6.x-dev', + 'silverstripe-theme', + [ + '8.1 prf-low mysql57 phpunit all', + '8.2 mariadb phpunit all', + '8.3 mysql80 phpunit all', + ] + ], 'composerupgrade_nophpversion_framework51' => [ 'false', '',