Skip to content

Commit

Permalink
Merge pull request #40 from magento-commerce/develop
Browse files Browse the repository at this point in the history
Merge develop into 2002.1
  • Loading branch information
oshmyheliuk authored Jan 27, 2021
2 parents 41949c3 + 89cdaee commit 2340afb
Show file tree
Hide file tree
Showing 103 changed files with 1,778 additions and 438 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.1', '7.2', '7.3']
php-versions: ['7.1', '7.2', '7.3', '7.4']
steps:
- name: Checkout
uses: actions/checkout@v1
Expand Down
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
dist: bionic

cache:
bundler: true
directories:
- $HOME/docker

addons:
hosts:
- magento2.docker
Expand Down Expand Up @@ -31,6 +36,9 @@ stages:

jobs:
exclude:
- php: '7.1'
env: TEST_SUITE=functional-ce

- php: '7.1'
env: TEST_SUITE=functional-ee

Expand All @@ -46,7 +54,8 @@ jobs:
before_install:
# https://github.com/kylekatarnls/update-helper/issues/9
- if [ -n "${COMPOSER_VERSION}" ]; then travis_retry composer self-update ${COMPOSER_VERSION}; fi;

- if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}; fi;
- if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi

install:
- phpenv config-add travis.php.ini
Expand All @@ -65,3 +74,6 @@ before_script:
script:
- if [ $TEST_SUITE == "functional-ce" ]; then ./tests/travis/functional_ce.sh; fi;
- if [ $TEST_SUITE == "functional-ee" ] && [ $TRAVIS_SECURE_ENV_VARS == "true" ]; then ./tests/travis/prepare_functional_parallel.sh && ./tests/travis/functional_ee.sh; fi;
- >
mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
| xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz'
4 changes: 2 additions & 2 deletions 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.4",
"version": "2002.1.5",
"license": "OSL-3.0",
"repositories": {
"repo.magento.com": {
Expand Down Expand Up @@ -41,7 +41,7 @@
"consolidation/robo": "^1.2",
"php-mock/php-mock-phpunit": "^2.0",
"phpmd/phpmd": "@stable",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan": "^0.12",
"phpunit/php-code-coverage": "^6.0",
"phpunit/phpunit": "^7.2",
"squizlabs/php_codesniffer": "^3.0",
Expand Down
16 changes: 16 additions & 0 deletions config/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ variables:
deploy:
SCD_MATRIX:
magento/backend: []
SCD_NO_PARENT:
description: Adds '--no-parent' option to SCD CLI command. This option does not allow to generate static content
for parent themes what decrease time for generation static content.
type: boolean
magento_version: '>=2.4.2'
stages:
- global
- build
- deploy
default:
build: false
deploy: false
examples:
- stage:
build:
SCD_NO_PARENT: true
SCD_USE_BALER:
description: Run Baler after performing static content deployment in order to generate an optimized JavaScript bundle.
type: boolean
Expand Down
16 changes: 13 additions & 3 deletions src/App/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,21 @@ private function prepare(): void
* @param string $deployLogPath deploy log path
* @param string $buildPhaseLogContent build log content
* @return bool
*
* @throws FileSystemException
*/
private function isBuildLogApplied(string $deployLogPath, string $buildPhaseLogContent): bool
{
return false !== strpos($this->file->fileGetContents($deployLogPath), $buildPhaseLogContent);
$buildLogLines = explode(PHP_EOL, $buildPhaseLogContent);
if (!isset($buildLogLines[0])) {
return true;
}

$needle = strtr(addslashes($buildLogLines[0]), [
'[' => '\[',
']' => '\]',
]);

$result = @shell_exec(sprintf('grep "%s" %s', $needle, $deployLogPath));

return !empty($result);
}
}
7 changes: 6 additions & 1 deletion src/App/Logger/Prepare/ErrorLogFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,19 @@ private function isNeedToCopyBuildErrorLogFile(string $deployLogPath, string $bu
return false;
}

$buildPhaseLogContent = $this->file->fileGetContents($buildPhaseLogPath);
if (empty($buildPhaseLogContent)) {
return false;
}

$deployLogFileExists = $this->file->isExists($deployLogPath);
if (!$deployLogFileExists) {
return true;
}

return false === strpos(
$this->file->fileGetContents($deployLogPath),
$this->file->fileGetContents($buildPhaseLogPath)
$buildPhaseLogContent
);
}
}
1 change: 1 addition & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function getDefaultCommands()
$this->container->create(Command\ConfigShow::class),
$this->container->create(Command\ConfigCreate::class),
$this->container->create(Command\ConfigUpdate::class),
$this->container->create(Command\ConfigValidate::class),
$this->container->create(Command\RunCommand::class),
$this->container->create(Command\GenerateSchema::class),
$this->container->create(Command\ErrorShow::class)
Expand Down
19 changes: 19 additions & 0 deletions src/Cli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\MagentoCloud;

