Skip to content

Commit c6a2c38

Browse files
authored
Merge pull request #124 from magento-commerce/develop
MCLOUD-11293: Release ECE-Tools 2002.1.16
2 parents def1e5a + 4264e7b commit c6a2c38

12 files changed

+295
-10
lines changed

.github/.metadata.json

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"templateVersion": "0.1",
2+
"templateVersion": "0.2",
33
"product": {
44
"name": "Magento Commerce Cloud Deployment Tools",
55
"description": "ECE-Tools is a set of scripts and tools designed to manage and deploy Cloud projects"
66
},
77
"contacts": {
88
"team": {
9-
"name": "Magic Mountain",
10-
"DL": "Grp-magento-cloud-all",
11-
"slackChannel": "magic_mountain"
9+
"name": "Mystic Mountain",
10+
"DL": "Grp-Mystic-Mountain",
11+
"slackChannel": "#mystic-mountain-team"
1212
}
1313
},
1414
"ticketTracker": {
@@ -17,10 +17,8 @@
1717
},
1818
"securityJiraQueue": {
1919
"projectKey": "MAGREQ",
20-
"component": "Magento Cloud Engineering"
20+
"component": "MAGREQ/Magento Cloud Engineering"
2121
}
2222
},
23-
"staticScan": {
24-
"enable": false
25-
}
23+
"productionCodeBranches": ["2002.0", "2002.1"]
2624
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/ece-tools",
33
"description": "Provides tools to build and deploy Magento 2 Enterprise Edition",
44
"type": "magento2-component",
5-
"version": "2002.1.15",
5+
"version": "2002.1.16",
66
"license": "OSL-3.0",
77
"repositories": {
88
"repo.magento.com": {

config/schema.error.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,16 @@
440440
suggestion: 'Check the `cloud.log` for more information.'
441441
stage: general
442442
type: critical
443+
!php/const Magento\MagentoCloud\App\Error::GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED:
444+
title: 'Failed to generate the AdobeCommerceWebhookPlugins module'
445+
suggestion: 'Check the `cloud.log` for more information.'
446+
stage: general
447+
type: critical
448+
!php/const Magento\MagentoCloud\App\Error::GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED:
449+
title: 'Failed to enable the AdobeCommerceWebhookPlugins module'
450+
suggestion: 'Check the `cloud.log` for more information.'
451+
stage: general
452+
type: critical
443453
# Warning errors
444454
!php/const Magento\MagentoCloud\App\Error::WARN_CONFIG_PHP_NOT_EXISTS:
445455
title: 'File app/etc/config.php does not exist'

config/schema.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,17 @@ variables:
717717
- stage:
718718
global:
719719
ENABLE_EVENTING: true
720+
ENABLE_WEBHOOKS:
721+
description: Enables Commerce webhooks.
722+
type: boolean
723+
stages:
724+
- global
725+
default:
726+
global: false
727+
examples:
728+
- stage:
729+
global:
730+
ENABLE_WEBHOOKS: true
720731

721732
# Environment variables
722733
ENV_RELATIONSHIPS:

dist/error-codes.md

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ Critical errors indicate a problem with the Commerce on cloud infrastructure pro
102102
| 246 | | Unable to read the `.schema.yaml` file | |
103103
| 247 | | Unable to generate a module for eventing | Check the `cloud.log` for more information. |
104104
| 248 | | Unable to enable a module for eventing | Check the `cloud.log` for more information. |
105+
| 249 | | Failed to generate the AdobeCommerceWebhookPlugins module | Check the `cloud.log` for more information. |
106+
| 250 | | Failed to enable the AdobeCommerceWebhookPlugins module | Check the `cloud.log` for more information. |
105107

106108
## Warning Errors
107109

scenario/build/generate.xml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<step name="marshall-files" type="Magento\MagentoCloud\Step\Build\MarshallFiles" priority="800"/>
3131
<step name="copy-sample-data" type="Magento\MagentoCloud\Step\Build\CopySampleData" priority="900"/>
3232
<step name="enable-eventing" type="Magento\MagentoCloud\Step\Build\EnableEventing" priority="950" />
33+
<step name="enable-webhooks" type="Magento\MagentoCloud\Step\Build\EnableWebhooks" priority="975" />
3334
<step name="compile-di" type="Magento\MagentoCloud\Step\Build\CompileDi" priority="1000"/>
3435
<step name="dump-autoload" type="Magento\MagentoCloud\Step\Build\ComposerDumpAutoload" priority="1100"/>
3536
<step name="deploy-static-content" type="Magento\MagentoCloud\Step\Build\DeployStaticContent" priority="1200">

src/App/Error.php

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class Error
9696
public const GLOBAL_CONFIG_UNABLE_TO_READ_SCHEMA_YAML = 246;
9797
public const GLOBAL_EVENTING_MODULE_GENERATE_FAILED = 247;
9898
public const GLOBAL_EVENTING_MODULE_ENABLEMENT_FAILED = 248;
99+
public const GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED = 249;
100+
public const GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED = 250;
99101

100102
/**
101103
* Build

src/Config/StageConfigInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ interface StageConfigInterface
4343
public const VAR_SCD_NO_PARENT = 'SCD_NO_PARENT';
4444
public const VAR_X_FRAME_CONFIGURATION = 'X_FRAME_CONFIGURATION';
4545
public const VAR_ENABLE_EVENTING = 'ENABLE_EVENTING';
46+
public const VAR_ENABLE_WEBHOOKS = 'ENABLE_WEBHOOKS';
4647

4748
/**
4849
* Settings for deployment from git.

src/Step/Build/EnableEventing.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function execute()
7575
} catch (ShellException $e) {
7676
$this->logger->error(
7777
'Failed to generate the Magento_AdobeCommerceEvents module. ' .
78-
'Refer to the eventing documentation to determine if all required modules are have been installed. ' .
78+
'Refer to the eventing documentation to determine if all required modules have been installed. ' .
7979
'Error: ' . $e->getMessage()
8080
);
8181
throw new StepException($e->getMessage(), Error::GLOBAL_EVENTING_MODULE_GENERATE_FAILED, $e);

src/Step/Build/EnableWebhooks.php

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\MagentoCloud\Step\Build;
9+
10+
use Magento\MagentoCloud\App\Error;
11+
use Magento\MagentoCloud\Config\ConfigException;
12+
use Magento\MagentoCloud\Config\GlobalSection;
13+
use Magento\MagentoCloud\Config\StageConfigInterface;
14+
use Magento\MagentoCloud\Shell\MagentoShell;
15+
use Magento\MagentoCloud\Shell\ShellException;
16+
use Magento\MagentoCloud\Shell\ShellFactory;
17+
use Magento\MagentoCloud\Step\StepException;
18+
use Magento\MagentoCloud\Step\StepInterface;
19+
use Psr\Log\LoggerInterface;
20+
21+
/**
22+
* Runs a command to generate a module for webhooks and enables this module in case when
23+
* it is enabled in configuration
24+
*/
25+
class EnableWebhooks implements StepInterface
26+
{
27+
/**
28+
* @var LoggerInterface
29+
*/
30+
private $logger;
31+
32+
/**
33+
* @var MagentoShell
34+
*/
35+
private $magentoShell;
36+
37+
/**
38+
* @var GlobalSection
39+
*/
40+
private $globalConfig;
41+
42+
/**
43+
* @param LoggerInterface $logger
44+
* @param ShellFactory $shellFactory
45+
* @param GlobalSection $globalConfig
46+
*/
47+
public function __construct(
48+
LoggerInterface $logger,
49+
ShellFactory $shellFactory,
50+
GlobalSection $globalConfig
51+
) {
52+
$this->logger = $logger;
53+
$this->magentoShell = $shellFactory->createMagento();
54+
$this->globalConfig = $globalConfig;
55+
}
56+
57+
/**
58+
* Generates and enables a module for Commerce webhooks
59+
* if @see StageConfigInterface::VAR_ENABLE_WEBHOOKS set to true
60+
*
61+
* {@inheritDoc}
62+
*/
63+
public function execute()
64+
{
65+
try {
66+
if (!$this->globalConfig->get(StageConfigInterface::VAR_ENABLE_WEBHOOKS)) {
67+
return;
68+
}
69+
} catch (ConfigException $e) {
70+
throw new StepException($e->getMessage(), $e->getCode(), $e);
71+
}
72+
73+
try {
74+
$this->logger->notice('Generating module for Commerce webhooks');
75+
$this->magentoShell->execute('webhooks:generate:module');
76+
} catch (ShellException $e) {
77+
$this->logger->error(
78+
'Failed to generate the AdobeCommerceWebhookPlugins module. ' .
79+
'Refer to the Commerce webhooks documentation to determine if all ' .
80+
'required modules have been installed. ' .
81+
'Error: ' . $e->getMessage()
82+
);
83+
throw new StepException($e->getMessage(), Error::GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED, $e);
84+
}
85+
86+
try {
87+
$this->logger->notice('Enabling module for Commerce webhooks');
88+
$this->magentoShell->execute('module:enable Magento_AdobeCommerceWebhookPlugins');
89+
} catch (ShellException $e) {
90+
$this->logger->error('Failed to enable module for Commerce webhooks: ' . $e->getMessage());
91+
throw new StepException($e->getMessage(), Error::GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED, $e);
92+
}
93+
}
94+
}

src/Test/Unit/Config/SchemaTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public function testGetDefaultsForGlobalSection(): void
175175
StageConfigInterface::VAR_MIN_LOGGING_LEVEL => '',
176176
StageConfigInterface::VAR_X_FRAME_CONFIGURATION => 'SAMEORIGIN',
177177
StageConfigInterface::VAR_ENABLE_EVENTING => false,
178+
StageConfigInterface::VAR_ENABLE_WEBHOOKS => false,
178179
],
179180
$this->schema->getDefaults(StageConfigInterface::STAGE_GLOBAL)
180181
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\MagentoCloud\Test\Unit\Step\Build;
9+
10+
use Magento\MagentoCloud\App\Error;
11+
use Magento\MagentoCloud\Config\GlobalSection;
12+
use Magento\MagentoCloud\Config\StageConfigInterface;
13+
use Magento\MagentoCloud\Shell\MagentoShell;
14+
use Magento\MagentoCloud\Shell\ShellException;
15+
use Magento\MagentoCloud\Shell\ShellFactory;
16+
use Magento\MagentoCloud\Step\Build\EnableWebhooks;
17+
use Magento\MagentoCloud\Step\StepException;
18+
use PHPUnit\Framework\MockObject\MockObject;
19+
use PHPUnit\Framework\TestCase;
20+
use Psr\Log\LoggerInterface;
21+
22+
/**
23+
* @inheritDoc
24+
*/
25+
class EnableWebhooksTest extends TestCase
26+
{
27+
/**
28+
* @var EnableWebhooks
29+
*/
30+
private $step;
31+
32+
/**
33+
* @var LoggerInterface|MockObject
34+
*/
35+
private $loggerMock;
36+
37+
/**
38+
* @var MagentoShell|MockObject
39+
*/
40+
private $magentoShellMock;
41+
42+
/**
43+
* @var GlobalSection|MockObject
44+
*/
45+
private $globalConfigMock;
46+
47+
/**
48+
* @inheritdoc
49+
*/
50+
protected function setUp(): void
51+
{
52+
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
53+
$this->magentoShellMock = $this->createMock(MagentoShell::class);
54+
/** @var ShellFactory|MockObject $shellFactoryMock */
55+
$shellFactoryMock = $this->createMock(ShellFactory::class);
56+
$shellFactoryMock->expects($this->once())
57+
->method('createMagento')
58+
->willReturn($this->magentoShellMock);
59+
$this->globalConfigMock = $this->createMock(GlobalSection::class);
60+
61+
$this->step = new EnableWebhooks(
62+
$this->loggerMock,
63+
$shellFactoryMock,
64+
$this->globalConfigMock
65+
);
66+
}
67+
68+
/**
69+
* @return void
70+
* @throws StepException
71+
*/
72+
public function testExecuteWebhooksNotEnabled()
73+
{
74+
$this->globalConfigMock->expects(self::once())
75+
->method('get')
76+
->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
77+
->willReturn(false);
78+
79+
$this->magentoShellMock->expects(self::never())
80+
->method('execute');
81+
$this->loggerMock->expects(self::never())
82+
->method('notice');
83+
84+
$this->step->execute();
85+
}
86+
87+
/**
88+
* @return void
89+
* @throws StepException
90+
*/
91+
public function testExecuteGenerateCommandFailed()
92+
{
93+
$this->expectException(StepException::class);
94+
$this->expectExceptionMessage('error during module generation');
95+
$this->expectExceptionCode(Error::GLOBAL_WEBHOOKS_MODULE_GENERATE_FAILED);
96+
97+
$this->globalConfigMock->expects(self::once())
98+
->method('get')
99+
->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
100+
->willReturn(true);
101+
$this->magentoShellMock->expects(self::once())
102+
->method('execute')
103+
->with('webhooks:generate:module')
104+
->willThrowException(new ShellException('error during module generation'));
105+
$this->loggerMock->expects(self::once())
106+
->method('notice');
107+
$this->loggerMock->expects(self::once())
108+
->method('error');
109+
110+
$this->step->execute();
111+
}
112+
113+
/**
114+
* @return void
115+
* @throws StepException
116+
*/
117+
public function testExecuteEnableModuleCommandFailed()
118+
{
119+
$this->expectException(StepException::class);
120+
$this->expectExceptionMessage('error during module enablement');
121+
$this->expectExceptionCode(Error::GLOBAL_WEBHOOKS_MODULE_ENABLEMENT_FAILED);
122+
123+
$this->globalConfigMock->expects(self::once())
124+
->method('get')
125+
->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
126+
->willReturn(true);
127+
$this->magentoShellMock->expects(self::at(0))
128+
->method('execute')
129+
->with('webhooks:generate:module');
130+
$this->magentoShellMock->expects(self::at(1))
131+
->method('execute')
132+
->with('module:enable Magento_AdobeCommerceWebhookPlugins')
133+
->willThrowException(new ShellException('error during module enablement'));
134+
$this->loggerMock->expects(self::exactly(2))
135+
->method('notice');
136+
$this->loggerMock->expects(self::once())
137+
->method('error');
138+
139+
$this->step->execute();
140+
}
141+
142+
/**
143+
* @return void
144+
* @throws StepException
145+
*/
146+
public function testExecuteSuccess()
147+
{
148+
$this->globalConfigMock->expects(self::once())
149+
->method('get')
150+
->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
151+
->willReturn(true);
152+
$this->magentoShellMock->expects(self::at(0))
153+
->method('execute')
154+
->with('webhooks:generate:module');
155+
$this->magentoShellMock->expects(self::at(1))
156+
->method('execute')
157+
->with('module:enable Magento_AdobeCommerceWebhookPlugins');
158+
$this->loggerMock->expects(self::exactly(2))
159+
->method('notice');
160+
$this->loggerMock->expects(self::never())
161+
->method('error');
162+
163+
$this->step->execute();
164+
}
165+
}

0 commit comments

Comments
 (0)