Skip to content

Commit 2340afb

Browse files
authored
Merge pull request #40 from magento-commerce/develop
Merge develop into 2002.1
2 parents 41949c3 + 89cdaee commit 2340afb

File tree

103 files changed

+1778
-438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1778
-438
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php-versions: ['7.1', '7.2', '7.3']
10+
php-versions: ['7.1', '7.2', '7.3', '7.4']
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v1

.travis.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
dist: bionic
22

3+
cache:
4+
bundler: true
5+
directories:
6+
- $HOME/docker
7+
38
addons:
49
hosts:
510
- magento2.docker
@@ -31,6 +36,9 @@ stages:
3136

3237
jobs:
3338
exclude:
39+
- php: '7.1'
40+
env: TEST_SUITE=functional-ce
41+
3442
- php: '7.1'
3543
env: TEST_SUITE=functional-ee
3644

@@ -46,7 +54,8 @@ jobs:
4654
before_install:
4755
# https://github.com/kylekatarnls/update-helper/issues/9
4856
- if [ -n "${COMPOSER_VERSION}" ]; then travis_retry composer self-update ${COMPOSER_VERSION}; fi;
49-
57+
- if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}; fi;
58+
- if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
5059

5160
install:
5261
- phpenv config-add travis.php.ini
@@ -65,3 +74,6 @@ before_script:
6574
script:
6675
- if [ $TEST_SUITE == "functional-ce" ]; then ./tests/travis/functional_ce.sh; fi;
6776
- if [ $TEST_SUITE == "functional-ee" ] && [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/prepare_functional_parallel.sh && ./tests/travis/functional_ee.sh; fi;
77+
- >
78+
mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
79+
| xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz'

composer.json

+2-2
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.4",
5+
"version": "2002.1.5",
66
"license": "OSL-3.0",
77
"repositories": {
88
"repo.magento.com": {
@@ -41,7 +41,7 @@
4141
"consolidation/robo": "^1.2",
4242
"php-mock/php-mock-phpunit": "^2.0",
4343
"phpmd/phpmd": "@stable",
44-
"phpstan/phpstan": "^0.11",
44+
"phpstan/phpstan": "^0.12",
4545
"phpunit/php-code-coverage": "^6.0",
4646
"phpunit/phpunit": "^7.2",
4747
"squizlabs/php_codesniffer": "^3.0",

config/schema.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ variables:
137137
deploy:
138138
SCD_MATRIX:
139139
magento/backend: []
140+
SCD_NO_PARENT:
141+
description: Adds '--no-parent' option to SCD CLI command. This option does not allow to generate static content
142+
for parent themes what decrease time for generation static content.
143+
type: boolean
144+
magento_version: '>=2.4.2'
145+
stages:
146+
- global
147+
- build
148+
- deploy
149+
default:
150+
build: false
151+
deploy: false
152+
examples:
153+
- stage:
154+
build:
155+
SCD_NO_PARENT: true
140156
SCD_USE_BALER:
141157
description: Run Baler after performing static content deployment in order to generate an optimized JavaScript bundle.
142158
type: boolean

src/App/Logger.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,21 @@ private function prepare(): void
102102
* @param string $deployLogPath deploy log path
103103
* @param string $buildPhaseLogContent build log content
104104
* @return bool
105-
*
106-
* @throws FileSystemException
107105
*/
108106
private function isBuildLogApplied(string $deployLogPath, string $buildPhaseLogContent): bool
109107
{
110-
return false !== strpos($this->file->fileGetContents($deployLogPath), $buildPhaseLogContent);
108+
$buildLogLines = explode(PHP_EOL, $buildPhaseLogContent);
109+
if (!isset($buildLogLines[0])) {
110+
return true;
111+
}
112+
113+
$needle = strtr(addslashes($buildLogLines[0]), [
114+
'[' => '\[',
115+
']' => '\]',
116+
]);
117+
118+
$result = @shell_exec(sprintf('grep "%s" %s', $needle, $deployLogPath));
119+
120+
return !empty($result);
111121
}
112122
}

src/App/Logger/Prepare/ErrorLogFile.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,19 @@ private function isNeedToCopyBuildErrorLogFile(string $deployLogPath, string $bu
8989
return false;
9090
}
9191

92+
$buildPhaseLogContent = $this->file->fileGetContents($buildPhaseLogPath);
93+
if (empty($buildPhaseLogContent)) {
94+
return false;
95+
}
96+
9297
$deployLogFileExists = $this->file->isExists($deployLogPath);
9398
if (!$deployLogFileExists) {
9499
return true;
95100
}
96101

97102
return false === strpos(
98103
$this->file->fileGetContents($deployLogPath),
99-
$this->file->fileGetContents($buildPhaseLogPath)
104+
$buildPhaseLogContent
100105
);
101106
}
102107
}