/**
* @api
*
* @codeCoverageIgnore
*/
class Cli
{
public const SUCCESS = 0;
public const FAILURE = 1;
}
9 changes: 7 additions & 2 deletions src/Command/ApplyPatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Magento\MagentoCloud\Command;

use Magento\MagentoCloud\Cli;
use Magento\MagentoCloud\Config\ConfigException;
use Magento\MagentoCloud\Patch\Manager;
use Magento\MagentoCloud\Shell\ShellException;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -49,12 +51,15 @@ protected function configure(): void
}

/**
* {@inheritdoc}
* {@inheritDoc}
*
* @throws ShellException
* @throws ConfigException
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$this->manager->apply();

return Cli::SUCCESS;
}
}
20 changes: 12 additions & 8 deletions src/Command/BackupList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

namespace Magento\MagentoCloud\Command;

use Magento\MagentoCloud\Cli;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\MagentoCloud\Command\Backup\FileList as BackupFilesList;
use Psr\Log\LoggerInterface;
use Exception;

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

/**
* Command name
*/
const NAME = 'backup:list';
public const NAME = 'backup:list';

/**
* @param BackupFilesList $backupFilesList
Expand All @@ -52,7 +51,7 @@ public function __construct(
/**
* @inheritdoc
*/
protected function configure()
protected function configure(): void
{
$this->setName(self::NAME)
->setDescription('Shows the list of backup files.');
Expand All @@ -61,16 +60,21 @@ protected function configure()
}

/**
* @inheritdoc
* {@inheritDoc}
*
* @throws Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
try {
$output->writeln('<comment>The list of backup files:</comment>');
$output->writeln($this->backupFilesList->get() ?: 'There are no files in the backup');
} catch (\Exception $exception) {
} catch (Exception $exception) {
$this->logger->critical($exception->getMessage());

throw $exception;
}

return Cli::SUCCESS;
}
}
21 changes: 13 additions & 8 deletions src/Command/BackupRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

namespace Magento\MagentoCloud\Command;

use Magento\MagentoCloud\Cli;
use Symfony\Component\Console\Command\Command;
use Magento\MagentoCloud\Command\Backup\Restore;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Psr\Log\LoggerInterface;
use Exception;

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

/**
* Command name
*/
const NAME = 'backup:restore';
public const NAME = 'backup:restore';

/**
* @param Restore $restore
Expand All @@ -45,13 +44,14 @@ public function __construct(Restore $restore, LoggerInterface $logger)
{
$this->restore = $restore;
$this->logger = $logger;

parent::__construct();
}

/**
* @inheritdoc
*/
protected function configure()
protected function configure(): void
{
$this->setName(self::NAME)
->setDescription(
Expand All @@ -74,9 +74,11 @@ protected function configure()
}

/**
* @inheritdoc
* {@inheritdoc}
*
* @throws Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
try {
$restore = true;
Expand All @@ -93,9 +95,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($restore) {
$this->restore->run($input, $output);
}
} catch (\Exception $exception) {
} catch (Exception $exception) {
$this->logger->critical($exception->getMessage());

throw $exception;
}

return Cli::SUCCESS;
}
}
22 changes: 17 additions & 5 deletions src/Command/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

namespace Magento\MagentoCloud\Command;

use Magento\MagentoCloud\Cli;
use Magento\MagentoCloud\Command\Build\Generate;
use Magento\MagentoCloud\Command\Build\Transfer;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use RuntimeException;

/**
* CLI command for build hook. Responsible for preparing the codebase before it's moved to the server.
Expand All @@ -20,12 +22,12 @@
*/
class Build extends Command
{
const NAME = 'build';
public const NAME = 'build';

/**
* @inheritdoc
*/
protected function configure()
protected function configure(): void
{
$this->setName(static::NAME)
->setDescription('Builds application.');
Expand All @@ -37,10 +39,20 @@ protected function configure()
* This method is a proxy for calling build:generate and build:transfer commands.
*
* {@inheritdoc}
*
* @throws RuntimeException
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$this->getApplication()->find(Generate::NAME)->execute($input, $output);
$this->getApplication()->find(Transfer::NAME)->execute($input, $output);
$application = $this->getApplication();

if (null === $application) {
throw new RuntimeException('Application is not defined');
}

$application->find(Generate::NAME)->execute($input, $output);
$application->find(Transfer::NAME)->execute($input, $output);

return Cli::SUCCESS;
}
}
Loading

0 comments on commit 2340afb

Please sign in to comment.