forked from deployphp/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[deployphp#2197] Moved docker to test dir & separated e2e tests from …
…unit-tests The docker directory has been moved into test/ directory. Additionally the e2e tests have been separated from the unit-test files: * AbstractE2ETest class is directly inheriting from TestCase, dropping relation to the AbstractTest * Separate bootstrap.php file for e2e test was created * Separate phpunit-e2e.xml.dist file was created to configure PHPUnit for just the e2e tests * deployer docker service now runs only e2e tests by default
- Loading branch information
Bartlomiej Sacharski
committed
Oct 15, 2020
1 parent
ef78d77
commit ba40142
Showing
14 changed files
with
98 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ RUN ssh-keygen \ | |
-t rsa \ | ||
-f ~/.ssh/id_rsa | ||
|
||
RUN git config --global user.email "[email protected]" \ | ||
&& git config --global user.name "E2E Deployer" | ||
|
||
ARG XDEBUG_VERSION=2.9.8 | ||
RUN set -eux; \ | ||
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \ | ||
|
@@ -27,7 +30,6 @@ RUN set -eux; \ | |
apk del .build-deps | ||
|
||
COPY --from=composer /tmp/composer /bin/composer | ||
ENV E2E_ENV=1 | ||
VOLUME [ "/project" ] | ||
WORKDIR /project | ||
|
||
|
@@ -47,8 +49,8 @@ RUN mkdir /run/sshd \ | |
&& sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd | ||
|
||
# Configure Apache to expose healthcheck & configure site to use /var/www/html/current ad document root | ||
COPY ./conf/healthcheck.conf /etc/apache2/sites-available/healthcheck.conf | ||
COPY ./initial-site/index.html /var/www/html/initial-site/index.html | ||
COPY conf/healthcheck.conf /etc/apache2/sites-available/healthcheck.conf | ||
COPY initial-site/index.html /var/www/html/initial-site/index.html | ||
|
||
ENV APACHE_DOCUMENT_ROOT /var/www/html/current | ||
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/000-default.conf \ | ||
|
@@ -70,12 +72,25 @@ RUN useradd \ | |
&& chmod 700 ~deployer/.ssh \ | ||
&& chmod 600 ~deployer/.ssh/authorized_keys | ||
|
||
COPY ./scripts/start-servers.sh /usr/local/bin/start-servers | ||
RUN useradd \ | ||
--create-home \ | ||
git \ | ||
&& mkdir ~git/.ssh \ | ||
&& touch ~git/.ssh/authorized_keys \ | ||
&& chown -R git:git ~git/.ssh \ | ||
&& chmod 700 ~git/.ssh \ | ||
&& chmod 700 ~git/.ssh/authorized_keys \ | ||
&& mkdir ~git/repository \ | ||
&& git init --bare ~git/repository \ | ||
&& chown -R git:git ~git/repository | ||
|
||
COPY scripts/start-servers.sh /usr/local/bin/start-servers | ||
COPY --from=composer /tmp/composer /usr/local/bin/composer | ||
COPY --from=deployer /root/.ssh/id_rsa.pub /tmp/root_rsa.pub | ||
|
||
RUN chmod a+x /usr/local/bin/start-servers \ | ||
&& cat /tmp/root_rsa.pub >> ~deployer/.ssh/authorized_keys \ | ||
&& cat /tmp/root_rsa.pub >> ~git/.ssh/authorized_keys \ | ||
&& rm -rf /tmp/root_rsa.pub | ||
|
||
EXPOSE 22 80 81 | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,50 @@ | ||
<?php declare(strict_types=1); | ||
namespace e2e; | ||
|
||
use Deployer\AbstractTest; | ||
use Deployer\Deployer; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Tester\ApplicationTester; | ||
|
||
abstract class AbstractE2ETest extends AbstractTest | ||
abstract class AbstractE2ETest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
/** | ||
* @var ApplicationTester | ||
*/ | ||
protected $tester; | ||
|
||
/** | ||
* @var Deployer | ||
*/ | ||
protected $deployer; | ||
|
||
public static function setUpBeforeClass(): void | ||
{ | ||
self::cleanUp(); | ||
mkdir(__TEMP_DIR__); | ||
} | ||
|
||
public static function tearDownAfterClass(): void | ||
{ | ||
parent::setUp(); | ||
$isE2EEnvironment = filter_var(getenv('E2E_ENV'), FILTER_VALIDATE_BOOLEAN); | ||
self::cleanUp(); | ||
} | ||
|
||
if ($isE2EEnvironment !== true) { | ||
$this->markTestSkipped('Cannot execute in non-E2E environment'); | ||
protected static function cleanUp(): void | ||
{ | ||
if (is_dir(__TEMP_DIR__)) { | ||
exec('rm -rf ' . __TEMP_DIR__); | ||
} | ||
} | ||
|
||
protected function init(string $recipe): void | ||
{ | ||
$console = new Application(); | ||
$console->setAutoExit(false); | ||
$this->tester = new ApplicationTester($console); | ||
|
||
$this->deployer = new Deployer($console); | ||
Deployer::load($recipe); | ||
$this->deployer->init(); | ||
$this->deployer->config->set('deploy_path', __TEMP_DIR__ . '/{{hostname}}'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
$loaded = false; | ||
$file = __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
if (file_exists($file)) { | ||
require $file; | ||
} else { | ||
die( | ||
'You need to set up the project dependencies using the following commands:' . PHP_EOL . | ||
'composer install' . PHP_EOL | ||
); | ||
} | ||
|
||
// For loading recipes | ||
set_include_path(__DIR__ . '/../..' . PATH_SEPARATOR . get_include_path()); | ||
|
||
define('DEPLOYER_BIN', __DIR__ . '/../../bin/dep'); | ||
define('__FIXTURES__', __DIR__ . '/../fixtures'); | ||
define('__REPOSITORY__', __DIR__ . '/../fixtures/repository'); | ||
define('__TEMP_DIR__', sys_get_temp_dir() . '/deployer'); | ||
|
||
require_once __DIR__ . '/AbstractE2ETest.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<testsuites> | ||
<testsuite name="e2e"> | ||
<directory>.</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../../../recipe/laravel.php'; |