Implement Keystone environment deployments
This commit is contained in:
71
tests/Feature/LaravelEnvironmentDefaultsTest.php
Normal file
71
tests/Feature/LaravelEnvironmentDefaultsTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use App\Actions\Applications\CreateLaravelEnvironment;
|
||||
use App\Enums\DeployPolicy;
|
||||
use App\Enums\SchedulerMode;
|
||||
use App\Enums\ServiceType;
|
||||
use App\Models\Application;
|
||||
use App\Models\Organisation;
|
||||
|
||||
it('creates a laravel environment with a primary web scheduler target and no worker by default', function () {
|
||||
$organisation = Organisation::factory()->create();
|
||||
$application = Application::factory()->for($organisation)->create([
|
||||
'default_branch' => 'main',
|
||||
]);
|
||||
|
||||
$environment = app(CreateLaravelEnvironment::class)->execute($application, 'production');
|
||||
$web = $environment->services()->first();
|
||||
|
||||
expect($environment->branch)->toBe('main')
|
||||
->and($environment->scheduler_enabled)->toBeTrue()
|
||||
->and($environment->scheduler_mode)->toBe(SchedulerMode::SINGLE)
|
||||
->and($environment->scheduler_target_service_id)->toBe($web->id)
|
||||
->and($web->type)->toBe(ServiceType::LARAVEL)
|
||||
->and($web->deploy_policy)->toBe(DeployPolicy::WITH_ENVIRONMENT)
|
||||
->and($web->process_roles)->toBe(['web', 'scheduler'])
|
||||
->and($environment->services()->whereJsonContains('process_roles', 'worker')->exists())->toBeFalse();
|
||||
});
|
||||
|
||||
it('provides a managed serversideup frankenphp dockerfile template', function () {
|
||||
$organisation = Organisation::factory()->create();
|
||||
$application = Application::factory()->for($organisation)->create();
|
||||
$environment = app(CreateLaravelEnvironment::class)->execute($application, 'production');
|
||||
$web = $environment->services()->first();
|
||||
|
||||
$dockerfile = $web->driver()->dockerfileTemplate();
|
||||
|
||||
expect($dockerfile)
|
||||
->toContain('FROM serversideup/php:8.4-frankenphp')
|
||||
->toContain('composer install --no-dev')
|
||||
->toContain('SERVER_DOCUMENT_ROOT=/var/www/html/public');
|
||||
});
|
||||
|
||||
it('renders configurable javascript build steps for managed laravel artifacts', function () {
|
||||
$organisation = Organisation::factory()->create();
|
||||
$application = Application::factory()->for($organisation)->create();
|
||||
$environment = app(CreateLaravelEnvironment::class)->execute($application, 'production');
|
||||
$web = $environment->services()->first();
|
||||
|
||||
$web->update([
|
||||
'config' => [
|
||||
...$web->config,
|
||||
'js_package_manager' => 'bun',
|
||||
'js_build_command' => 'bun run build',
|
||||
],
|
||||
]);
|
||||
|
||||
expect($web->refresh()->driver()->dockerfileTemplate())
|
||||
->toContain('bun install --frozen-lockfile')
|
||||
->toContain('bun run build');
|
||||
|
||||
$web->update([
|
||||
'config' => [
|
||||
...$web->config,
|
||||
'js_package_manager' => 'npm',
|
||||
'js_build_command' => 'npm run build',
|
||||
],
|
||||
]);
|
||||
|
||||
expect($web->refresh()->driver()->dockerfileTemplate())
|
||||
->toContain('npm ci && npm run build');
|
||||
});
|
||||
Reference in New Issue
Block a user