Skip to content

Commit 17f194a

Browse files
Merge pull request #385 from magento/develop
Merge develop
2 parents a90c853 + 218b93b commit 17f194a

28 files changed

+1469
-1058
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ before_install:
3535

3636
install:
3737
- composer update -n --no-suggest
38-
- ./bin/ece-tools docker:build --test --php ${TRAVIS_PHP_VERSION}
38+
- ./bin/ece-tools docker:build:integration ${TRAVIS_PHP_VERSION} 10.0 latest
3939

4040
before_script: docker-compose up -d
4141

dist/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.PHONY: help
22

3+
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
34
help: ## This help
45
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
56

src/App/Container.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\MagentoCloud\App;
79

810
use Magento\MagentoCloud\Command\Build;

src/Application.php

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\MagentoCloud;
79

810
use Composer\Composer;
@@ -70,6 +72,7 @@ protected function getDefaultCommands()
7072
$this->container->create(Command\Wizard\IdealState::class),
7173
$this->container->create(Command\Wizard\MasterSlave::class),
7274
$this->container->create(Command\Docker\Build::class),
75+
$this->container->create(Command\Docker\BuildIntegration::class),
7376
$this->container->create(Command\Docker\ConfigConvert::class),
7477
$this->container->create(Command\CronKill::class),
7578
]

src/Command/Docker/Build.php

+39-67
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\MagentoCloud\Command\Docker;
79

810
use Magento\MagentoCloud\Config\Environment;
11+
use Magento\MagentoCloud\Config\RepositoryFactory;
912
use Magento\MagentoCloud\Docker\BuilderFactory;
1013
use Magento\MagentoCloud\Docker\BuilderInterface;
1114
use Magento\MagentoCloud\Docker\ConfigurationMismatchException;
1215
use Magento\MagentoCloud\Filesystem\Driver\File;
13-
use Magento\MagentoCloud\Filesystem\FileList;
1416
use Magento\MagentoCloud\Filesystem\FileSystemException;
1517
use Symfony\Component\Console\Command\Command;
1618
use Symfony\Component\Console\Input\InputInterface;
@@ -31,8 +33,6 @@ class Build extends Command
3133
const OPTION_ES = 'es';
3234
const OPTION_RABBIT_MQ = 'rmq';
3335

34-
const OPTION_IS_TEST = 'test';
35-
3636
/**
3737
* @var BuilderFactory
3838
*/
@@ -44,31 +44,31 @@ class Build extends Command
4444
private $file;
4545

4646
/**
47-
* @var FileList
47+
* @var Environment
4848
*/
49-
private $fileList;
49+
private $environment;
5050

5151
/**
52-
* @var Environment
52+
* @var RepositoryFactory
5353
*/
54-
private $environment;
54+
private $configFactory;
5555

5656
/**
5757
* @param BuilderFactory $builderFactory
5858
* @param File $file
59-
* @param FileList $fileList
6059
* @param Environment $environment
60+
* @param RepositoryFactory $configFactory
6161
*/
6262
public function __construct(
6363
BuilderFactory $builderFactory,
6464
File $file,
65-
FileList $fileList,
66-
Environment $environment
65+
Environment $environment,
66+
RepositoryFactory $configFactory
6767
) {
6868
$this->builderFactory = $builderFactory;
6969
$this->file = $file;
70-
$this->fileList = $fileList;
7170
$this->environment = $environment;
71+
$this->configFactory = $configFactory;
7272

7373
parent::__construct();
7474
}
@@ -84,47 +84,34 @@ protected function configure()
8484
self::OPTION_PHP,
8585
null,
8686
InputOption::VALUE_OPTIONAL,
87-
'PHP version',
88-
BuilderInterface::DEFAULT_PHP_VERSION
87+
'PHP version'
8988
)->addOption(
9089
self::OPTION_NGINX,
9190
null,
9291
InputOption::VALUE_OPTIONAL,
93-
'Nginx version',
94-
BuilderInterface::DEFAULT_NGINX_VERSION
92+
'Nginx version'
9593
)->addOption(
9694
self::OPTION_DB,
9795
null,
9896
InputOption::VALUE_OPTIONAL,
99-
'DB version',
100-
BuilderInterface::DEFAULT_DB_VERSION
97+
'DB version'
10198
)->addOption(
10299
self::OPTION_REDIS,
103100
null,
104101
InputOption::VALUE_OPTIONAL,
105-
'Redis version',
106-
BuilderInterface::DEFAULT_REDIS_VERSION
102+
'Redis version'
107103
)->addOption(
108104
self::OPTION_ES,
109105
null,
110106
InputOption::VALUE_OPTIONAL,
111-
'ElasticSearch version',
112-
BuilderInterface::DEFAULT_ES_VERSION
107+
'Elasticsearch version'
113108
)->addOption(
114109
self::OPTION_RABBIT_MQ,
115110
null,
116111
InputOption::VALUE_OPTIONAL,
117-
'RabbitMQ version',
118-
BuilderInterface::DEFAULT_RABBIT_MQ_VERSION
112+
'RabbitMQ version'
119113
);
120114

