diff --git a/src/Command/CodeStudio/CodeStudioCiCdVariables.php b/src/Command/CodeStudio/CodeStudioCiCdVariables.php index 3a5b50bd6..f81893f59 100644 --- a/src/Command/CodeStudio/CodeStudioCiCdVariables.php +++ b/src/Command/CodeStudio/CodeStudioCiCdVariables.php @@ -16,7 +16,7 @@ public static function getList(): array { /** * @return array */ - public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL): array { + public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string $cloudKey = NULL, ?string $cloudSecret = NULL, ?string $projectAccessTokenName = NULL, ?string $projectAccessToken = NULL, ?string $phpVersion = NULL): array { return [ [ 'key' => 'ACQUIA_APPLICATION_UUID', @@ -53,6 +53,13 @@ public static function getDefaults(?string $cloudApplicationUuid = NULL, ?string 'value' => $projectAccessToken, 'variable_type' => 'env_var', ], + [ + 'key' => 'PHP_VERSION', + 'masked' => FALSE, + 'protected' => FALSE, + 'value' => $phpVersion, + 'variable_type' => 'env_var', + ], ]; } diff --git a/src/Command/CodeStudio/CodeStudioWizardCommand.php b/src/Command/CodeStudio/CodeStudioWizardCommand.php index 4788d92cb..2d83e22a2 100644 --- a/src/Command/CodeStudio/CodeStudioWizardCommand.php +++ b/src/Command/CodeStudio/CodeStudioWizardCommand.php @@ -46,6 +46,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int // But, we specifically need an API Token key-pair of Code Studio. // So we reauthenticate to be sure we're using the provided credentials. $this->reAuthenticate($cloudKey, $cloudSecret, $this->cloudCredentials->getBaseUri(), $this->cloudCredentials->getAccountsUri()); + + $phpVersions = [ + 'PHP_version_8.1' => "8.1", + 'PHP_version_8.2' => "8.2", + ]; + $project = $this->io->choice('Select a PHP version', array_values($phpVersions), $phpVersions['PHP_version_8.1']); + $project = array_search($project, $phpVersions, TRUE); + $phpVersion = $phpVersions[$project]; + $appUuid = $this->determineCloudApplication(); // Get Cloud account. @@ -92,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $projectAccessTokenName = 'acquia-codestudio'; $projectAccessToken = $this->createProjectAccessToken($project, $projectAccessTokenName); $this->updateGitLabProject($project); - $this->setGitLabCiCdVariables($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken); + $this->setGitLabCiCdVariables($project, $appUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion); $this->createScheduledPipeline($project); $this->io->success([ @@ -161,9 +170,9 @@ private function createProjectAccessToken(array $project, string $projectAccessT return $projectAccessToken['token']; } - private function setGitLabCiCdVariables(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken): void { + private function setGitLabCiCdVariables(array $project, string $cloudApplicationUuid, string $cloudKey, string $cloudSecret, string $projectAccessTokenName, string $projectAccessToken, string $phpVersion): void { $this->io->writeln("Setting GitLab CI/CD variables for {$project['path_with_namespace']}.."); - $gitlabCicdVariables = CodeStudioCiCdVariables::getDefaults($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken); + $gitlabCicdVariables = CodeStudioCiCdVariables::getDefaults($cloudApplicationUuid, $cloudKey, $cloudSecret, $projectAccessTokenName, $projectAccessToken, $phpVersion); $gitlabCicdExistingVariables = $this->gitLabClient->projects() ->variables($project['id']); $gitlabCicdExistingVariablesKeyed = []; diff --git a/tests/phpunit/src/CommandTestBase.php b/tests/phpunit/src/CommandTestBase.php index ab573ba7e..9e7517986 100644 --- a/tests/phpunit/src/CommandTestBase.php +++ b/tests/phpunit/src/CommandTestBase.php @@ -633,7 +633,7 @@ protected function getMockGitLabVariables(): array { 'protected' => FALSE, 'value' => '111aae74-e81a-4052-b4b9-a27a62e6b6a6', 'variable_type' => 'env_var', - ], + ], ]; } diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php index b797d674a..ca22288e2 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php @@ -93,6 +93,28 @@ public function providerTestCommand(): array { [ // 'Would you like to create a new Code Studio project? 'y', + // Select PHP version 8.1 + '0', + // Do you want to continue? + 'y', + // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: + 'y', + ], + // Args. + [ + '--key' => $this->key, + '--secret' => $this->secret, + ], + ], + [ + // No projects. + [], + // Inputs. + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Select PHP version 8.2 + '1', // Do you want to continue? 'y', // Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]: @@ -133,6 +155,27 @@ public function providerTestCommand(): array { $this->key, // Enter Cloud secret, $this->secret, + // Select PHP version 8.1 + '0', + // Do you want to continue? + 'y', + ], + // Args + [], + ], + [ + // No projects. + [], + // Inputs + [ + // 'Would you like to create a new Code Studio project? + 'y', + // Enter Cloud Key + $this->key, + // Enter Cloud secret, + $this->secret, + // Select PHP version 8.2 + '1', // Do you want to continue? 'y', ],