-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
257 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/vendor/ | ||
/composer.lock | ||
/.phpunit.result.cache | ||
/.phpunit.cache | ||
/build/ |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" | ||
colors="true" cacheDirectory=".phpunit.cache"> | ||
<testsuites> | ||
<testsuite name="Deployer Cron Testsuite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</source> | ||
</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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Setono\Deployer\Cron\Integration; | ||
|
||
use phpseclib3\Crypt\PublicKeyLoader; | ||
use phpseclib3\Net\SSH2; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class DeployerTest extends TestCase | ||
{ | ||
protected function assertPreConditions(): void | ||
{ | ||
self::assertFileExists(__DIR__ . '/deploy.php'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_deploys(): void | ||
{ | ||
exec(sprintf('cd %s && php %s deploy -n', __DIR__, '../../vendor/bin/dep'), $output, $return); | ||
|
||
$this->assertSame(0, $return); | ||
|
||
$key = PublicKeyLoader::load(file_get_contents(__DIR__ . '/../docker/ssh_key')); | ||
|
||
$ssh = new SSH2('127.0.0.1', 2222); | ||
if (!$ssh->login('root', $key)) { | ||
throw new \RuntimeException('Could not connection to the server'); | ||
} | ||
|
||
$release = basename(trim($ssh->exec('realpath ~/deployer/current'))); | ||
self::assertIsNumeric($release); | ||
|
||
$release = (int) $release; | ||
|
||
$output = $ssh->exec('crontab -l -u root'); | ||
|
||
self::assertStringContainsString(<<<CRON | ||
###> prod ### | ||
0 0 * * * /usr/bin/php ~/deployer/releases/$release/send-report.php # Run every day at midnight | ||
###< prod ### | ||
CRON | ||
, $output); | ||
} | ||
} |
Oops, something went wrong.