From f8ea85a1efbc180a7f965e5fc085baa100bd562d Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Tue, 21 Nov 2023 16:48:06 +1300 Subject: [PATCH] MNT New PHP 8.3 support --- consts.php | 60 ++++++++++++++++++++++++++++++++++++++++ job_creator.php | 23 ++++++++++++--- tests/JobCreatorTest.php | 45 ++++++++++++++++++++++++++---- 3 files changed, 118 insertions(+), 10 deletions(-) diff --git a/consts.php b/consts.php index 3e69073..211af75 100644 --- a/consts.php +++ b/consts.php @@ -31,6 +31,11 @@ '8.1', '8.2', ], + '5.2' => [ + '8.1', + '8.2', + '8.3', + ], '5' => [ '8.1', '8.2', @@ -529,4 +534,59 @@ 'silverstripe-versionfeed' => '3.1', 'silverstripe-webauthn-authenticator' => '5.1', ], + '5.2' => [ + 'cwp-agencyextensions' => '3.1', + 'cwp-starter-theme' => '4.0', + 'cwp-watea-theme' => '4.0', + 'silverstripe-advancedworkflow' => '6.1', + 'silverstripe-auditor' => '3.0', + 'silverstripe-blog' => '4.1', + 'silverstripe-composer-update-checker' => '4.0', + 'silverstripe-contentreview' => '5.1', + 'silverstripe-crontask' => '3.0', + 'silverstripe-developer-docs' => '5.1', + 'silverstripe-documentconverter' => '3.1', + 'silverstripe-dynamodb' => '5.0', + 'silverstripe-elemental' => '5.1', + 'silverstripe-elemental-bannerblock' => '3.1', + 'silverstripe-elemental-fileblock' => '3.1', + 'silverstripe-elemental-userforms' => '4.1', + 'silverstripe-environmentcheck' => '3.0', + 'silverstripe-externallinks' => '3.1', + 'silverstripe-fluent' => '7.0', + 'silverstripe-graphql' => '5.1', + 'silverstripe-gridfield-bulk-editing-tools' => '4.0', + 'silverstripe-gridfieldextensions' => '4.0', + 'silverstripe-gridfieldqueuedexport' => '3.1', + 'silverstripe-hybridsessions' => '3.0', + 'silverstripe-iframe' => '3.1', + 'silverstripe-ldap' => '2.1', + 'silverstripe-login-forms' => '5.1', + 'silverstripe-lumberjack' => '3.0', + 'silverstripe-maintenance' => '3.0', + 'silverstripe-mfa' => '5.1', + 'silverstripe-mimevalidator' => '3.0', + 'silverstripe-multivaluefield' => '6.0', + 'silverstripe-queuedjobs' => '5.0', + 'silverstripe-realme' => '5.2', + 'silverstripe-registry' => '3.1', + 'silverstripe-restfulserver' => '3.0', + 'silverstripe-securityreport' => '3.0', + 'silverstripe-segment-field' => '3.1', + 'silverstripe-session-manager' => '2.1', + 'silverstripe-sharedraftcontent' => '3.1', + 'silverstripe-simple' => '3.3', + 'silverstripe-sitewidecontent-report' => '4.1', + 'silverstripe-spamprotection' => '4.1', + 'silverstripe-staticpublishqueue' => '6.1', + 'silverstripe-subsites' => '3.1', + 'silverstripe-tagfield' => '3.1', + 'silverstripe-taxonomy' => '3.1', + 'silverstripe-textextraction' => '4.0', + 'silverstripe-totp-authenticator' => '5.1', + 'silverstripe-userforms' => '6.1', + 'silverstripe-vendor-plugin' => '2.0', + 'silverstripe-versionfeed' => '3.1', + 'silverstripe-webauthn-authenticator' => '5.1', + ], ]; diff --git a/job_creator.php b/job_creator.php index 96b56f9..f342504 100644 --- a/job_creator.php +++ b/job_creator.php @@ -197,11 +197,8 @@ private function isAllowedPhpVersion(string $phpVersion) return false; } - private function getPhpVersion(int $phpIndex): string + private function getBranchVersion(): string { - if ($this->phpVersionOverride) { - return $this->phpVersionOverride; - } $key = str_replace('.x-dev', '', $this->installerVersion); $repo = explode('/', $this->githubRepository)[1]; if (in_array($repo, NO_INSTALLER_LOCKSTEPPED_REPOS)) { @@ -213,6 +210,16 @@ private function getPhpVersion(int $phpIndex): string $key = sprintf('%d.%d', $cmsMajor, $matches[1]); } } + + return $key; + } + + private function getPhpVersion(int $phpIndex): string + { + if ($this->phpVersionOverride) { + return $this->phpVersionOverride; + } + $key = $this->getBranchVersion(); $phpVersions = INSTALLER_TO_PHP_VERSIONS[$key] ?? INSTALLER_TO_PHP_VERSIONS['4']; // Use the max allowed php version if (!array_key_exists($phpIndex, $phpVersions)) { @@ -235,6 +242,7 @@ private function getPhpVersion(int $phpIndex): string return $phpVersion; } } + throw new Exception("No valid PHP version allowed"); } @@ -379,6 +387,13 @@ private function createPhpunitJobs( 'phpunit' => true, 'phpunit_suite' => $suite, ]); + if ($this->getBranchVersion() === '5.2') { + $matrix['include'][] = $this->createJob(2, [ + 'db' => DB_MYSQL_80, + 'phpunit' => true, + 'phpunit_suite' => $suite, + ]); + } } } return $matrix; diff --git a/tests/JobCreatorTest.php b/tests/JobCreatorTest.php index 927c4fe..b249b0e 100644 --- a/tests/JobCreatorTest.php +++ b/tests/JobCreatorTest.php @@ -675,9 +675,9 @@ public function provideGetInstallerVersionCMS5FromComposer(): array // 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.1.x-dev'], - ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], '5.1.x-dev'], - ['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], '5.1.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'], ]; } @@ -772,7 +772,7 @@ public function provideComposerInstall(): array [ '8.1 prf-low mysql57 phpunit all', '8.1 mariadb phpunit all', - '8.2 mysql80 phpunit all' + '8.2 mysql80 phpunit all', ] ], 'composerupgrade_definedphpversion_framework5' => [ @@ -782,7 +782,7 @@ public function provideComposerInstall(): array [ '8.1 prf-low mysql57 phpunit all', '8.1 mariadb phpunit all', - '8.2 mysql80 phpunit all' + '8.2 mysql80 phpunit all', ] ], 'composerupgrade_invalidphpversion_framework5' => [ @@ -792,7 +792,40 @@ public function provideComposerInstall(): array [ '8.1 prf-low mysql57 phpunit all', '8.1 mariadb phpunit all', - '8.2 mysql80 phpunit all' + '8.2 mysql80 phpunit all', + ] + ], + 'composerupgrade_nophpversion_framework52' => [ + 'false', + '', + '5.2.x-dev', + [ + '8.1 prf-low mysql57 phpunit all', + '8.1 mariadb phpunit all', + '8.2 mysql80 phpunit all', + '8.3 mysql80 phpunit all', + ] + ], + 'composerupgrade_definedphpversion_framework52' => [ + 'false', + '21.99', + '5.2.x-dev', + [ + '8.1 prf-low mysql57 phpunit all', + '8.1 mariadb phpunit all', + '8.2 mysql80 phpunit all', + '8.3 mysql80 phpunit all', + ] + ], + 'composerupgrade_invalidphpversion_framework52' => [ + 'false', + 'fish', + '5.2.x-dev', + [ + '8.1 prf-low mysql57 phpunit all', + '8.1 mariadb phpunit all', + '8.2 mysql80 phpunit all', + '8.3 mysql80 phpunit all', ] ], ];