Skip to content

Commit

Permalink
FIX Ensure recipes get databases set up (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jan 29, 2024
1 parent cdeaecd commit 7ad5b31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class JobCreator

public string $githubRepository = '';

public string $repoName = '';

private string $installerVersion = '';

private string $parentBranch = '';
Expand All @@ -21,16 +23,16 @@ class JobCreator
*/
public function getInstallerVersion(): string
{
$repo = explode('/', $this->githubRepository)[1];
$this->repoName = explode('/', $this->githubRepository)[1];
// repo should not use installer
if (in_array($repo, NO_INSTALLER_LOCKSTEPPED_REPOS) || in_array($repo, NO_INSTALLER_UNLOCKSTEPPED_REPOS)) {
if (in_array($this->repoName, NO_INSTALLER_LOCKSTEPPED_REPOS) || in_array($this->repoName, NO_INSTALLER_UNLOCKSTEPPED_REPOS)) {
return '';
}
$branch = $this->getCleanedBranch(true);
$isReleaseBranch = preg_match('#^[0-9\.]+-release$#', $branch);
$cmsMajor = $this->getCmsMajor();
// repo is a lockstepped repo
if (in_array($repo, LOCKSTEPPED_REPOS) && (is_numeric($branch) || $isReleaseBranch)) {
if (in_array($this->repoName, LOCKSTEPPED_REPOS) && (is_numeric($branch) || $isReleaseBranch)) {
if ($isReleaseBranch) {
return 'dev-' . preg_replace('#^([0-9])#', $cmsMajor, $branch);
}
Expand All @@ -47,7 +49,7 @@ public function getInstallerVersion(): string
foreach (INSTALLER_TO_REPO_MINOR_VERSIONS[$installerVersion] as $_repo => $_repoVersions) {
$repoVersions = is_array($_repoVersions) ? $_repoVersions : [$_repoVersions];
foreach ($repoVersions as $repoVersion) {
if ($repo === $_repo && $repoVersion === preg_replace('#-release$#', '', $branch)) {
if ($this->repoName === $_repo && $repoVersion === preg_replace('#-release$#', '', $branch)) {
if ($isReleaseBranch) {
return 'dev-' . $installerVersion . '-release';
}
Expand Down Expand Up @@ -129,7 +131,7 @@ public function createJob(int $phpIndex, array $opts): array
'endtoend_suite' => 'root',
'endtoend_config' => '',
'js' => false,
'needs_full_setup' => $this->installerVersion !== '',
'needs_full_setup' => $this->installerVersion !== '' && !in_array($this->repoName, NO_INSTALLER_LOCKSTEPPED_REPOS),
];
return array_merge($default, $opts);
}
Expand Down Expand Up @@ -216,8 +218,7 @@ private function isAllowedPhpVersion(string $phpVersion)
private function getBranchName(): string
{
$version = str_replace('.x-dev', '', $this->installerVersion);
$repo = explode('/', $this->githubRepository)[1];
if (in_array($repo, NO_INSTALLER_LOCKSTEPPED_REPOS)) {
if (in_array($this->repoName, NO_INSTALLER_LOCKSTEPPED_REPOS)) {
$cmsMajor = $this->getCmsMajor();
$branch = $this->getCleanedBranch();
if (preg_match('#^[1-9]$#', $branch)) {
Expand Down Expand Up @@ -274,16 +275,15 @@ private function getCmsMajor(): string
private function getCmsMajorFromBranch(): string
{
$branch = $this->getCleanedBranch();
$repo = explode('/', $this->githubRepository)[1];
$branchMajor = '';
if (preg_match('#^[1-9]$#', $branch)) {
$branchMajor = $branch;
} elseif (preg_match('#^([1-9])\.[0-9]+$#', $branch, $matches)) {
$branchMajor = $matches[1];
}
foreach (array_keys(CMS_TO_REPO_MAJOR_VERSIONS) as $cmsMajor) {
if (isset(CMS_TO_REPO_MAJOR_VERSIONS[$cmsMajor][$repo])) {
if (CMS_TO_REPO_MAJOR_VERSIONS[$cmsMajor][$repo] === $branchMajor) {
if (isset(CMS_TO_REPO_MAJOR_VERSIONS[$cmsMajor][$this->repoName])) {
if (CMS_TO_REPO_MAJOR_VERSIONS[$cmsMajor][$this->repoName] === $branchMajor) {
return $cmsMajor;
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/JobCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function testCreateJob(
): void {
$creator = new JobCreator();
$creator->githubRepository = $githubRepository;
$creator->repoName = explode('/', $githubRepository)[1];
$creator->branch = $branch;
$actual = $creator->createJob($phpIndex, $opts);
foreach ($expected as $key => $expectedVal) {
Expand Down Expand Up @@ -74,6 +75,7 @@ public function testGetInstallerVersion(
): void {
$creator = new JobCreator();
$creator->githubRepository = $githubRepository;
$creator->repoName = explode('/', $githubRepository)[1];
$creator->branch = $branch;
$actual = $creator->getInstallerVersion();
$this->assertSame($expected, $actual);
Expand Down

0 comments on commit 7ad5b31

Please sign in to comment.