mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
fix: trigger configuration changed detection for build settings (#7371)
This commit is contained in:
@@ -1035,7 +1035,7 @@ class Application extends BaseModel
|
||||
|
||||
public function isConfigurationChanged(bool $save = false)
|
||||
{
|
||||
$newConfigHash = base64_encode($this->fqdn.$this->git_repository.$this->git_branch.$this->git_commit_sha.$this->build_pack.$this->static_image.$this->install_command.$this->build_command.$this->start_command.$this->ports_exposes.$this->ports_mappings.$this->custom_network_aliases.$this->base_directory.$this->publish_directory.$this->dockerfile.$this->dockerfile_location.$this->custom_labels.$this->custom_docker_run_options.$this->dockerfile_target_build.$this->redirect.$this->custom_nginx_configuration.$this->settings->use_build_secrets);
|
||||
$newConfigHash = base64_encode($this->fqdn.$this->git_repository.$this->git_branch.$this->git_commit_sha.$this->build_pack.$this->static_image.$this->install_command.$this->build_command.$this->start_command.$this->ports_exposes.$this->ports_mappings.$this->custom_network_aliases.$this->base_directory.$this->publish_directory.$this->dockerfile.$this->dockerfile_location.$this->custom_labels.$this->custom_docker_run_options.$this->dockerfile_target_build.$this->redirect.$this->custom_nginx_configuration.$this->settings->use_build_secrets.$this->settings->inject_build_args_to_dockerfile.$this->settings->include_source_commit_in_build);
|
||||
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());
|
||||
} else {
|
||||
|
||||
@@ -15,3 +15,35 @@ it('different custom_network_aliases values produce different hashes', function
|
||||
->and($hash1)->not->toBe($hash3)
|
||||
->and($hash2)->not->toBe($hash3);
|
||||
});
|
||||
|
||||
/**
|
||||
* Unit test to verify that inject_build_args_to_dockerfile is included in configuration change detection.
|
||||
* Tests the behavior of the isConfigurationChanged method by verifying that different
|
||||
* inject_build_args_to_dockerfile values produce different configuration hashes.
|
||||
*/
|
||||
it('different inject_build_args_to_dockerfile values produce different hashes', function () {
|
||||
// Test that the hash calculation includes inject_build_args_to_dockerfile by computing hashes with different values
|
||||
// true becomes '1', false becomes '', so they produce different hashes
|
||||
$hash1 = md5(base64_encode('test'.true)); // 'test1'
|
||||
$hash2 = md5(base64_encode('test'.false)); // 'test'
|
||||
$hash3 = md5(base64_encode('test')); // 'test'
|
||||
|
||||
expect($hash1)->not->toBe($hash2)
|
||||
->and($hash2)->toBe($hash3); // false and empty string produce the same result
|
||||
});
|
||||
|
||||
/**
|
||||
* Unit test to verify that include_source_commit_in_build is included in configuration change detection.
|
||||
* Tests the behavior of the isConfigurationChanged method by verifying that different
|
||||
* include_source_commit_in_build values produce different configuration hashes.
|
||||
*/
|
||||
it('different include_source_commit_in_build values produce different hashes', function () {
|
||||
// Test that the hash calculation includes include_source_commit_in_build by computing hashes with different values
|
||||
// true becomes '1', false becomes '', so they produce different hashes
|
||||
$hash1 = md5(base64_encode('test'.true)); // 'test1'
|
||||
$hash2 = md5(base64_encode('test'.false)); // 'test'
|
||||
$hash3 = md5(base64_encode('test')); // 'test'
|
||||
|
||||
expect($hash1)->not->toBe($hash2)
|
||||
->and($hash2)->toBe($hash3); // false and empty string produce the same result
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user