diff --git a/.github/.metadata.json b/.github/.metadata.json
index 6da808bc7..ef79f7a4d 100644
--- a/.github/.metadata.json
+++ b/.github/.metadata.json
@@ -1,14 +1,14 @@
{
- "templateVersion": "0.1",
+ "templateVersion": "0.2",
"product": {
"name": "Magento Commerce Cloud Deployment Tools",
"description": "ECE-Tools is a set of scripts and tools designed to manage and deploy Cloud projects"
},
"contacts": {
"team": {
- "name": "Magic Mountain",
- "DL": "Grp-magento-cloud-all",
- "slackChannel": "magic_mountain"
+ "name": "Mystic Mountain",
+ "DL": "Grp-Mystic-Mountain",
+ "slackChannel": "#mystic-mountain-team"
}
},
"ticketTracker": {
@@ -17,10 +17,8 @@
},
"securityJiraQueue": {
"projectKey": "MAGREQ",
- "component": "Magento Cloud Engineering"
+ "component": "MAGREQ/Magento Cloud Engineering"
}
},
- "staticScan": {
- "enable": false
- }
+ "productionCodeBranches": ["2002.0", "2002.1"]
}
diff --git a/composer.json b/composer.json
index 3d6248c0c..acadd8065 100755
--- a/composer.json
+++ b/composer.json
@@ -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.15",
+ "version": "2002.1.16",
"license": "OSL-3.0",
"repositories": {
"repo.magento.com": {
diff --git a/config/schema.error.yaml b/config/schema.error.yaml
index 2e57576a2..2f54cf7d1 100644
--- a/config/schema.error.yaml
+++ b/config/schema.error.yaml
@@ -440,6 +440,16 @@
suggestion: 'Check the `cloud.log` for more information.'
stage: general
type: critical
+!php/const Magento\MagentoCloud\App\Error::GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED:
+ title: 'Failed to generate the AdobeCommerceWebhookPlugins module'
+ suggestion: 'Check the `cloud.log` for more information.'
+ stage: general
+ type: critical
+!php/const Magento\MagentoCloud\App\Error::GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED:
+ title: 'Failed to enable the AdobeCommerceWebhookPlugins module'
+ suggestion: 'Check the `cloud.log` for more information.'
+ stage: general
+ type: critical
# Warning errors
!php/const Magento\MagentoCloud\App\Error::WARN_CONFIG_PHP_NOT_EXISTS:
title: 'File app/etc/config.php does not exist'
diff --git a/config/schema.yaml b/config/schema.yaml
index 5317b4d4f..c9ac513cd 100644
--- a/config/schema.yaml
+++ b/config/schema.yaml
@@ -717,6 +717,17 @@ variables:
- stage:
global:
ENABLE_EVENTING: true
+ ENABLE_WEBHOOKS:
+ description: Enables Commerce webhooks.
+ type: boolean
+ stages:
+ - global
+ default:
+ global: false
+ examples:
+ - stage:
+ global:
+ ENABLE_WEBHOOKS: true
# Environment variables
ENV_RELATIONSHIPS:
diff --git a/dist/error-codes.md b/dist/error-codes.md
index 17355c388..1f41b718f 100644
--- a/dist/error-codes.md
+++ b/dist/error-codes.md
@@ -102,6 +102,8 @@ Critical errors indicate a problem with the Commerce on cloud infrastructure pro
| 246 | | Unable to read the `.schema.yaml` file | |
| 247 | | Unable to generate a module for eventing | Check the `cloud.log` for more information. |
| 248 | | Unable to enable a module for eventing | Check the `cloud.log` for more information. |
+| 249 | | Failed to generate the AdobeCommerceWebhookPlugins module | Check the `cloud.log` for more information. |
+| 250 | | Failed to enable the AdobeCommerceWebhookPlugins module | Check the `cloud.log` for more information. |
## Warning Errors
diff --git a/scenario/build/generate.xml b/scenario/build/generate.xml
index 008161aa0..4e3ccbff1 100644
--- a/scenario/build/generate.xml
+++ b/scenario/build/generate.xml
@@ -30,6 +30,7 @@
+
diff --git a/src/App/Error.php b/src/App/Error.php
index 11d6cd830..7835f3679 100644
--- a/src/App/Error.php
+++ b/src/App/Error.php
@@ -96,6 +96,8 @@ class Error
public const GLOBAL_CONFIG_UNABLE_TO_READ_SCHEMA_YAML = 246;
public const GLOBAL_EVENTING_MODULE_GENERATE_FAILED = 247;
public const GLOBAL_EVENTING_MODULE_ENABLEMENT_FAILED = 248;
+ public const GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED = 249;
+ public const GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED = 250;
/**
* Build
diff --git a/src/Config/StageConfigInterface.php b/src/Config/StageConfigInterface.php
index 36d1ca4e8..5df54d544 100644
--- a/src/Config/StageConfigInterface.php
+++ b/src/Config/StageConfigInterface.php
@@ -43,6 +43,7 @@ interface StageConfigInterface
public const VAR_SCD_NO_PARENT = 'SCD_NO_PARENT';
public const VAR_X_FRAME_CONFIGURATION = 'X_FRAME_CONFIGURATION';
public const VAR_ENABLE_EVENTING = 'ENABLE_EVENTING';
+ public const VAR_ENABLE_WEBHOOKS = 'ENABLE_WEBHOOKS';
/**
* Settings for deployment from git.
diff --git a/src/Step/Build/EnableEventing.php b/src/Step/Build/EnableEventing.php
index 2dcc2f2a4..bac7e0fc4 100644
--- a/src/Step/Build/EnableEventing.php
+++ b/src/Step/Build/EnableEventing.php
@@ -75,7 +75,7 @@ public function execute()
} catch (ShellException $e) {
$this->logger->error(
'Failed to generate the Magento_AdobeCommerceEvents module. ' .
- 'Refer to the eventing documentation to determine if all required modules are have been installed. ' .
+ 'Refer to the eventing documentation to determine if all required modules have been installed. ' .
'Error: ' . $e->getMessage()
);
throw new StepException($e->getMessage(), Error::GLOBAL_EVENTING_MODULE_GENERATE_FAILED, $e);
diff --git a/src/Step/Build/EnableWebhooks.php b/src/Step/Build/EnableWebhooks.php
new file mode 100644
index 000000000..4db26943f
--- /dev/null
+++ b/src/Step/Build/EnableWebhooks.php
@@ -0,0 +1,94 @@
+logger = $logger;
+ $this->magentoShell = $shellFactory->createMagento();
+ $this->globalConfig = $globalConfig;
+ }
+
+ /**
+ * Generates and enables a module for Commerce webhooks
+ * if @see StageConfigInterface::VAR_ENABLE_WEBHOOKS set to true
+ *
+ * {@inheritDoc}
+ */
+ public function execute()
+ {
+ try {
+ if (!$this->globalConfig->get(StageConfigInterface::VAR_ENABLE_WEBHOOKS)) {
+ return;
+ }
+ } catch (ConfigException $e) {
+ throw new StepException($e->getMessage(), $e->getCode(), $e);
+ }
+
+ try {
+ $this->logger->notice('Generating module for Commerce webhooks');
+ $this->magentoShell->execute('webhooks:generate:module');
+ } catch (ShellException $e) {
+ $this->logger->error(
+ 'Failed to generate the AdobeCommerceWebhookPlugins module. ' .
+ 'Refer to the Commerce webhooks documentation to determine if all ' .
+ 'required modules have been installed. ' .
+ 'Error: ' . $e->getMessage()
+ );
+ throw new StepException($e->getMessage(), Error::GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED, $e);
+ }
+
+ try {
+ $this->logger->notice('Enabling module for Commerce webhooks');
+ $this->magentoShell->execute('module:enable Magento_AdobeCommerceWebhookPlugins');
+ } catch (ShellException $e) {
+ $this->logger->error('Failed to enable module for Commerce webhooks: ' . $e->getMessage());
+ throw new StepException($e->getMessage(), Error::GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED, $e);
+ }
+ }
+}
diff --git a/src/Test/Unit/Config/SchemaTest.php b/src/Test/Unit/Config/SchemaTest.php
index e8ff40030..90e0643c2 100644
--- a/src/Test/Unit/Config/SchemaTest.php
+++ b/src/Test/Unit/Config/SchemaTest.php
@@ -175,6 +175,7 @@ public function testGetDefaultsForGlobalSection(): void
StageConfigInterface::VAR_MIN_LOGGING_LEVEL => '',
StageConfigInterface::VAR_X_FRAME_CONFIGURATION => 'SAMEORIGIN',
StageConfigInterface::VAR_ENABLE_EVENTING => false,
+ StageConfigInterface::VAR_ENABLE_WEBHOOKS => false,
],
$this->schema->getDefaults(StageConfigInterface::STAGE_GLOBAL)
);
diff --git a/src/Test/Unit/Step/Build/EnableWebhooksTest.php b/src/Test/Unit/Step/Build/EnableWebhooksTest.php
new file mode 100644
index 000000000..eb2bcbd46
--- /dev/null
+++ b/src/Test/Unit/Step/Build/EnableWebhooksTest.php
@@ -0,0 +1,165 @@
+loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
+ $this->magentoShellMock = $this->createMock(MagentoShell::class);
+ /** @var ShellFactory|MockObject $shellFactoryMock */
+ $shellFactoryMock = $this->createMock(ShellFactory::class);
+ $shellFactoryMock->expects($this->once())
+ ->method('createMagento')
+ ->willReturn($this->magentoShellMock);
+ $this->globalConfigMock = $this->createMock(GlobalSection::class);
+
+ $this->step = new EnableWebhooks(
+ $this->loggerMock,
+ $shellFactoryMock,
+ $this->globalConfigMock
+ );
+ }
+
+ /**
+ * @return void
+ * @throws StepException
+ */
+ public function testExecuteWebhooksNotEnabled()
+ {
+ $this->globalConfigMock->expects(self::once())
+ ->method('get')
+ ->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
+ ->willReturn(false);
+
+ $this->magentoShellMock->expects(self::never())
+ ->method('execute');
+ $this->loggerMock->expects(self::never())
+ ->method('notice');
+
+ $this->step->execute();
+ }
+
+ /**
+ * @return void
+ * @throws StepException
+ */
+ public function testExecuteGenerateCommandFailed()
+ {
+ $this->expectException(StepException::class);
+ $this->expectExceptionMessage('error during module generation');
+ $this->expectExceptionCode(Error::GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED);
+
+ $this->globalConfigMock->expects(self::once())
+ ->method('get')
+ ->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
+ ->willReturn(true);
+ $this->magentoShellMock->expects(self::once())
+ ->method('execute')
+ ->with('webhooks:generate:module')
+ ->willThrowException(new ShellException('error during module generation'));
+ $this->loggerMock->expects(self::once())
+ ->method('notice');
+ $this->loggerMock->expects(self::once())
+ ->method('error');
+
+ $this->step->execute();
+ }
+
+ /**
+ * @return void
+ * @throws StepException
+ */
+ public function testExecuteEnableModuleCommandFailed()
+ {
+ $this->expectException(StepException::class);
+ $this->expectExceptionMessage('error during module enablement');
+ $this->expectExceptionCode(Error::GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED);
+
+ $this->globalConfigMock->expects(self::once())
+ ->method('get')
+ ->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
+ ->willReturn(true);
+ $this->magentoShellMock->expects(self::at(0))
+ ->method('execute')
+ ->with('webhooks:generate:module');
+ $this->magentoShellMock->expects(self::at(1))
+ ->method('execute')
+ ->with('module:enable Magento_AdobeCommerceWebhookPlugins')
+ ->willThrowException(new ShellException('error during module enablement'));
+ $this->loggerMock->expects(self::exactly(2))
+ ->method('notice');
+ $this->loggerMock->expects(self::once())
+ ->method('error');
+
+ $this->step->execute();
+ }
+
+ /**
+ * @return void
+ * @throws StepException
+ */
+ public function testExecuteSuccess()
+ {
+ $this->globalConfigMock->expects(self::once())
+ ->method('get')
+ ->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
+ ->willReturn(true);
+ $this->magentoShellMock->expects(self::at(0))
+ ->method('execute')
+ ->with('webhooks:generate:module');
+ $this->magentoShellMock->expects(self::at(1))
+ ->method('execute')
+ ->with('module:enable Magento_AdobeCommerceWebhookPlugins');
+ $this->loggerMock->expects(self::exactly(2))
+ ->method('notice');
+ $this->loggerMock->expects(self::never())
+ ->method('error');
+
+ $this->step->execute();
+ }
+}