diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 0bb84c6b4e..27c6e59128 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -693,7 +693,7 @@ class Builds extends Action cpus: $cpus, memory: $memory, timeout: $timeout, - remove: true, + remove: true, entrypoint: $deployment->getAttribute('entrypoint', ''), destination: APP_STORAGE_BUILDS . "/app-{$project->getId()}", variables: $vars, @@ -746,7 +746,12 @@ class Builds extends Action } } + if (empty($logs)) { + return; + } + $currentLogs = $deployment->getAttribute('buildLogs', ''); + $affected = false; $streamLogs = \str_replace("\\n", "{APPWRITE_LINEBREAK_PLACEHOLDER}", $logs); foreach (\explode("\n", $streamLogs) as $streamLog) { @@ -759,14 +764,20 @@ class Builds extends Action // TODO: use part[0] as timestamp when switching to dbForLogs for build logs $currentLogs .= $streamParts[1]; + + if (!empty($streamParts[1])) { + $affected = true; + } } - $deployment = $deployment->setAttribute('buildLogs', $currentLogs); - $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); + if ($affected) { + $deployment = $deployment->setAttribute('buildLogs', $currentLogs); + $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); - $queueForRealtime - ->setPayload($deployment->getArrayCopy()) - ->trigger(); + $queueForRealtime + ->setPayload($deployment->getArrayCopy()) + ->trigger(); + } } } ); @@ -1199,6 +1210,13 @@ class Builds extends Action $message = "" . $message; } + $separator = \strpos($message, '{APPWRITE_DETECTION_SEPARATOR_START}'); + if ($separator !== false) { + $error = \substr($message, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_START}')); + $message = \substr($message, 0, $separator); + $message .= "\n" . $error; + } + $endTime = DateTime::now(); $durationEnd = \microtime(true); $deployment->setAttribute('buildEndedAt', $endTime); diff --git a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php index 01de2782a5..ba2d18694a 100644 --- a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php @@ -607,15 +607,6 @@ class RealtimeConsoleClientTest extends Scope $this->assertContains("projects.{$projectId}", $response['data']['channels']); $this->assertArrayHasKey('buildLogs', $response['data']['payload']); - // Ignore comparasion for first payload - if ($previousBuildLogs !== null) { - $this->assertNotEquals($previousBuildLogs, $response['data']['payload']['buildLogs']); - } - - $previousBuildLogs = $response['data']['payload']['buildLogs']; - - $this->assertEquals('building', $response['data']['payload']['status']); - if (!empty($response['data']['payload']['buildEndedAt'])) { $this->assertNotEmpty($response['data']['payload']['buildEndedAt']); $this->assertNotEmpty($response['data']['payload']['buildStartedAt']); @@ -626,6 +617,15 @@ class RealtimeConsoleClientTest extends Scope $this->assertNotEmpty($response['data']['payload']['buildLogs']); break; } + + // Ignore comparasion for first payload + if ($previousBuildLogs !== null) { + $this->assertNotEquals($previousBuildLogs, $response['data']['payload']['buildLogs']); + } + + $previousBuildLogs = $response['data']['payload']['buildLogs']; + + $this->assertEquals('building', $response['data']['payload']['status']); } $response = json_decode($client->receive(), true); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index f9d5b4acdf..dd4efa5932 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2646,7 +2646,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('Error:', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('No such file or directory', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); }, 100000, 500); $this->cleanupSite($siteId);