src/Application.php

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ protected function getDefaultCommands()
7777
$this->container->create(Command\ConfigShow::class),
7878
$this->container->create(Command\ConfigCreate::class),
7979
$this->container->create(Command\ConfigUpdate::class),
80+
$this->container->create(Command\ConfigValidate::class),
8081
$this->container->create(Command\RunCommand::class),
8182
$this->container->create(Command\GenerateSchema::class),
8283
$this->container->create(Command\ErrorShow::class)

src/Cli.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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;
9+
10+
/**
11+
* @api
12+
*
13+
* @codeCoverageIgnore
14+
*/
15+
class Cli
16+
{
17+
public const SUCCESS = 0;
18+
public const FAILURE = 1;
19+
}

src/Command/ApplyPatches.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\MagentoCloud\Command;
99

10+
use Magento\MagentoCloud\Cli;
11+
use Magento\MagentoCloud\Config\ConfigException;
1012
use Magento\MagentoCloud\Patch\Manager;
1113
use Magento\MagentoCloud\Shell\ShellException;
1214
use Symfony\Component\Console\Command\Command;
@@ -49,12 +51,15 @@ protected function configure(): void
4951
}
5052

5153
/**
52-
* {@inheritdoc}
54+
* {@inheritDoc}
5355
*
5456
* @throws ShellException
57+
* @throws ConfigException
5558
*/
56-
public function execute(InputInterface $input, OutputInterface $output)
59+
public function execute(InputInterface $input, OutputInterface $output): int
5760
{
5861
$this->manager->apply();
62+
63+
return Cli::SUCCESS;
5964
}
6065
}

src/Command/BackupList.php

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
namespace Magento\MagentoCloud\Command;
99

10+
use Magento\MagentoCloud\Cli;
1011
use Symfony\Component\Console\Command\Command;
1112
use Symfony\Component\Console\Input\InputInterface;
1213
use Symfony\Component\Console\Output\OutputInterface;
1314
use Magento\MagentoCloud\Command\Backup\FileList as BackupFilesList;
1415
use Psr\Log\LoggerInterface;
16+
use Exception;
1517

1618
/**
1719
* CLI command for showing the list of backup files.
@@ -30,10 +32,7 @@ class BackupList extends Command
3032
*/
3133
private $logger;
3234

33-
/**
34-
* Command name
35-
*/
36-
const NAME = 'backup:list';
35+
public const NAME = 'backup:list';
3736

3837
/**
3938
* @param BackupFilesList $backupFilesList
@@ -52,7 +51,7 @@ public function __construct(
5251
/**
5352
* @inheritdoc
5453
*/
55-
protected function configure()
54+
protected function configure(): void
5655
{
5756
$this->setName(self::NAME)
5857
->setDescription('Shows the list of backup files.');
@@ -61,16 +60,21 @@ protected function configure()
6160
}
6261

6362
/**
64-
* @inheritdoc
63+
* {@inheritDoc}
64+
*
65+
* @throws Exception
6566
*/
66-
protected function execute(InputInterface $input, OutputInterface $output)
67+
protected function execute(InputInterface $input, OutputInterface $output): int
6768
{
6869
try {
6970
$output->writeln('<comment>The list of backup files:</comment>');
7071
$output->writeln($this->backupFilesList->get() ?: 'There are no files in the backup');
71-
} catch (\Exception $exception) {
72+
} catch (Exception $exception) {
7273
$this->logger->critical($exception->getMessage());
74+
7375
throw $exception;
7476
}
77+
78+
return Cli::SUCCESS;
7579
}
7680
}

src/Command/BackupRestore.php

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
namespace Magento\MagentoCloud\Command;
99

10+
use Magento\MagentoCloud\Cli;
1011
use Symfony\Component\Console\Command\Command;
1112
use Magento\MagentoCloud\Command\Backup\Restore;
1213
use Symfony\Component\Console\Input\InputInterface;
1314
use Symfony\Component\Console\Output\OutputInterface;
1415
use Symfony\Component\Console\Input\InputOption;
1516
use Symfony\Component\Console\Question\ConfirmationQuestion;
1617
use Psr\Log\LoggerInterface;
18+
use Exception;
1719

1820
/**
1921
* CLI command for restoring Magento configuration files from backup.
@@ -32,10 +34,7 @@ class BackupRestore extends Command
3234
*/
3335
private $logger;
3436

35-
/**
36-
* Command name
37-
*/
38-
const NAME = 'backup:restore';
37+
public const NAME = 'backup:restore';
3938

4039
/**
4140
* @param Restore $restore
@@ -45,13 +44,14 @@ public function __construct(Restore $restore, LoggerInterface $logger)
4544
{
4645
$this->restore = $restore;
4746
$this->logger = $logger;
47+
4848
parent::__construct();
4949
}
5050

5151
/**
5252
* @inheritdoc
5353
*/
54-
protected function configure()
54+
protected function configure(): void
5555
{
5656
$this->setName(self::NAME)
5757
->setDescription(
@@ -74,9 +74,11 @@ protected function configure()
7474
}
7575

7676
/**
77-
* @inheritdoc
77+
* {@inheritdoc}
78+
*
79+
* @throws Exception
7880
*/
79-
protected function execute(InputInterface $input, OutputInterface $output)
81+
protected function execute(InputInterface $input, OutputInterface $output): int
8082
{
8183
try {
8284
$restore = true;
@@ -93,9 +95,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
9395
if ($restore) {
9496
$this->restore->run($input, $output);
9597
}
96-
} catch (\Exception $exception) {
98+
} catch (Exception $exception) {
9799
$this->logger->critical($exception->getMessage());
100+
98101
throw $exception;
99102
}
103+
104+
return Cli::SUCCESS;
100105
}
101106
}

src/Command/Build.php

+17-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
namespace Magento\MagentoCloud\Command;
99

10+
use Magento\MagentoCloud\Cli;
1011
use Magento\MagentoCloud\Command\Build\Generate;
1112
use Magento\MagentoCloud\Command\Build\Transfer;
1213
use Symfony\Component\Console\Command\Command;
1314
use Symfony\Component\Console\Input\InputInterface;
1415
use Symfony\Component\Console\Output\OutputInterface;
16+
use RuntimeException;
1517

1618
/**
1719
* CLI command for build hook. Responsible for preparing the codebase before it's moved to the server.
@@ -20,12 +22,12 @@
2022
*/
2123
class Build extends Command
2224
{
23-
const NAME = 'build';
25+
public const NAME = 'build';
2426

2527
/**
2628
* @inheritdoc
2729
*/
28-
protected function configure()
30+
protected function configure(): void
2931
{
3032
$this->setName(static::NAME)
3133
->setDescription('Builds application.');
@@ -37,10 +39,20 @@ protected function configure()
3739
* This method is a proxy for calling build:generate and build:transfer commands.
3840
*
3941
* {@inheritdoc}
42+
*
43+
* @throws RuntimeException
4044
*/
41-
public function execute(InputInterface $input, OutputInterface $output)
45+
public function execute(InputInterface $input, OutputInterface $output): int
4246
{
43-
$this->getApplication()->find(Generate::NAME)->execute($input, $output);
44-
$this->getApplication()->find(Transfer::NAME)->execute($input, $output);
47+
$application = $this->getApplication();
48+
49+
if (null === $application) {
50+
throw new RuntimeException('Application is not defined');
51+
}
52+
53+
$application->find(Generate::NAME)->execute($input, $output);
54+
$application->find(Transfer::NAME)->execute($input, $output);
55+
56+
return Cli::SUCCESS;
4557
}
4658
}

0 commit comments

Comments
 (0)