mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
fix(application): show watch paths for deploy key applications
Closes #12373 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c6f5899949
commit
6e3ab703bf
3 files changed
+112
-8
No files matched your search
@@ -706,13 +706,13 @@ class Application extends BaseModel
|
||||
return false;
|
||||
}
|
||||
|
||||
public function is_github_based(): bool
|
||||
/**
|
||||
* Watch paths filter Git webhook deployments. Deploy-key applications have no
|
||||
* source but receive manual webhooks, so a source is not required.
|
||||
*/
|
||||
public function supportsWatchPaths(): bool
|
||||
{
|
||||
if (data_get($this, 'source')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->git_based() && ! $this->is_public_repository();
|
||||
}
|
||||
|
||||
public function isGithubAppSource(): bool
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@if ($this->application->is_github_based() && !$this->application->is_public_repository())
|
||||
@if ($this->application->supportsWatchPaths())
|
||||
<div class="pt-4">
|
||||
<x-forms.textarea
|
||||
helper="Order-based pattern matching to filter Git webhook deployments. Enter one pattern per line. Commas do not separate patterns. Supports wildcards (*, **, ?) and negation (!). Last matching pattern wins."
|
||||
@@ -272,7 +272,7 @@
|
||||
@endif
|
||||
@endif
|
||||
</x-forms.repository-paths>
|
||||
@if ($this->application->is_github_based() && !$this->application->is_public_repository())
|
||||
@if ($this->application->supportsWatchPaths())
|
||||
<div class="pb-4">
|
||||
<x-forms.textarea
|
||||
helper="Order-based pattern matching to filter Git webhook deployments. Enter one pattern per line. Commas do not separate patterns. Supports wildcards (*, **, ?) and negation (!). Last matching pattern wins."
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Project\Application\General;
|
||||
use App\Models\Application;
|
||||
use App\Models\Environment;
|
||||
use App\Models\GithubApp;
|
||||
use App\Models\InstanceSettings;
|
||||
use App\Models\PrivateKey;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->team = Team::factory()->create();
|
||||
$this->user = User::factory()->create();
|
||||
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
|
||||
|
||||
$this->actingAs($this->user);
|
||||
session(['currentTeam' => $this->team]);
|
||||
InstanceSettings::unguarded(function () {
|
||||
InstanceSettings::updateOrCreate(['id' => 0], []);
|
||||
});
|
||||
|
||||
$project = Project::factory()->create(['team_id' => $this->team->id]);
|
||||
$this->environment = Environment::factory()->create(['project_id' => $project->id]);
|
||||
$server = Server::factory()->create(['team_id' => $this->team->id]);
|
||||
$this->destination = StandaloneDocker::where('server_id', $server->id)->first()
|
||||
?? StandaloneDocker::factory()->create(['server_id' => $server->id, 'network' => 'coolify-test']);
|
||||
});
|
||||
|
||||
function watchPathsTestApplication(array $attributes): Application
|
||||
{
|
||||
return Application::factory()->create([
|
||||
'environment_id' => test()->environment->id,
|
||||
'destination_id' => test()->destination->id,
|
||||
'destination_type' => StandaloneDocker::class,
|
||||
'git_repository' => 'git@github.com:acme/monorepo.git',
|
||||
...$attributes,
|
||||
]);
|
||||
}
|
||||
|
||||
function watchPathsTestGithubApp(bool $isPublic): GithubApp
|
||||
{
|
||||
return GithubApp::create([
|
||||
'name' => $isPublic ? 'public-github' : 'private-github-app',
|
||||
'team_id' => test()->team->id,
|
||||
'api_url' => 'https://api.github.com',
|
||||
'html_url' => 'https://github.com',
|
||||
'is_public' => $isPublic,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression for #12373: deploy-key applications have no source, but manual Git
|
||||
* webhooks still filter their deployments by watch paths.
|
||||
*/
|
||||
it('shows the watch paths field for deploy key applications', function (string $buildPack) {
|
||||
$privateKey = PrivateKey::factory()->create(['team_id' => $this->team->id]);
|
||||
$application = watchPathsTestApplication([
|
||||
'build_pack' => $buildPack,
|
||||
'private_key_id' => $privateKey->id,
|
||||
]);
|
||||
|
||||
Livewire::test(General::class, ['application' => $application->fresh()])
|
||||
->assertSee('Watch paths');
|
||||
})->with(['dockercompose', 'dockerfile', 'nixpacks']);
|
||||
|
||||
it('shows the watch paths field for private GitHub App applications', function () {
|
||||
$githubApp = watchPathsTestGithubApp(isPublic: false);
|
||||
$application = watchPathsTestApplication([
|
||||
'source_id' => $githubApp->id,
|
||||
'source_type' => GithubApp::class,
|
||||
]);
|
||||
|
||||
Livewire::test(General::class, ['application' => $application->fresh()])
|
||||
->assertSee('Watch paths');
|
||||
});
|
||||
|
||||
it('hides the watch paths field for public repository applications', function () {
|
||||
$githubApp = watchPathsTestGithubApp(isPublic: true);
|
||||
$application = watchPathsTestApplication([
|
||||
'source_id' => $githubApp->id,
|
||||
'source_type' => GithubApp::class,
|
||||
]);
|
||||
|
||||
Livewire::test(General::class, ['application' => $application->fresh()])
|
||||
->assertDontSee('Watch paths');
|
||||
});
|
||||
|
||||
it('hides the watch paths field for applications without a Git repository', function () {
|
||||
$application = watchPathsTestApplication([
|
||||
'build_pack' => 'dockerfile',
|
||||
'dockerfile' => "FROM nginx:alpine\n",
|
||||
]);
|
||||
|
||||
Livewire::test(General::class, ['application' => $application->fresh()])
|
||||
->assertDontSee('Watch paths');
|
||||
});
|
||||
Reference in new issue
Block a user