Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Ensure recipes get databases set up #78

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
Comment on lines -24 to +26
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed so that we have access to the repo name in createJob() - and since we now have this property we should use it wherever else we need the repo name as well.

// 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
Loading