Skip to content

Commit

Permalink
Merge pull request #130 from magento-commerce/develop
Browse files Browse the repository at this point in the history
MCLOUD-11596: Release Cloud Tools
  • Loading branch information
BaDos authored Jan 11, 2024
2 parents c6a2c38 + 02a26af commit d730998
Show file tree
Hide file tree
Showing 22 changed files with 214 additions and 29 deletions.
9 changes: 5 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ You must have a [GitHub account](https://help.github.com/en/github/getting-start

## Contribution requirements

1. Contributions must adhere to the [Magento coding standards](https://devdocs.magento.com/guides/v2.3/coding-standards/bk-coding-standards.html).
1. Contributions must adhere to the [coding standards](https://developer.adobe.com/commerce/php/coding-standards/).
2. When you submit a Pull request (PR), write a meaningful description to explain the purpose of your contribution. Comprehensive descriptions increase the chances that a pull request can be merged quickly, without requests for additional clarification. See the [Magento Cloud Tools Pull Request Template](https://github.com/magento/ece-tools/blob/develop/.github/PULL_REQUEST_TEMPLATE.md) for more information.
3. Commits must be accompanied by meaningful commit messages.
4. If your PR includes bug fixes, provide a step-by-step description of how to reproduce the bug in the pull request description.
3. If your PR includes new logic or new features, you must also submit the following information along with the pull request
5. If your PR includes new logic or new features, you must also submit the following information along with the pull request
* Unit/integration test coverage
* Proposed documentation updates: Submit developer documentation contributions to the [Magento DevDocs repository](https://github.com/magento/devdocs/blob/master/.github/CONTRIBUTING.md). Submit updates to Magento user documentation to the [Magento Merchant documentation repository](https://github.com/magento/merchdocs/blob/master/.github/CONTRIBUTING.md).
4. For larger features or changes, [open an issue](https://github.com/magento/ece-tools/issues/new) to discuss the proposed changes prior to development. Discussing the updates in advance can prevent duplicate or unnecessary effort and allow other contributors to provide input.
* Proposed [documentation](https://developer.adobe.com/commerce) updates. Use feedback buttons __Edit in GitHub__ and __Log an issue__ at the top of a relevant topic.
6. For larger features or changes, [open an issue](https://github.com/magento/ece-tools/issues/new) to discuss the proposed changes prior to development. Discussing the updates in advance can prevent duplicate or unnecessary effort and allow other contributors to provide input.

## Contribution process

1. Search current [listed issues](https://github.com/magento/ece-tools/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
2. Review and sign the [Contributor License Agreement (CLA)](https://opensource.adobe.com/cla.html) if this is your first time contributing. You only need to sign the CLA once.
3. Create and test your work.
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

### Release notes

For user-facing changes, add a meaningful release note. For examples, see [Magento Cloud ECE-tools release notes](https://devdocs.magento.com/cloud/release-notes/ece-release-notes.html).
For user-facing changes, add a meaningful release note. For examples, see [Magento Cloud ECE-tools release notes](https://experienceleague.adobe.com/docs/commerce-cloud-service/user-guide/release-notes/ece-tools-package.html).

### Associated documentation updates
<!--
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The Magento Cloud Suite includes a set of packages designed to deploy and manage

## Useful Resources
- [Release Notes](https://github.com/magento/ece-tools/releases)
- [Magento Cloud Guide DevDocs](https://devdocs.magento.com/cloud/bk-cloud.html)
- [Magento Cloud Guide DevDocs](https://experienceleague.adobe.com/docs/commerce-cloud-service/user-guide/overview.html)
- [Cloud Knowledge Base and Support](https://support.magento.com)
- [Cloud Slack Channel](https://magentocommeng.slack.com) (join #cloud and #cloud-docker)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/ece-tools",
"description": "Provides tools to build and deploy Magento 2 Enterprise Edition",
"type": "magento2-component",
"version": "2002.1.16",
"version": "2002.1.17",
"license": "OSL-3.0",
"repositories": {
"repo.magento.com": {
Expand Down
1 change: 1 addition & 0 deletions scenario/build/transfer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<argument name="steps" xsi:type="array">
<item name="static-content" xsi:type="object" priority="100">Magento\MagentoCloud\Step\Build\BackupData\StaticContent</item>
<item name="writable-dirs" xsi:type="object" priority="200">Magento\MagentoCloud\Step\Build\BackupData\WritableDirectories</item>
<item name="clear-mounted-dirs" xsi:type="object" priority="300">Magento\MagentoCloud\Step\Build\ClearMountedDirectories</item>
</argument>
</arguments>
</step>
Expand Down
16 changes: 14 additions & 2 deletions src/Config/Validator/Deploy/ElasticSearchIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\MagentoCloud\Config\Validator\Deploy;

use Magento\MagentoCloud\App\Error;
use Magento\MagentoCloud\Config\Magento\Shared\Reader;
use Magento\MagentoCloud\Config\Validator;
use Magento\MagentoCloud\Config\ValidatorException;
use Magento\MagentoCloud\Config\ValidatorInterface;
Expand Down Expand Up @@ -42,22 +43,30 @@ class ElasticSearchIntegrity implements ValidatorInterface
*/
private $openSearch;

/**
* @var Reader
*/
private $reader;

/**
* @param MagentoVersion $magentoVersion
* @param Validator\ResultFactory $resultFactory
* @param ElasticSearch $elasticSearch
* @param OpenSearch $openSearch
* @param Reader $reader
*/
public function __construct(
MagentoVersion $magentoVersion,
Validator\ResultFactory $resultFactory,
ElasticSearch $elasticSearch,
OpenSearch $openSearch
OpenSearch $openSearch,
Reader $reader
) {
$this->magentoVersion = $magentoVersion;
$this->resultFactory = $resultFactory;
$this->elasticsearch = $elasticSearch;
$this->openSearch = $openSearch;
$this->reader = $reader;
}

/**
Expand All @@ -70,8 +79,11 @@ public function validate(): Validator\ResultInterface
return $this->resultFactory->success();
}

$modules = $this->reader->read()['modules'] ?? [];
$liveSearchEnabled = $modules['Magento_LiveSearchAdapter'] ?? false;

if ($this->magentoVersion->isGreaterOrEqual('2.4.0')
&& !$this->elasticsearch->isInstalled()
&& !$this->elasticsearch->isInstalled() && !$liveSearchEnabled
) {
return $this->resultFactory->errorByCode(Error::DEPLOY_ES_SERVICE_NOT_INSTALLED);
}
Expand Down
16 changes: 14 additions & 2 deletions src/Config/Validator/Deploy/OpenSearchIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\MagentoCloud\Config\Validator\Deploy;

use Magento\MagentoCloud\App\Error;
use Magento\MagentoCloud\Config\Magento\Shared\Reader;
use Magento\MagentoCloud\App\GenericException;
use Magento\MagentoCloud\Config\Validator;
use Magento\MagentoCloud\Config\ValidatorException;
Expand Down Expand Up @@ -43,22 +44,30 @@ class OpenSearchIntegrity implements ValidatorInterface
*/
private $openSearch;

/**
* @var Reader
*/
private $reader;

/**
* @param MagentoVersion $magentoVersion
* @param Validator\ResultFactory $resultFactory
* @param ElasticSearch $elasticSearch
* @param OpenSearch $openSearch
* @param Reader $reader
*/
public function __construct(
MagentoVersion $magentoVersion,
Validator\ResultFactory $resultFactory,
ElasticSearch $elasticSearch,
OpenSearch $openSearch
OpenSearch $openSearch,
Reader $reader
) {
$this->magentoVersion = $magentoVersion;
$this->resultFactory = $resultFactory;
$this->elasticsearch = $elasticSearch;
$this->openSearch = $openSearch;
$this->reader = $reader;
}

/**
Expand All @@ -77,8 +86,11 @@ public function validate(): Validator\ResultInterface
return $this->resultFactory->errorByCode(Error::DEPLOY_MAGENTO_VERSION_DOES_NOT_SUPPORT_OS);
}

$modules = $this->reader->read()['modules'] ?? [];
$liveSearchEnabled = $modules['Magento_LiveSearchAdapter'] ?? false;

if ($this->magentoVersion->isGreaterOrEqual('2.4.3-p2')
&& !$this->openSearch->isInstalled()
&& !$this->openSearch->isInstalled() && !$liveSearchEnabled
) {
return $this->resultFactory->errorByCode(Error::DEPLOY_OS_SERVICE_NOT_INSTALLED);
}
Expand Down
20 changes: 20 additions & 0 deletions src/Filesystem/DirectoryList.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ public function getWritableDirectories(): array
}, $writableDirs);
}

/**
* Retrieves mount points for writable directories.
*
* @return array
* @throws UndefinedPackageException
*/
public function getMountPoints(): array
{
$mountPoints = [
static::DIR_ETC,
static::DIR_VAR,
static::DIR_MEDIA,
static::DIR_STATIC
];

return array_map(function ($path) {
return $this->getPath($path, true);
}, $mountPoints);
}

/**
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Validator
'>=2.4.4' => '~7.10.0', // Greater than 7.10 isn't supported on cloud infrastructure.
],
ServiceInterface::NAME_OPENSEARCH => [
'>=2.3.7-p3 <2.4.0 || >=2.4.3-p2 <2.4.6' => '~1.1.0 || ~1.2.1',
'>=2.3.7-p3 <2.4.0 || >=2.4.3-p2 <2.4.6' => '~1.1.0 || 1.2.*',
'>=2.4.6' => '^2',
],
ServiceInterface::NAME_RABBITMQ => [
Expand Down
66 changes: 66 additions & 0 deletions src/Step/Build/ClearMountedDirectories.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/************************************************************************
* Copyright 2023 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
* ************************************************************************
*/
declare(strict_types=1);

namespace Magento\MagentoCloud\Step\Build;

use Magento\MagentoCloud\Filesystem\Driver\File;
use Magento\MagentoCloud\Filesystem\DirectoryList;
use Magento\MagentoCloud\Step\StepInterface;
use Psr\Log\LoggerInterface;

/**
* Clear the mounted directories on the local filesystem before mounting the remote filesystem.
*
* This prevents warning messages that the mounted directories are not empty.
*
* {@inheritdoc}
*/
class ClearMountedDirectories implements StepInterface
{
/** @var LoggerInterface */
private $logger;

/** @var File */
private $file;

/** @var DirectoryList */
private $directoryList;

public function __construct(
LoggerInterface $logger,
File $file,
DirectoryList $directoryList
) {
$this->logger = $logger;
$this->file = $file;
$this->directoryList = $directoryList;
}

/**
* {@inheritDoc}
*/
public function execute()
{
foreach ($this->directoryList->getMountPoints() as $mount) {
if ($this->file->isExists($mount) === false) {
continue;
}
$this->logger->info(sprintf('Clearing the %s path of all files and folders', $mount));
$this->file->clearDirectory($mount);
}
}
}
4 changes: 4 additions & 0 deletions src/Test/Functional/Acceptance/BackupDb24Cest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ private function partRunDbDumpWithoutSplitDbArch(CliTester $I)

// Running database dump command with invalid database label
$I->runDockerComposeCommand('run build cloud-build');

// Restore app/etc after build phase
$I->runDockerComposeCommand('run build bash -c "cp -r /app/init/app/etc /app/app"');

$I->runDockerComposeCommand('run deploy ece-command db-dump incorrectName');
$I->seeInOutput(
'CRITICAL: Incorrect the database names: [ incorrectName ].'
Expand Down
4 changes: 4 additions & 0 deletions src/Test/Functional/Acceptance/BackupDbCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ private function partRunDbDumpWithoutSplitDbArch(CliTester $I)

// Running database dump command with invalid database label
$I->runDockerComposeCommand('run build cloud-build');

// Restore app/etc after build phase
$I->runDockerComposeCommand('run build bash -c "cp -r /app/init/app/etc /app/app"');

$I->runDockerComposeCommand('run deploy ece-command db-dump incorrectName');
$I->seeInOutput(
'CRITICAL: Incorrect the database names: [ incorrectName ].'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testScenarioExtensibilityAndPriority(\CliTester $I): void
$I->runDockerComposeCommand('run build cloud-build');
$I->startEnvironment();

$cloudLog = $I->grabFileContent('/var/log/cloud.log', Docker::BUILD_CONTAINER);
$cloudLog = $I->grabFileContent('/init/var/log/cloud.log', Docker::BUILD_CONTAINER);

$I->assertStringContainsString(
'Step "copy-sample-data" was skipped',
Expand Down
3 changes: 3 additions & 0 deletions src/Test/Functional/Acceptance/SplitDbCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public function testSplitDb(CliTester $I, Example $data)
$I->writeServicesYaml($services);
$I->writeAppMagentoYaml($magentoApp);

// Restore app/etc after build phase
$I->runDockerComposeCommand('run build bash -c "cp -r /app/init/app/etc /app/app"');

// Deploy 'Split Db' in an environment with prepared architecture. Case with upgrade
$I->generateDockerCompose('--mode=production');
foreach ($this->variationsDataPartWithSplitDbArch() as $variationData) {
Expand Down
2 changes: 2 additions & 0 deletions src/Test/Functional/Acceptance/SplitDbWizardCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function testSplitDbWizard(CliTester $I, Example $data)
$appMagento['relationships']['database-sales'] = 'mysql-sales:mysql';
$I->writeServicesYaml($services);
$I->writeAppMagentoYaml($appMagento);
// Restore app/etc after build phase
$I->runDockerComposeCommand('run build bash -c "cp -r /app/init/app/etc /app/app"');
$I->generateDockerCompose('--mode=production');

foreach ($this->variationsData() as $variationData) {
Expand Down
9 changes: 6 additions & 3 deletions src/Test/Functional/Acceptance/WizardScdCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function _before(\CliTester $I): void
public function testDefault(\CliTester $I): void
{
$I->runDockerComposeCommand('run build cloud-build');
$I->assertFalse($I->runDockerComposeCommand('run build ece-command wizard:scd-on-build'));
$I->runDockerComposeCommand('run deploy cloud-deploy');
$I->assertFalse($I->runDockerComposeCommand('run deploy ece-command wizard:scd-on-build'));
$I->seeInOutput(' - No stores/website/locales found in');
$I->seeInOutput('SCD on build is disabled');
}
Expand All @@ -50,7 +51,8 @@ public function testScdInBuildIsEnabled(\CliTester $I): void
{
$I->copyFileToWorkDir('files/scdinbuild/config.php', 'app/etc/config.php');
$I->runDockerComposeCommand('run build cloud-build');
$I->assertTrue($I->runDockerComposeCommand('run build ece-command wizard:scd-on-build'));
$I->runDockerComposeCommand('run deploy cloud-deploy');
$I->assertTrue($I->runDockerComposeCommand('run deploy ece-command wizard:scd-on-build'));
$I->seeInOutput('SCD on build is enabled');
}

Expand All @@ -62,7 +64,8 @@ public function testScdOnDemandIsEnabled(\CliTester $I): void
{
$I->copyFileToWorkDir('files/scdondemand/.magento.env.yaml', '.magento.env.yaml');
$I->runDockerComposeCommand('run build cloud-build');
$I->assertTrue($I->runDockerComposeCommand('run build ece-command wizard:scd-on-demand'));
$I->runDockerComposeCommand('run deploy cloud-deploy');
$I->assertTrue($I->runDockerComposeCommand('run deploy ece-command wizard:scd-on-demand'));
$I->seeInOutput('SCD on demand is enabled');
}
}
Loading

0 comments on commit d730998

Please sign in to comment.