Merge pull request #1004 from coollabsio/ijpatricio-wip-2

Refactors `coolifyProcess` to `remoteProcess`
This commit is contained in:
Andras Bacsai 2023-03-24 13:56:57 +01:00 committed by GitHub
commit 436d22e385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 455 additions and 323 deletions

View File

@ -0,0 +1,29 @@
<?php
namespace App\Actions\RemoteProcess;
use App\Data\RemoteProcessArgs;
use App\Jobs\ExecuteRemoteProcess;
use Spatie\Activitylog\Models\Activity;
class DispatchRemoteProcess
{
protected Activity $activity;
public function __construct(RemoteProcessArgs $remoteProcessArgs){
$this->activity = activity()
->withProperties($remoteProcessArgs->toArray())
->log("Awaiting command to start...\n\n");
}
public function __invoke(): Activity
{
$job = new ExecuteRemoteProcess($this->activity);
dispatch($job);
$this->activity->refresh();
return $this->activity;
}
}

View File

@ -1,25 +1,17 @@
<?php
namespace App\Jobs;
namespace App\Actions\RemoteProcess;
use App\Services\ProcessStatus;
use Illuminate\Support\Facades\DB;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Process\InvokedProcess;
use App\Enums\ActivityTypes;
use App\Enums\ProcessStatus;
use Illuminate\Process\ProcessResult;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Process;
use Spatie\Activitylog\Contracts\Activity;
use Spatie\Activitylog\Models\Activity;
class ExecuteCoolifyProcess implements ShouldQueue
class RunRemoteProcess
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $throttleIntervalMS = 500;
public Activity $activity;
protected $timeStart;
@ -27,6 +19,8 @@ class ExecuteCoolifyProcess implements ShouldQueue
protected $lastWriteAt = 0;
protected $throttleIntervalMS = 500;
protected string $stdOutIncremental = '';
protected string $stdErrIncremental = '';
@ -34,41 +28,20 @@ class ExecuteCoolifyProcess implements ShouldQueue
/**
* Create a new job instance.
*/
public function __construct(
public Activity $activity,
){}
public function __construct(Activity $activity)
{
if ($activity->getExtraProperty('type') !== ActivityTypes::COOLIFY_PROCESS->value) {
throw new \RuntimeException('Incompatible Activity to run a remote command.');
}
/**
* Execute the job.
*/
public function handle(): ProcessResult
$this->activity = $activity;
}
public function __invoke(): ProcessResult
{
$this->timeStart = hrtime(true);
$user = $this->activity->getExtraProperty('user');
$destination = $this->activity->getExtraProperty('destination');
$port = $this->activity->getExtraProperty('port');
$command = $this->activity->getExtraProperty('command');
$delimiter = 'EOF-COOLIFY-SSH';
$sshCommand = 'ssh '
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
. '-o PasswordAuthentication=no '
. '-o RequestTTY=no '
// Quiet mode. Causes most warning and diagnostic messages to be suppressed.
// Errors are still out put. This is to silence for example, that warning
// Permanently added <host and key type> to the list of known hosts.
. '-q '
. "-p {$port} "
. "{$user}@{$destination} "
. " 'bash -se' << \\$delimiter" . PHP_EOL
. $command . PHP_EOL
. $delimiter;
$process = Process::start($sshCommand, $this->handleOutput(...));
$processResult = $process->wait();
$processResult = Process::run($this->getCommand(), $this->handleOutput(...));
$status = match ($processResult->exitCode()) {
0 => ProcessStatus::FINISHED,
@ -87,6 +60,26 @@ class ExecuteCoolifyProcess implements ShouldQueue
return $processResult;
}
protected function getCommand(): string
{
$user = $this->activity->getExtraProperty('user');
$destination = $this->activity->getExtraProperty('destination');
$port = $this->activity->getExtraProperty('port');
$command = $this->activity->getExtraProperty('command');
$delimiter = 'EOF-COOLIFY-SSH';
return 'ssh '
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
. '-o PasswordAuthentication=no '
. '-o RequestTTY=no '
. "-p {$port} "
. "{$user}@{$destination} "
. " 'bash -se' << \\$delimiter" . PHP_EOL
. $command . PHP_EOL
. $delimiter;
}
protected function handleOutput(string $type, string $output)
{
$this->currentTime = $this->elapsedTime();
@ -109,7 +102,7 @@ class ExecuteCoolifyProcess implements ShouldQueue
}
/**
* Decides if it's time to write again to database.
* Determines if it's time to write again to database.
*
* @return bool
*/

View File

@ -0,0 +1,19 @@
<?php
namespace App\Data;
use App\Enums\ActivityTypes;
use App\Enums\ProcessStatus;
use Spatie\LaravelData\Data;
class RemoteProcessArgs extends Data
{
public function __construct(
public string $destination,
public string $command,
public int $port,
public string $user,
public string $type = ActivityTypes::COOLIFY_PROCESS->value,
public string $status = ProcessStatus::HOLDING->value,
){}
}

View File

@ -0,0 +1,8 @@
<?php
namespace App\Enums;
enum ActivityTypes: string
{
case COOLIFY_PROCESS = 'coolify_process';
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Enums;
enum ProcessStatus: string
{

View File

@ -23,21 +23,21 @@ class RunCommand extends Component
{
$this->isKeepAliveOn = true;
$this->activity = coolifyProcess($this->command, 'testing-host');
$this->activity = remoteProcess($this->command, 'testing-host');
}
public function runSleepingBeauty()
{
$this->isKeepAliveOn = true;
$this->activity = coolifyProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', 'testing-host');
$this->activity = remoteProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', 'testing-host');
}
public function runDummyProjectBuild()
{
$this->isKeepAliveOn = true;
$this->activity = coolifyProcess(<<<EOT
$this->activity = remoteProcess(<<<EOT
cd projects/dummy-project
~/.docker/cli-plugins/docker-compose build --no-cache
EOT, 'testing-host');

View File

@ -0,0 +1,35 @@
<?php
namespace App\Jobs;
use App\Actions\RemoteProcess\RunRemoteProcess;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Spatie\Activitylog\Models\Activity;
class ExecuteRemoteProcess implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct(
public Activity $activity,
){}
/**
* Execute the job.
*/
public function handle(): void
{
$remoteProcess = resolve(RunRemoteProcess::class, [
'activity' => $this->activity,
]);
$remoteProcess();
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace App\Services;
use App\Jobs\ExecuteCoolifyProcess;
use Illuminate\Process\ProcessResult;
use Spatie\Activitylog\Contracts\Activity;
class CoolifyProcess
{
protected Activity $activity;
// TODO Left 'root' as default user instead of 'coolify' because
// there's a task at TODO.md to run docker without sudo
public function __construct(
protected string $destination,
protected string $command,
protected ?int $port = 22,
protected ?string $user = 'root',
){
$this->activity = activity()
->withProperties([
'type' => 'COOLIFY_PROCESS',
'user' => $this->user,
'destination' => $this->destination,
'port' => $this->port,
'command' => $this->command,
'status' => ProcessStatus::HOLDING,
])
->log("Awaiting to start command...\n\n");
}
public function __invoke(): Activity|ProcessResult
{
$job = new ExecuteCoolifyProcess($this->activity);
if (app()->environment('testing')) {
return $job->handle();
}
dispatch($job);
return $this->activity;
}
}

View File

@ -1,24 +1,29 @@
<?php
use App\Services\CoolifyProcess;
use Illuminate\Process\ProcessResult;
use App\Actions\RemoteProcess\DispatchRemoteProcess;
use App\Data\RemoteProcessArgs;
use Spatie\Activitylog\Contracts\Activity;
if (! function_exists('coolifyProcess')) {
if (! function_exists('remoteProcess')) {
/**
* Run a Coolify Process, which SSH's into a machine to run the command(s).
* Run a Coolify Process, which SSH's asynchronously into a machine to run the command(s).
* @TODO Change 'root' to 'coolify' when it's able to run Docker commands without sudo
*
*/
function coolifyProcess($command, $destination): Activity|ProcessResult
function remoteProcess(
string $command,
string $destination,
?int $port = 22,
?string $user = 'root',
): Activity
{
$process = resolve(CoolifyProcess::class, [
'destination' => $destination,
'command' => $command,
]);
$activityLog = $process();
return $activityLog;
return resolve(DispatchRemoteProcess::class, [
'remoteProcessArgs' => new RemoteProcessArgs(
destination: $destination,
command: $command,
port: $port,
user: $user,
),
])();
}
}

View File

@ -5,13 +5,14 @@
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.1",
"php": "^8.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.0",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"livewire/livewire": "^2.12",
"spatie/laravel-activitylog": "^4.7",
"spatie/laravel-data": "^3.2",
"spatie/laravel-ray": "^1.32"
},
"require-dev": {

485
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5b876c04da75e4ae5fab21efa402fd45",
"content-hash": "c6bfcd94dc256f9124e84a380eaaf556",
"packages": [
{
"name": "brick/math",
@ -137,6 +137,49 @@
},
"time": "2022-10-27T11:44:00+00:00"
},
{
"name": "doctrine/deprecations",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"phpunit/phpunit": "^7.5|^8.5|^9.5",
"psr/log": "^1|^2|^3"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
},
"time": "2022-05-02T15:47:09+00:00"
},
{
"name": "doctrine/inflector",
"version": "2.0.6",
@ -2276,6 +2319,117 @@
],
"time": "2023-02-08T01:06:31+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-2.x": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
"homepage": "http://www.phpdoc.org",
"keywords": [
"FQSEN",
"phpDocumentor",
"phpdoc",
"reflection",
"static analysis"
],
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
},
"time": "2020-06-27T09:03:43+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5",
"reference": "1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5",
"shasum": ""
},
"require": {
"doctrine/deprecations": "^1.0",
"php": "^7.4 || ^8.0",
"phpdocumentor/reflection-common": "^2.0",
"phpstan/phpdoc-parser": "^1.13"
},
"require-dev": {
"ext-tokenizer": "*",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.13.9",
"vimeo/psalm": "^4.25"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-1.x": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.0"
},
"time": "2023-03-12T10:13:29+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.1",
@ -2351,6 +2505,51 @@
],
"time": "2023-02-25T19:38:58+00:00"
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.16.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e27e92d939e2e3636f0a1f0afaba59692c0bf571",
"reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"type": "library",
"autoload": {
"psr-4": {
"PHPStan\\PhpDocParser\\": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.16.1"
},
"time": "2023-02-07T18:11:17+00:00"
},
{
"name": "pimple/pimple",
"version": "v3.5.0",
@ -3222,6 +3421,89 @@
],
"time": "2023-01-25T17:04:51+00:00"
},
{
"name": "spatie/laravel-data",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-data.git",
"reference": "c4f632924870e52beefe982aa50a88ff59250bfd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-data/zipball/c4f632924870e52beefe982aa50a88ff59250bfd",
"reference": "c4f632924870e52beefe982aa50a88ff59250bfd",
"shasum": ""
},
"require": {
"illuminate/contracts": "^9.30|^10.0",
"php": "^8.1",
"phpdocumentor/type-resolver": "^1.5",
"spatie/laravel-package-tools": "^1.9.0"
},
"require-dev": {
"fakerphp/faker": "^1.14",
"friendsofphp/php-cs-fixer": "^3.0",
"inertiajs/inertia-laravel": "^0.6.3",
"nesbot/carbon": "^2.63",
"nette/php-generator": "^3.5",
"nunomaduro/larastan": "^2.0",
"orchestra/testbench": "^7.6|^8.0",
"pestphp/pest": "^1.22",
"pestphp/pest-plugin-laravel": "^1.3",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpunit/phpunit": "^9.3",
"spatie/invade": "^1.0",
"spatie/laravel-typescript-transformer": "^2.1.6",
"spatie/pest-plugin-snapshots": "^1.1",
"spatie/phpunit-snapshot-assertions": "^4.2",
"spatie/test-time": "^1.2"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\LaravelData\\LaravelDataServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\LaravelData\\": "src",
"Spatie\\LaravelData\\Database\\Factories\\": "database/factories"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ruben Van Assche",
"email": "ruben@spatie.be",
"role": "Developer"
}
],
"description": "Create unified resources and data transfer objects",
"homepage": "https://github.com/spatie/laravel-data",
"keywords": [
"laravel",
"laravel-data",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-data/issues",
"source": "https://github.com/spatie/laravel-data/tree/3.2.0"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2023-03-17T09:48:15+00:00"
},
{
"name": "spatie/laravel-package-tools",
"version": "1.14.2",
@ -6406,49 +6688,6 @@
],
"time": "2023-03-20T15:15:41+00:00"
},
{
"name": "doctrine/deprecations",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"phpunit/phpunit": "^7.5|^8.5|^9.5",
"psr/log": "^1|^2|^3"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
},
"time": "2022-05-02T15:47:09+00:00"
},
{
"name": "fakerphp/faker",
"version": "v1.21.0",
@ -7521,59 +7760,6 @@
},
"time": "2022-02-21T01:04:05+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-2.x": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
"homepage": "http://www.phpdoc.org",
"keywords": [
"FQSEN",
"phpDocumentor",
"phpdoc",
"reflection",
"static analysis"
],
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
},
"time": "2020-06-27T09:03:43+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "5.3.0",
@ -7631,109 +7817,6 @@
},
"time": "2021-10-19T17:43:47+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5",
"reference": "1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5",
"shasum": ""
},
"require": {
"doctrine/deprecations": "^1.0",
"php": "^7.4 || ^8.0",
"phpdocumentor/reflection-common": "^2.0",
"phpstan/phpdoc-parser": "^1.13"
},
"require-dev": {
"ext-tokenizer": "*",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.13.9",
"vimeo/psalm": "^4.25"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-1.x": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.0"
},
"time": "2023-03-12T10:13:29+00:00"
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.16.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e27e92d939e2e3636f0a1f0afaba59692c0bf571",
"reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"type": "library",
"autoload": {
"psr-4": {
"PHPStan\\PhpDocParser\\": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.16.1"
},
"time": "2023-02-07T18:11:17+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "10.0.2",
@ -9484,7 +9567,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.1"
"php": "^8.2"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"

View File

@ -8,6 +8,7 @@
<button wire:click="runSleepingBeauty">Run sleeping beauty</button>
<button wire:click="runDummyProjectBuild">Build DummyProject</button>
</div>
<div>
<input id="manualKeepAlive" name="manualKeepAlive" type="checkbox" wire:model="manualKeepAlive">
<label for="manualKeepAlive">Real-time logs</label>
@ -20,7 +21,7 @@
Activity: <span>{{ $activity?->id ?? 'waiting' }}</span>
</div>
<pre style="width: 100%;overflow-y: scroll;"
@if ($isKeepAliveOn || $manualKeepAlive) wire:poll.750ms="polling" @endif> {{ data_get($activity, 'description') }}</pre>
@if ($isKeepAliveOn || $manualKeepAlive) wire:poll.750ms="polling" @endif>{{ data_get($activity, 'description') }}</pre>
<div>
<div>Details:</div>
<pre style="width: 100%;overflow-y: scroll;">{{ json_encode(data_get($activity, 'properties'), JSON_PRETTY_PRINT) }}</pre>

View File

@ -13,20 +13,20 @@ it('starts a docker container correctly', function () {
$host = 'testing-host';
// Assert there's no containers start with coolify_test_*
$processResult = coolifyProcess($areThereCoolifyTestContainers, $host);
$containers = Output::containerList($processResult->output());
$activity = remoteProcess($areThereCoolifyTestContainers, $host);
$containers = Output::containerList($activity->getExtraProperty('stdout'));
expect($containers)->toBeEmpty();
// start a container nginx -d --name = $containerName
$processResult = coolifyProcess("docker run -d --name {$containerName} nginx", $host);
expect($processResult->successful())->toBeTrue();
$activity = remoteProcess("docker run -d --rm --name {$containerName} nginx", $host);
expect($activity->getExtraProperty('exitCode'))->toBe(0);
// docker ps name = $container
$processResult = coolifyProcess($areThereCoolifyTestContainers, $host);
$containers = Output::containerList($processResult->output());
$activity = remoteProcess($areThereCoolifyTestContainers, $host);
$containers = Output::containerList($activity->getExtraProperty('stdout'));
expect($containers->where('Names', $containerName)->count())->toBe(1);
// Stop testing containers
$processResult = coolifyProcess("docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -q)", $host);
expect($processResult->successful())->toBeTrue();
$activity = remoteProcess("docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -q)", $host);
expect($activity->getExtraProperty('exitCode'))->toBe(0);
});

5
tests/Unit/RulesTest.php Normal file
View File

@ -0,0 +1,5 @@
<?php
test('globals')
->expect(['dd', 'dump', 'ray'])
->not->toBeUsed();