Skip to content

Commit

Permalink
MNT New PHP 8.3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Nov 22, 2023
1 parent 313a706 commit 688f339
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 10 deletions.
60 changes: 60 additions & 0 deletions consts.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
'8.1',
'8.2',
],
'5.2' => [
'8.1',
'8.2',
'8.3',
],
'5' => [
'8.1',
'8.2',
Expand Down Expand Up @@ -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',
],
];
23 changes: 19 additions & 4 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)) {
Expand All @@ -235,6 +242,7 @@ private function getPhpVersion(int $phpIndex): string
return $phpVersion;
}
}

throw new Exception("No valid PHP version allowed");
}

Expand Down Expand Up @@ -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;
Expand Down
45 changes: 39 additions & 6 deletions tests/JobCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];
}
Expand Down Expand Up @@ -772,7 +772,8 @@ 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',
'8.3 mysql80 phpunit all',
]
],
'composerupgrade_definedphpversion_framework5' => [
Expand All @@ -782,7 +783,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' => [
Expand All @@ -792,7 +793,39 @@ 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',
]
],
'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',
]
],
];
Expand Down

0 comments on commit 688f339

Please sign in to comment.