Skip to content

Commit

Permalink
ENH Add MySQL 8.4 to matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Nov 18, 2024
1 parent 8bcfe4f commit d7aaa3f
Show file tree
Hide file tree
Showing 3 changed files with 625 additions and 423 deletions.
1 change: 1 addition & 0 deletions consts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const DB_MYSQL_57 = 'mysql57';
const DB_MYSQL_57_PDO = 'mysql57pdo';
const DB_MYSQL_80 = 'mysql80';
const DB_MYSQL_84 = 'mysql84';
const DB_PGSQL = 'pgsql';
const DB_MARIADB = 'mariadb';

Expand Down
38 changes: 29 additions & 9 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,15 @@ private function createPhpunitJobs(
]);
} else {
$cmsMajor = BranchLogic::getCmsMajor($this->repoData, $this->branch, $this->getComposerJsonContent()) ?: MetaData::LOWEST_SUPPORTED_CMS_MAJOR;
$dbsAdded = [];
$db = in_array($cmsMajor, ['4', '5']) ? DB_MYSQL_57 : DB_MARIADB;
$matrix['include'][] = $this->createJob(0, [
'composer_args' => '--prefer-lowest',
'db' => in_array($cmsMajor, ['4', '5']) ? DB_MYSQL_57 : DB_MARIADB,
'db' => $db,
'phpunit' => true,
'phpunit_suite' => $suite,
]);
$dbsAdded[] = $db;
if ($cmsMajor === '4') {
if (!$this->doRunPhpCoverage($run)) {
// this same mysql pdo test is also created for the phpcoverage job, so only add it here if
Expand All @@ -334,14 +337,25 @@ private function createPhpunitJobs(
'phpunit_suite' => $suite,
]);
} else {
// phpunit tests for cms 5 are run on php 8.1, 8.2 or 8.3 and mysql 8.0 or mariadb
// phpunit tests for cms 5 are run on php 8.1, 8.2 or 8.3 and mysql 8.0, 8.4 or mariadb
$phpToDB = $this->generatePhpToDBMap();
$lastPhp = null;
foreach ($phpToDB as $php => $db) {
$matrix['include'][] = $this->createJob($this->getIndexByPHPVersion($php), [
'db' => $db,
'phpunit' => true,
'phpunit_suite' => $suite,
]);
$dbsAdded[] = $db;
$lastPhp = $php;
}
$dbNotAdded = array_diff($this->getDBs(), $dbsAdded);
foreach ($dbNotAdded as $db) {
$matrix['include'][] = $this->createJob($this->getIndexByPHPVersion($lastPhp), [
'db' => $db,
'phpunit' => true,
'phpunit_suite' => $suite,
]);
}
}
}
Expand All @@ -365,6 +379,18 @@ private function getIndexByPHPVersion(string $version): int
return array_search($version, $this->getListOfPhpVersionsByBranchName()) ?? 0;
}

/**
* Return a list of DBS to test against for the current CMS major
*/
private function getDBs()
{
$cmsMajor = BranchLogic::getCmsMajor($this->repoData, $this->branch, $this->getComposerJsonContent()) ?: MetaData::LOWEST_SUPPORTED_CMS_MAJOR;
if ($cmsMajor === '5') {
return [DB_MARIADB, DB_MYSQL_80, DB_MYSQL_84];
}
return [DB_MYSQL_80, DB_MYSQL_84, DB_MARIADB];
}

/**
* Generate a map of php versions to db versions
* e.g. [ '8.1' => 'mariadb', '8.2' => 'mysql80' ]
Expand All @@ -373,12 +399,7 @@ private function generatePhpToDBMap(): array
{
$map = [];
$phpVersions = $this->getListOfPhpVersionsByBranchName();
$cmsMajor = BranchLogic::getCmsMajor($this->repoData, $this->branch, $this->getComposerJsonContent()) ?: MetaData::LOWEST_SUPPORTED_CMS_MAJOR;
if ($cmsMajor === '5') {
$dbs = [DB_MARIADB, DB_MYSQL_80];
} else {
$dbs = [DB_MYSQL_80, DB_MARIADB];
}
$dbs = $this->getDBs();
foreach ($phpVersions as $key => $phpVersion) {
if (count($phpVersions) < 3) {
$map[$phpVersion] = $dbs[$key];
Expand All @@ -387,7 +408,6 @@ private function generatePhpToDBMap(): array
$map[$phpVersion] = array_key_exists($key, $dbs) ? $dbs[$key - 1] : DB_MYSQL_80;
}
}

return $map;
}

Expand Down
Loading

0 comments on commit d7aaa3f

Please sign in to comment.