Skip to content

Commit

Permalink
CLI-1320: Update cx-api-spec to provide OS upgrade API (#1733)
Browse files Browse the repository at this point in the history
* CLI-1320: Update cx-api-spec to provide OS upgrade API

* Convert schemas to JSON

* fix tests

* ignore msi with no mutations
  • Loading branch information
danepowell authored May 14, 2024
1 parent 2698b1e commit 90fd815
Show file tree
Hide file tree
Showing 15 changed files with 54,980 additions and 36,327 deletions.
46,058 changes: 46,058 additions & 0 deletions assets/acquia-spec.json

Large diffs are not rendered by default.

30,146 changes: 0 additions & 30,146 deletions assets/acquia-spec.yaml

This file was deleted.

8,908 changes: 8,908 additions & 0 deletions assets/acsf-spec.json

Large diffs are not rendered by default.

6,157 changes: 0 additions & 6,157 deletions assets/acsf-spec.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions bin/acli
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ $application->setName('Acquia CLI');
$application->setVersion(getenv('ACLI_VERSION'));
/** @var ApiCommandHelper $helper */
$helper = $container->get(ApiCommandHelper::class);
$application->addCommands($helper->getApiCommands( __DIR__ . '/../assets/acquia-spec.yaml', 'api', $container->get(ApiCommandFactory::class)));
$application->addCommands($helper->getApiCommands( __DIR__ . '/../assets/acsf-spec.yaml', 'acsf', $container->get(AcsfCommandFactory::class)));
$application->addCommands($helper->getApiCommands( __DIR__ . '/../assets/acquia-spec.json', 'api', $container->get(ApiCommandFactory::class)));
$application->addCommands($helper->getApiCommands( __DIR__ . '/../assets/acsf-spec.json', 'acsf', $container->get(AcsfCommandFactory::class)));
try {
$application->add(new SelfUpdateCommand($application->getName(), $application->getVersion(), 'acquia/cli'));
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"infection --threads=max --only-covered"
],
"mutation-diff-lines": [
"infection --threads=max --only-covered --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --min-covered-msi=100"
"infection --threads=max --only-covered --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --min-covered-msi=100 --ignore-msi-with-no-mutations"
],
"cs": "phpcs",
"cbf": "phpcbf",
Expand Down
9 changes: 1 addition & 8 deletions src/Command/Api/ApiCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Yaml\Yaml;

class ApiCommandHelper {

Expand Down Expand Up @@ -300,7 +299,7 @@ private function getCloudApiSpec(string $specFilePath): array {

// Parse file. This can take a long while!
$this->logger->debug("Rebuilding caches...");
$spec = Yaml::parseFile($specFilePath);
$spec = json_decode(file_get_contents($specFilePath), TRUE);

$cache->warmUp([
$cacheKey => $spec,
Expand All @@ -316,12 +315,6 @@ private function getCloudApiSpec(string $specFilePath): array {
private function generateApiCommandsFromSpec(array $acquiaCloudSpec, string $commandPrefix, CommandFactoryInterface $commandFactory): array {
$apiCommands = [];
foreach ($acquiaCloudSpec['paths'] as $path => $endpoint) {
// Skip internal endpoints. These shouldn't actually be in the spec.
// @infection-ignore-all
if (array_key_exists('x-internal', $endpoint) && $endpoint['x-internal']) {
continue;
}

foreach ($endpoint as $method => $schema) {
if (!array_key_exists('x-cli-name', $schema)) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/CloudApi/AcsfClientServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class AcsfClientServiceTest extends TestBase {

protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../../assets/acsf-spec.yaml';
protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../../assets/acsf-spec.json';
protected string $apiCommandPrefix = 'acsf';

/**
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
*/
class AcsfApiCommandTest extends AcsfCommandTestBase {

protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../../../assets/acsf-spec.yaml';
protected string $apiCommandPrefix = 'acsf';

public function setUp(): void {
parent::setUp();
$this->clientProphecy->addOption('headers', ['Accept' => 'application/hal+json, version=2']);
Expand Down
4 changes: 4 additions & 0 deletions tests/phpunit/src/Commands/Acsf/AcsfCommandTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ abstract class AcsfCommandTestBase extends CommandTestBase {

protected string $acsfKey = 'h@x0r';

protected string $apiCommandPrefix = 'acsf';

protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../../../assets/acsf-spec.json';

/**
* @return array<mixed>
*/
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/src/Commands/Acsf/AcsfListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
use Acquia\Cli\Command\Acsf\AcsfListCommandBase;
use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Command\Self\ListCommand;
use Acquia\Cli\Tests\CommandTestBase;

/**
* @property AcsfListCommandBase $command
*/
class AcsfListCommandTest extends CommandTestBase {

protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../../../assets/acsf-spec.yaml';
protected string $apiCommandPrefix = 'acsf';
class AcsfListCommandTest extends AcsfCommandTestBase {

public function setUp(): void {
parent::setUp();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Pull/PullCommandTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected function mockExecuteMySqlImport(
$localMachineHelper->checkRequiredBinariesExist(['gunzip', 'mysql'])->shouldBeCalled();
$this->mockExecutePvExists($localMachineHelper, $pvExists);
$process = $this->mockProcess($success);
$filePath = Path::join(sys_get_temp_dir(), "$env-$dbName-$dbMachineName-2012-05-15T12:00:00Z.sql.gz");
$filePath = Path::join(sys_get_temp_dir(), "$env-$dbName-$dbMachineName-2012-05-15T12:00:00.000Z.sql.gz");
$command = $pvExists ? "pv $filePath --bytes --rate | gunzip | MYSQL_PWD=drupal mysql --host=localhost --user=drupal $localDbName" : "gunzip -c $filePath | MYSQL_PWD=drupal mysql --host=localhost --user=drupal $localDbName";
// MySQL import command.
$localMachineHelper
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Ssh/SshKeyInfoCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testInfo(): void {
$this->assertStringContainsString('UUID 02905393-65d7-4bef-873b-24593f73d273', $output);
$this->assertStringContainsString('Label PC Home', $output);
$this->assertStringContainsString('Fingerprint (md5) 5d:23:fb:45:70:df:ef:ad:ca:bf:81:93:cd:50:26:28', $output);
$this->assertStringContainsString('Created at 2017-05-09T20:30:35+00:00', $output);
$this->assertStringContainsString('Created at 2017-05-09T20:30:35.000Z', $output);
}

}
2 changes: 1 addition & 1 deletion tests/phpunit/src/Misc/ApiSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class ApiSpecTest extends TestCase {

public function testApiSpec(): void {
$apiSpecFile = Path::canonicalize(__DIR__ . '/../../../../assets/acquia-spec.yaml');
$apiSpecFile = Path::canonicalize(__DIR__ . '/../../../../assets/acquia-spec.json');
$this->assertFileExists($apiSpecFile);
$apiSpec = file_get_contents($apiSpecFile);
$this->assertStringNotContainsString('x-internal', $apiSpec);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
abstract class TestBase extends TestCase {

protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../assets/acquia-spec.yaml';
protected string $apiSpecFixtureFilePath = __DIR__ . '/../../../assets/acquia-spec.json';

protected ConsoleOutput $consoleOutput;

Expand Down

0 comments on commit 90fd815

Please sign in to comment.