121-
$this->addOption(
122-
self::OPTION_IS_TEST,
123-
null,
124-
InputOption::VALUE_NONE,
125-
'Generates ECE-Tools testing configuration (internal usage only)'
126-
);
127-
128115
parent::configure();
129116
}
130117

@@ -136,43 +123,28 @@ protected function configure()
136123
*/
137124
public function execute(InputInterface $input, OutputInterface $output)
138125
{
139-
if ($input->getOption(self::OPTION_IS_TEST)) {
140-
$strategy = BuilderFactory::BUILDER_TEST;
141-
$path = $this->fileList->getToolsDockerCompose();
142-
} else {
143-
$strategy = BuilderFactory::BUILDER_DEV;
144-
$path = $this->fileList->getMagentoDockerCompose();
145-
}
146-
147-
$builder = $this->builderFactory->create($strategy);
148-
149-
if ($phpVersion = $input->getOption(self::OPTION_PHP)) {
150-
$builder->setPhpVersion($phpVersion);
151-
}
152-
153-
if ($nginxVersion = $input->getOption(self::OPTION_NGINX)) {
154-
$builder->setNginxVersion($nginxVersion);
155-
}
156-
157-
if ($dbVersion = $input->getOption(self::OPTION_DB)) {
158-
$builder->setDbVersion($dbVersion);
159-
}
160-
161-
if ($redisVersion = $input->getOption(self::OPTION_REDIS)) {
162-
$builder->setRedisVersion($redisVersion);
163-
}
164-
165-
if ($esVersion = $input->getOption(self::OPTION_ES)) {
166-
$builder->setESVersion($esVersion);
167-
}
168-
169-
if ($rabbitMQVersion = $input->getOption(self::OPTION_RABBIT_MQ)) {
170-
$builder->setRabbitMQVersion($rabbitMQVersion);
171-
}
172-
173-
$config = Yaml::dump($builder->build(), 4, 2);
174-
175-
$this->file->filePutContents($path, $config);
126+
$builder = $this->builderFactory->create(BuilderFactory::BUILDER_DEV);
127+
$config = $this->configFactory->create();
128+
129+
$map = [
130+
self::OPTION_PHP => BuilderInterface::PHP_VERSION,
131+
self::OPTION_DB => BuilderInterface::DB_VERSION,
132+
self::OPTION_NGINX => BuilderInterface::NGINX_VERSION,
133+
self::OPTION_REDIS => BuilderInterface::REDIS_VERSION,
134+
self::OPTION_ES => BuilderInterface::ES_VERSION,
135+
self::OPTION_RABBIT_MQ => BuilderInterface::RABBIT_MQ_VERSION,
136+
];
137+
138+
array_walk($map, function ($key, $option) use ($config, $input) {
139+
if ($value = $input->getOption($option)) {
140+
$config->set($key, $value);
141+
}
142+
});
143+
144+
$this->file->filePutContents(
145+
$builder->getConfigPath(),
146+
Yaml::dump($builder->build($config), 4, 2)
147+
);
176148

177149
$output->writeln('<info>Configuration was built</info>');
178150
}
+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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\Command\Docker;
9+
10+
use Magento\MagentoCloud\Config\Environment;
11+
use Magento\MagentoCloud\Config\RepositoryFactory;
12+
use Magento\MagentoCloud\Docker\BuilderFactory;
13+
use Magento\MagentoCloud\Docker\BuilderInterface;
14+
use Magento\MagentoCloud\Docker\ConfigurationMismatchException;
15+
use Magento\MagentoCloud\Filesystem\Driver\File;
16+
use Magento\MagentoCloud\Filesystem\FileSystemException;
17+
use Symfony\Component\Console\Command\Command;
18+
use Symfony\Component\Console\Input\InputArgument;
19+
use Symfony\Component\Console\Input\InputInterface;
20+
use Symfony\Component\Console\Output\OutputInterface;
21+
use Symfony\Component\Yaml\Yaml;
22+
23+
/**
24+
* Docker build for internal integration testing.
25+
*/
26+
class BuildIntegration extends Command
27+
{
28+
const NAME = 'docker:build:integration';
29+
const ARGUMENT_PHP = 'php';
30+
const ARGUMENT_NGINX = 'nginx';
31+
const ARGUMENT_DB = 'db';
32+
33+
/**
34+
* @var BuilderFactory
35+
*/
36+
private $builderFactory;
37+
38+
/**
39+
* @var File
40+
*/
41+
private $file;
42+
43+
/**
44+
* @var RepositoryFactory
45+
*/
46+
private $configFactory;
47+
48+
/**
49+
* @var Environment
50+
*/
51+
private $environment;
52+
53+
/**
54+
* @param BuilderFactory $builderFactory
55+
* @param File $file
56+
* @param RepositoryFactory $configFactory
57+
* @param Environment $environment
58+
*/
59+
public function __construct(
60+
BuilderFactory $builderFactory,
61+
File $file,
62+
RepositoryFactory $configFactory,
63+
Environment $environment
64+
) {
65+
$this->builderFactory = $builderFactory;
66+
$this->file = $file;
67+
$this->configFactory = $configFactory;
68+
$this->environment = $environment;
69+
70+
parent::__construct();
71+
}
72+
73+
/**
74+
* @inheritdoc
75+
*/
76+
protected function configure()
77+
{
78+
$this->setName(self::NAME)
79+
->setDescription('Build test docker configuration')
80+
->addArgument(
81+
self::ARGUMENT_PHP,
82+
InputArgument::REQUIRED,
83+
'PHP version'
84+
)->addArgument(
85+
self::ARGUMENT_DB,
86+
InputArgument::REQUIRED,
87+
'DB version'
88+
)->addArgument(
89+
self::ARGUMENT_NGINX,
90+
InputArgument::REQUIRED,
91+
'Nginx version'
92+
);
93+
94+
parent::configure();
95+
}
96+
97+
/**
98+
* {@inheritdoc}
99+
*
100+
* @throws FileSystemException
101+
* @throws ConfigurationMismatchException
102+
*/
103+
public function execute(InputInterface $input, OutputInterface $output)
104+
{
105+
$builder = $this->builderFactory->create(BuilderFactory::BUILDER_TEST);
106+
$config = $this->configFactory->create();
107+
108+
$map = [
109+
self::ARGUMENT_PHP => BuilderInterface::PHP_VERSION,
110+
self::ARGUMENT_DB => BuilderInterface::DB_VERSION,
111+
self::ARGUMENT_NGINX => BuilderInterface::NGINX_VERSION,
112+
];
113+
114+
array_walk($map, function ($key, $option) use ($config, $input) {
115+
$config->set($key, $input->getArgument($option));
116+
});
117+
118+
$this->file->filePutContents(
119+
$builder->getConfigPath(),
120+
Yaml::dump($builder->build($config), 4, 2)
121+
);
122+
123+
$output->writeln('<info>Configuration was built</info>');
124+
}
125+
126+
/**
127+
* @inheritdoc
128+
*/
129+
public function isEnabled(): bool
130+
{
131+
return !$this->environment->isMasterBranch();
132+
}
133+
}

0 commit comments

Comments
 (0)