mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Queueing a deployment now honors git_commit_sha when set (non‑PR, non‑rollback). The deployment job keeps the pinned SHA as the resolved commit and avoids overwriting it with branch head. A hidden log entry records the actual checked‑out HEAD for verification. Added tests to ensure pinned commits are persisted and unpinned commits still resolve normally.
72 lines
2.3 KiB
PHP
72 lines
2.3 KiB
PHP
<?php
|
|
|
|
use App\Models\Application;
|
|
use App\Models\ApplicationDeploymentQueue;
|
|
use App\Models\Environment;
|
|
use App\Models\Project;
|
|
use App\Models\Server;
|
|
use App\Models\StandaloneDocker;
|
|
use App\Models\Team;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Bus;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
Bus::fake();
|
|
|
|
$this->team = Team::factory()->create();
|
|
$this->project = Project::create([
|
|
'name' => 'Pinned Commit Project',
|
|
'team_id' => $this->team->id,
|
|
]);
|
|
$this->environment = Environment::create([
|
|
'name' => 'production',
|
|
'project_id' => $this->project->id,
|
|
]);
|
|
$this->server = Server::factory()->create(['team_id' => $this->team->id]);
|
|
$this->destination = $this->server->standaloneDockers()->first();
|
|
});
|
|
|
|
test('pinned commit overrides queued commit', function () {
|
|
$pinnedCommit = str_repeat('a', 40);
|
|
$application = Application::factory()->create([
|
|
'environment_id' => $this->environment->id,
|
|
'destination_type' => StandaloneDocker::class,
|
|
'destination_id' => $this->destination->id,
|
|
'git_commit_sha' => $pinnedCommit,
|
|
]);
|
|
|
|
$deploymentUuid = 'pinned-commit-deployment';
|
|
queue_application_deployment(
|
|
application: $application,
|
|
deployment_uuid: $deploymentUuid,
|
|
commit: str_repeat('b', 40),
|
|
is_webhook: true
|
|
);
|
|
|
|
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
|
|
expect($deployment)->not->toBeNull();
|
|
expect($deployment->commit)->toBe($pinnedCommit);
|
|
});
|
|
|
|
test('un-pinned commit keeps the requested commit', function () {
|
|
$requestedCommit = str_repeat('c', 40);
|
|
$application = Application::factory()->create([
|
|
'environment_id' => $this->environment->id,
|
|
'destination_type' => StandaloneDocker::class,
|
|
'destination_id' => $this->destination->id,
|
|
'git_commit_sha' => 'HEAD',
|
|
]);
|
|
|
|
$deploymentUuid = 'head-commit-deployment';
|
|
queue_application_deployment(
|
|
application: $application,
|
|
deployment_uuid: $deploymentUuid,
|
|
commit: $requestedCommit
|
|
);
|
|
|
|
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $deploymentUuid)->first();
|
|
expect($deployment)->not->toBeNull();
|
|
expect($deployment->commit)->toBe($requestedCommit);
|
|
});
|