mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
Compare commits
11 commits
aa48915b05
...
91cebadad1
Author | SHA1 | Date | |
---|---|---|---|
|
91cebadad1 | ||
|
d2104fa2ee | ||
|
78938d2de2 | ||
|
553caf6fbe | ||
|
8d052a4121 | ||
|
7fd6dfb6f2 | ||
|
e7cec4c7c5 | ||
|
ac3abe3e94 | ||
|
df1fbba8d5 | ||
|
30a1ed80d5 | ||
|
8dc9b2537b |
10 changed files with 121 additions and 42 deletions
1
.github/workflows/app-code-coverage.yml
vendored
1
.github/workflows/app-code-coverage.yml
vendored
|
@ -63,6 +63,7 @@ jobs:
|
|||
phyre-php -v
|
||||
|
||||
cd /usr/local/phyre/web/
|
||||
sudo touch /usr/local/phyre/web/storage/installed
|
||||
sudo chmod -R 777 vendor
|
||||
composer test:coverage
|
||||
|
||||
|
|
1
.github/workflows/app-unit-test.yml
vendored
1
.github/workflows/app-unit-test.yml
vendored
|
@ -43,6 +43,7 @@ jobs:
|
|||
sudo COMPOSER_ALLOW_SUPERUSER=1 phyre-php composer.phar install
|
||||
|
||||
sudo /phyre-panel/install_web.sh
|
||||
sudo touch /usr/local/phyre/web/storage/installed
|
||||
sudo phyre-php artisan test
|
||||
|
||||
compile-phyre-web-panel:
|
||||
|
|
|
@ -30,15 +30,13 @@ class CustomerPanelProvider extends PanelProvider
|
|||
$defaultColor = Color::Yellow;
|
||||
$brandLogo = asset('images/phyre-logo.svg');
|
||||
|
||||
if (!app()->runningInConsole()) {
|
||||
$isAppInstalled = file_exists(storage_path('installed'));
|
||||
if ($isAppInstalled) {
|
||||
if (setting('general.brand_logo_url')) {
|
||||
$brandLogo = setting('general.brand_logo_url');
|
||||
}
|
||||
if (setting('general.brand_primary_color')) {
|
||||
$defaultColor = Color::hex(setting('general.brand_primary_color'));
|
||||
}
|
||||
$isAppInstalled = file_exists(storage_path('installed'));
|
||||
if ($isAppInstalled) {
|
||||
if (setting('general.brand_logo_url')) {
|
||||
$brandLogo = setting('general.brand_logo_url');
|
||||
}
|
||||
if (setting('general.brand_primary_color')) {
|
||||
$defaultColor = Color::hex(setting('general.brand_primary_color'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class DockerContainer extends Model
|
|||
$createContainer = $dockerContainerApi->run();
|
||||
|
||||
if (!isset($createContainer['ID'])) {
|
||||
return false;
|
||||
throw new \Exception('Failed to create container');
|
||||
}
|
||||
|
||||
$model->image = $createContainer['Image'];
|
||||
|
|
|
@ -90,7 +90,6 @@ class DockerContainerApi
|
|||
$output = shell_exec("cd $dockerContaienrPath && docker-compose up -d");
|
||||
|
||||
// Get docker container id from output
|
||||
$dockerContainerId = trim($output);
|
||||
$output = shell_exec('docker ps --format json --filter name='.$this->name);
|
||||
$output = json_decode($output, true);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ services:
|
|||
ports:
|
||||
- {{$externalPort}}:{{ $port }}
|
||||
|
||||
@if(isset($environmentVariables))
|
||||
@if(isset($environmentVariables) && !empty($environmentVariables))
|
||||
|
||||
environment:
|
||||
|
||||
|
|
|
@ -97,26 +97,25 @@ class AdminPanelProvider extends PanelProvider
|
|||
$defaultColor = Color::Yellow;
|
||||
$brandLogo = asset('images/phyre-logo.svg');
|
||||
|
||||
if (!app()->runningInConsole()) {
|
||||
$isAppInstalled = file_exists(storage_path('installed'));
|
||||
if ($isAppInstalled) {
|
||||
if (setting('general.brand_logo_url')) {
|
||||
$brandLogo = setting('general.brand_logo_url');
|
||||
}
|
||||
if (setting('general.brand_primary_color')) {
|
||||
$defaultColor = Color::hex(setting('general.brand_primary_color'));
|
||||
}
|
||||
$findModules = Module::where('installed', 1)->get();
|
||||
if ($findModules->count() > 0) {
|
||||
foreach ($findModules as $module) {
|
||||
$modulePathClusters = module_path($module->name, 'Filament/Clusters');
|
||||
if (is_dir($modulePathClusters)) {
|
||||
$panel->discoverClusters(in: $modulePathClusters, for: 'Modules\\' . $module->name . '\\Filament\\Clusters');
|
||||
}
|
||||
$modulePathPages = module_path($module->name, 'Filament/Pages');
|
||||
if (is_dir($modulePathPages)) {
|
||||
$panel->discoverPages(in: $modulePathPages, for: 'Modules\\' . $module->name . '\\Filament\\Pages');
|
||||
}
|
||||
|
||||
$isAppInstalled = file_exists(storage_path('installed'));
|
||||
if ($isAppInstalled) {
|
||||
if (setting('general.brand_logo_url')) {
|
||||
$brandLogo = setting('general.brand_logo_url');
|
||||
}
|
||||
if (setting('general.brand_primary_color')) {
|
||||
$defaultColor = Color::hex(setting('general.brand_primary_color'));
|
||||
}
|
||||
$findModules = Module::where('installed', 1)->get();
|
||||
if ($findModules->count() > 0) {
|
||||
foreach ($findModules as $module) {
|
||||
$modulePathClusters = module_path($module->name, 'Filament/Clusters');
|
||||
if (is_dir($modulePathClusters)) {
|
||||
$panel->discoverClusters(in: $modulePathClusters, for: 'Modules\\' . $module->name . '\\Filament\\Clusters');
|
||||
}
|
||||
$modulePathPages = module_path($module->name, 'Filament/Pages');
|
||||
if (is_dir($modulePathPages)) {
|
||||
$panel->discoverPages(in: $modulePathPages, for: 'Modules\\' . $module->name . '\\Filament\\Pages');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ class BackupTest extends ActionTestCase
|
|||
{
|
||||
public function testFullBackup()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
ini_set('max_execution_time', 0);
|
||||
|
||||
Artisan::call('phyre:run-backup');
|
||||
|
||||
$findLastBackup = Backup::orderBy('id', 'asc')->first();
|
||||
|
|
|
@ -2,23 +2,35 @@
|
|||
|
||||
namespace tests\Unit;
|
||||
|
||||
use App\Filament\Pages\Modules;
|
||||
use App\Models\Module;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Livewire\Livewire;
|
||||
use Modules\Docker\App\Models\DockerContainer;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Pages\DockerCatalog;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\CreateDockerContainer;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\EditDockerContainer;
|
||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\ListDockerContainers;
|
||||
use Modules\Docker\PostInstall;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DockerTest extends TestCase
|
||||
{
|
||||
public function testDocker()
|
||||
public function testDockerImages()
|
||||
{
|
||||
$docker = new PostInstall();
|
||||
$docker->setLogFile('/tmp/phyrepanel-docker-install.log');
|
||||
$docker->run();
|
||||
ini_set('memory_limit', '-1');
|
||||
ini_set('max_execution_time', 0);
|
||||
|
||||
$modulesTest = Livewire::test(Modules::class);
|
||||
$modulesTest->call('openInstallModal', 'Docker');
|
||||
|
||||
$installLogFilePath = $modulesTest->get('installLogFilePath');
|
||||
|
||||
$dockerIsInstalled = false;
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
$logFile = file_get_contents('/tmp/phyrepanel-docker-install.log');
|
||||
for ($i = 0; $i < 400; $i++) {
|
||||
$modulesTest->call('getInstallLog');
|
||||
$logFile = file_get_contents($installLogFilePath);
|
||||
if (strpos($logFile, 'Done!') !== false) {
|
||||
$dockerIsInstalled = true;
|
||||
break;
|
||||
|
@ -27,11 +39,16 @@ class DockerTest extends TestCase
|
|||
}
|
||||
$this->assertTrue($dockerIsInstalled);
|
||||
|
||||
$findModule = Module::where('name', 'Docker')->first();
|
||||
$this->assertNotEmpty($findModule);
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$livewireCatalogIndex = Livewire::test(DockerCatalog::class)
|
||||
->set('keyword', 'nginx')
|
||||
->assertSee('nginx');
|
||||
$dockerImage = 'nginx';
|
||||
|
||||
$dockerCatalogTest = Livewire::test(DockerCatalog::class);
|
||||
$livewireCatalogIndex = $dockerCatalogTest->set('keyword', $dockerImage)
|
||||
->assertSee($dockerImage);
|
||||
|
||||
$viewData = $livewireCatalogIndex->viewData('dockerImages');
|
||||
$this->assertNotEmpty($viewData);
|
||||
|
@ -39,6 +56,63 @@ class DockerTest extends TestCase
|
|||
$livewireCatalogIndex->set('keyword', 'non-existing-image')
|
||||
->assertDontSee('non-existing-image');
|
||||
|
||||
}
|
||||
$pullDockerImage = $dockerCatalogTest->call('pullDockerImage', $dockerImage)
|
||||
->assertSee('Pull Docker Image');
|
||||
|
||||
$isDokerImagePulled = false;
|
||||
$pullLog = '';
|
||||
for ($i = 0; $i < 300; $i++) {
|
||||
$pullLog = @file_get_contents($pullDockerImage->get('pullLogFile'));
|
||||
if (strpos($pullLog, 'DONE!') !== false) {
|
||||
$isDokerImagePulled = true;
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
$this->assertTrue($isDokerImagePulled);
|
||||
|
||||
$this->assertNotEmpty($pullLog);
|
||||
$this->assertStringContainsString('DONE!', $pullLog);
|
||||
|
||||
$createDockerContainerTest = Livewire::test(CreateDockerContainer::class);
|
||||
$createDockerContainerTest->assertSee('Create Docker Container');
|
||||
|
||||
$dockerName = 'nginx-latest-phyre-'.rand(1111,9999);
|
||||
$create = $createDockerContainerTest->fillForm([
|
||||
'name' => $dockerName,
|
||||
'image' => 'nginx',
|
||||
'environmentVariables' => [
|
||||
'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
'NGINX_VERSION' => '1.25.5',
|
||||
'NJS_VERSION' => '0.8.4',
|
||||
'NJS_RELEASE' => '2~bookworm',
|
||||
'PKG_RELEASE' => '1~bookworm',
|
||||
],
|
||||
'volumeMapping' => [],
|
||||
'port' => '83',
|
||||
'externalPort' => '3000',
|
||||
])->call('create');
|
||||
|
||||
$this->assertDatabaseHas(DockerContainer::class, [
|
||||
'name' => $dockerName,
|
||||
]);
|
||||
|
||||
$listDockerContainersTest = Livewire::test(ListDockerContainers::class);
|
||||
$listDockerContainersTest->assertSee($dockerName);
|
||||
|
||||
$findDockerContainer = DockerContainer::where('name', $dockerName)->first();
|
||||
|
||||
$editDockerContainersTest = Livewire::test(EditDockerContainer::class, [
|
||||
'record'=> $findDockerContainer->id
|
||||
]);
|
||||
$editDockerContainersTest->assertSee('Edit Docker Container');
|
||||
$editDockerContainersTest->callAction(DeleteAction::class);
|
||||
|
||||
$this->assertModelMissing($findDockerContainer);
|
||||
|
||||
|
||||
// Unistall docker
|
||||
$modulesTest = Livewire::test(Modules::class);
|
||||
$modulesTest->call('openUnistallModal', 'Docker');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ class HostingSubscriptionBackupTest extends ActionTestCase
|
|||
{
|
||||
public function testFullBackup()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
ini_set('max_execution_time', 0);
|
||||
|
||||
$chs = $this->_createHostingSubscription();
|
||||
|
||||
Artisan::call('phyre:run-hosting-subscriptions-backup');
|
||||
|
@ -110,6 +113,7 @@ class HostingSubscriptionBackupTest extends ActionTestCase
|
|||
|
||||
private function _createHostingSubscription()
|
||||
{
|
||||
|
||||
$customer = new Customer();
|
||||
$customer->name = 'UnitBackupTest' . time();
|
||||
$customer->email = 'UnitBackupTest' . time() . '@unit-test.com';
|
||||
|
|
Loading…
Reference in a new issue