fix(applications): use preview environment variable query
Call the preview environment variable relationship as a query when building the legacy configuration hash, and cover preview deployments with a regression test.
This commit is contained in:
parent
0ecd488d6a
commit
df4d9f8069
2 changed files with 28 additions and 1 deletions
|
|
@ -1255,7 +1255,7 @@ private function legacyConfigurationHash(): string
|
||||||
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
|
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
|
||||||
$newConfigHash .= json_encode($this->environment_variables()->get(['value', 'is_multiline', 'is_literal', 'is_buildtime', 'is_runtime'])->sort());
|
$newConfigHash .= json_encode($this->environment_variables()->get(['value', 'is_multiline', 'is_literal', 'is_buildtime', 'is_runtime'])->sort());
|
||||||
} else {
|
} else {
|
||||||
$newConfigHash .= json_encode($this->environment_variables_preview->get(['value', 'is_multiline', 'is_literal', 'is_buildtime', 'is_runtime'])->sort());
|
$newConfigHash .= json_encode($this->environment_variables_preview()->get(['value', 'is_multiline', 'is_literal', 'is_buildtime', 'is_runtime'])->sort());
|
||||||
}
|
}
|
||||||
|
|
||||||
return md5($newConfigHash);
|
return md5($newConfigHash);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationDeploymentQueue;
|
use App\Models\ApplicationDeploymentQueue;
|
||||||
use App\Models\Environment;
|
use App\Models\Environment;
|
||||||
|
use App\Models\EnvironmentVariable;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Team;
|
use App\Models\Team;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
@ -57,6 +58,32 @@ function configurationChangedDeployment(Application $application): ApplicationDe
|
||||||
->and(data_get($secondDeployment->configuration_diff, 'changes.0.label'))->toBe('Build command');
|
->and(data_get($secondDeployment->configuration_diff, 'changes.0.label'))->toBe('Build command');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checks legacy preview deployment configuration hash using preview environment variable query', function () {
|
||||||
|
$application = configurationChangedTestApplication();
|
||||||
|
|
||||||
|
EnvironmentVariable::create([
|
||||||
|
'key' => 'APP_ENV',
|
||||||
|
'value' => 'preview',
|
||||||
|
'is_preview' => true,
|
||||||
|
'is_multiline' => false,
|
||||||
|
'is_literal' => false,
|
||||||
|
'is_buildtime' => true,
|
||||||
|
'is_runtime' => true,
|
||||||
|
'resourceable_type' => Application::class,
|
||||||
|
'resourceable_id' => $application->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$application->forceFill([
|
||||||
|
'config_hash' => 'legacy-hash',
|
||||||
|
'pull_request_id' => 123,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$diff = $application->pendingDeploymentConfigurationDiff();
|
||||||
|
|
||||||
|
expect($diff->isLegacyFallback())->toBeTrue()
|
||||||
|
->and($diff->isChanged())->toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
it('falls back to legacy configuration hash when no deployment snapshot exists', function () {
|
it('falls back to legacy configuration hash when no deployment snapshot exists', function () {
|
||||||
$application = configurationChangedTestApplication();
|
$application = configurationChangedTestApplication();
|
||||||
$application->isConfigurationChanged(save: true);
|
$application->isConfigurationChanged(save: true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue