Merge pull request #9844 from appwrite/1.7.x

Append build error to build logs
This commit is contained in:
Matej Bačo 2025-05-21 10:15:20 +02:00 committed by GitHub
commit 8734aeb314
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 1 deletions

View file

@ -1223,7 +1223,7 @@ class Builds extends Action
$deployment->setAttribute('buildEndedAt', $endTime);
$deployment->setAttribute('buildDuration', \intval(\ceil($durationEnd - $durationStart)));
$deployment->setAttribute('status', 'failed');
$deployment->setAttribute('buildLogs', $message);
$deployment->setAttribute('buildLogs', $deployment->getAttribute('buildLogs', '') . "\n" . $message);
$deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment);

View file

@ -2651,4 +2651,46 @@ class SitesCustomServerTest extends Scope
$this->cleanupSite($siteId);
}
public function testBuildErrorLogs(): void
{
$siteId = $this->setupSite([
'siteId' => ID::unique(),
'name' => 'Astro SSR site',
'framework' => 'astro',
'buildRuntime' => 'node-22',
'outputDirectory' => './dist',
'buildCommand' => 'npm run build',
'installCommand' => 'echo "custom error" && npm install',
'adapter' => 'ssr',
]);
$this->assertNotEmpty($siteId);
$site = $this->getSite($siteId);
$this->assertEquals('200', $site['headers']['status-code']);
$domain = $this->setupSiteDomain($siteId);
$this->assertNotEmpty($domain);
$deployment = $this->createDeployment($siteId, [
'code' => $this->packageSite('astro-static'),
'activate' => true
]);
$this->assertEquals(202, $deployment['headers']['status-code']);
$deploymentId = $deployment['body']['$id'];
$this->assertNotEmpty($deploymentId);
$this->assertEventually(function () use ($siteId, $deploymentId) {
$deployment = $this->getDeployment($siteId, $deploymentId);
$this->assertEquals('failed', $deployment['body']['status'], 'Deployment status is failed, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
}, 100000, 500);
$deployment = $this->getDeployment($siteId, $deploymentId);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertStringContainsString('custom error', $deployment['body']['buildLogs']);
$this->assertStringContainsString('Adapter mismatch', $deployment['body']['buildLogs']);
$this->cleanupSite($siteId);
}
}