Compare commits

...
Author SHA1 Message Date
Khushboo Verma ec6683cfa9 Refactor 2025-03-20 18:44:00 +05:30
Khushboo Verma c2d0aded6d Fix GitHub check URL 2025-03-20 18:04:36 +05:30
Matej BačoandGitHub 963760678c Merge pull request #9534 from appwrite/feat-active-deployment-details
Feat: Active deployment details - status, creation date
2025-03-18 15:03:06 +01:00
Khushboo VermaandGitHub e95aeed56c Merge pull request #9535 from appwrite/fix-github-author-url
Fix incorrect URL for git commits
2025-03-18 17:39:37 +05:30
Matej Bačo 362520ff4a Remove active depoyment status (not relevant, always ready) 2025-03-18 12:56:44 +01:00
Matej Bačo 7cade1a27d Add active deployment status and creation date 2025-03-18 12:44:21 +01:00
Matej BačoandGitHub 20d90e06f2 Merge pull request #9532 from appwrite/feat-site-deployment-details
Feat: Add screenshots to site
2025-03-18 12:16:55 +01:00
Matej Bačo ef163e8517 Add screenshots to site 2025-03-18 12:01:30 +01:00
Matej BačoandGitHub a0d4e4736c Merge pull request #9524 from appwrite/feat-deployment-total-size
Feat: totalSize attribute
2025-03-18 11:03:11 +01:00
Matej Bačo 3f1c4c2095 Add per-framework screenshot sleep 2025-03-18 11:02:32 +01:00
Matej Bačo 83bcad6e17 Fix deployment rule deletion 2025-03-18 10:10:16 +01:00
Matej Bačo fd4b43569b Enable CodeRabbit for feat-sites 2025-03-17 17:48:33 +01:00
Matej Bačo b4536a94e0 Introduce dpeloyment totalSize + tests 2025-03-17 17:35:03 +01:00
19 changed files with 259 additions and 15 deletions
+7
View File
@@ -0,0 +1,7 @@
reviews:
auto_review:
base_branches:
- main
- 1.6.x
- 1.7.x
- feat-sites # temporary until merged to 1.7.x
+62
View File
@@ -579,6 +579,17 @@ return [
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('deploymentCreatedAt'),
'type' => Database::VAR_DATETIME,
'format' => '',
'size' => 0,
'signed' => false,
'required' => false,
'default' => null,
'array' => false,
'filters' => ['datetime'],
],
[
'$id' => ID::custom('vars'),
'type' => Database::VAR_STRING,
@@ -1003,6 +1014,39 @@ return [
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('deploymentCreatedAt'),
'type' => Database::VAR_DATETIME,
'format' => '',
'size' => 0,
'signed' => false,
'required' => false,
'default' => null,
'array' => false,
'filters' => ['datetime'],
],
[
'$id' => ID::custom('deploymentScreenshotLight'), // File ID from 'screenshots' Console bucket
'type' => Database::VAR_STRING,
'format' => '',
'size' => 32,
'signed' => false,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('deploymentScreenshotDark'), // File ID from 'screenshots' Console bucket
'type' => Database::VAR_STRING,
'format' => '',
'size' => 32,
'signed' => false,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('vars'),
'type' => Database::VAR_STRING,
@@ -1550,6 +1594,17 @@ return [
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('totalSize'),
'type' => Database::VAR_INTEGER,
'format' => '',
'size' => 0,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('status'),
'type' => Database::VAR_STRING,
@@ -1620,6 +1675,13 @@ return [
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_totalSize'),
'type' => Database::INDEX_KEY,
'attributes' => ['totalSize'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_buildDuration'),
'type' => Database::INDEX_KEY,
+12
View File
@@ -19,6 +19,7 @@ return [
'analog' => [
'key' => 'analog',
'name' => 'Analog',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/analog/bundle.sh',
@@ -44,6 +45,7 @@ return [
'angular' => [
'key' => 'angular',
'name' => 'Angular',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/angular/bundle.sh',
@@ -69,6 +71,7 @@ return [
'nextjs' => [
'key' => 'nextjs',
'name' => 'Next.js',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/next-js/bundle.sh',
@@ -93,6 +96,7 @@ return [
'react' => [
'key' => 'react',
'name' => 'React',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
@@ -109,6 +113,7 @@ return [
'nuxt' => [
'key' => 'nuxt',
'name' => 'Nuxt',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/nuxt/bundle.sh',
@@ -133,6 +138,7 @@ return [
'vue' => [
'key' => 'vue',
'name' => 'Vue.js',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
@@ -149,6 +155,7 @@ return [
'sveltekit' => [
'key' => 'sveltekit',
'name' => 'SvelteKit',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/sveltekit/bundle.sh',
@@ -173,6 +180,7 @@ return [
'astro' => [
'key' => 'astro',
'name' => 'Astro',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/astro/bundle.sh',
@@ -197,6 +205,7 @@ return [
'remix' => [
'key' => 'remix',
'name' => 'Remix',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'bundleCommand' => 'sh /usr/local/server/helpers/remix/bundle.sh',
@@ -221,6 +230,7 @@ return [
'flutter' => [
'key' => 'flutter',
'name' => 'Flutter',
'screenshotSleep' => 5000,
'buildRuntime' => 'flutter-3.29',
'runtimes' => getVersions($templateRuntimes['FLUTTER']['versions'], 'flutter'),
'adapters' => [
@@ -236,6 +246,7 @@ return [
'vite' => [
'key' => 'vite',
'name' => 'Vite',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
@@ -251,6 +262,7 @@ return [
'other' => [
'key' => 'other',
'name' => 'Other',
'screenshotSleep' => 3000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
@@ -234,6 +234,7 @@ class Create extends Action
'buildCommands' => $commands,
'sourcePath' => $path,
'sourceSize' => $fileSize,
'totalSize' => $fileSize,
'search' => implode(' ', [$deploymentId, $entrypoint]),
'activate' => $activate,
'sourceMetadata' => $metadata,
@@ -264,6 +265,7 @@ class Create extends Action
'buildCommands' => $commands,
'sourcePath' => $path,
'sourceSize' => $fileSize,
'totalSize' => $fileSize,
'sourceChunksTotal' => $chunks,
'sourceChunksUploaded' => $chunksUploaded,
'search' => implode(' ', [$deploymentId, $entrypoint]),
@@ -100,6 +100,7 @@ class Delete extends Action
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
'deploymentId' => '',
'deploymentInternalId' => '',
'deploymentCreatedAt' => '',
])));
}
@@ -100,6 +100,7 @@ class Create extends Action
'$internalId' => '',
'$id' => $deploymentId,
'sourcePath' => $destination,
'totalSize' => $deployment->getAttribute('sourceSize', 0),
'entrypoint' => $function->getAttribute('entrypoint'),
'buildCommands' => $function->getAttribute('commands', ''),
'search' => implode(' ', [$deploymentId, $function->getAttribute('entrypoint')]),
@@ -93,6 +93,7 @@ class Update extends Base
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
'deploymentInternalId' => $deployment->getInternalId(),
'deploymentId' => $deployment->getId(),
'deploymentCreatedAt' => $deployment->getCreatedAt(),
])));
// Inform scheduler if function is still active
@@ -285,7 +285,8 @@ class Builds extends Action
$directorySize = $device->getFileSize($source);
$deployment
->setAttribute('sourcePath', $source)
->setAttribute('sourceSize', $directorySize);
->setAttribute('sourceSize', $directorySize)
->setAttribute('totalSize', $directorySize);
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
$queueForRealtime
@@ -436,7 +437,8 @@ class Builds extends Action
$deployment
->setAttribute('sourcePath', $source)
->setAttribute('sourceSize', $directorySize);
->setAttribute('sourceSize', $directorySize)
->setAttribute('totalSize', $directorySize);
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
$queueForRealtime
@@ -720,6 +722,7 @@ class Builds extends Action
$deployment->setAttribute('status', 'ready');
$deployment->setAttribute('buildPath', $response['path']);
$deployment->setAttribute('buildSize', $response['size']);
$deployment->setAttribute('totalSize', $deployment->getAttribute('buildSize', 0) + $deployment->getAttribute('sourceSize', 0));
$logs = '';
foreach ($response['output'] as $log) {
@@ -784,12 +787,12 @@ class Builds extends Action
'x-appwrite-key' => API_KEY_DYNAMIC . '_' . $apiKey
]);
$config['sleep'] = 3000; // 3 seconds
$config['sleep'] = 3000;
// Makes tests much faster
$isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development';
if ($isDevelopment) {
$config['sleep'] = 0; // Override this when running Screenshot.php task
$frameworks = Config::getParam('frameworks', []);
$framework = $frameworks[$resource->getAttribute('framework', '')] ?? null;
if (!is_null($framework)) {
$config['sleep'] = $framework['screenshotSleep'];
}
$response = $client->fetch(
@@ -865,6 +868,7 @@ class Builds extends Action
$resource->setAttribute('deploymentId', $deployment->getId());
$resource->setAttribute('deploymentInternalId', $deployment->getInternalId());
$resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt());
$resource = $dbForProject->updateDocument('functions', $resource->getId(), $resource);
$queries = [
@@ -895,6 +899,9 @@ class Builds extends Action
$resource->setAttribute('deploymentId', $deployment->getId());
$resource->setAttribute('deploymentInternalId', $deployment->getInternalId());
$resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', ''));
$resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', ''));
$resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt());
$resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource);
$queries = [
Query::equal("projectInternalId", [$project->getInternalId()]),
@@ -1194,7 +1201,14 @@ class Builds extends Action
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https';
$hostname = System::getEnv('_APP_DOMAIN');
$providerTargetUrl = "{$protocol}://{$hostname}/console/project-{$project->getId()}/functions/function-{$resource->getId()}";
$projectId = $project->getId();
$resourceId = $resource->getId();
$providerTargetUrl = match ($resource->getCollection()) {
'functions' => "{$protocol}://{$hostname}/console/project-{$projectId}/functions/function-{$resourceId}",
'sites' => "{$protocol}://{$hostname}/console/project-{$projectId}/sites/site-{$resourceId}",
default => throw new \Exception('Invalid resource type')
};
$github->updateCommitStatus($repositoryName, $providerCommitHash, $owner, $state, $message, $providerTargetUrl, $name);
}
@@ -243,6 +243,7 @@ class Create extends Action
'buildOutput' => $outputDirectory,
'sourcePath' => $path,
'sourceSize' => $fileSize,
'totalSize' => $fileSize,
'search' => implode(' ', [$deploymentId]),
'activate' => $activate,
'sourceMetadata' => $metadata,
@@ -300,6 +301,7 @@ class Create extends Action
'buildOutput' => $outputDirectory,
'sourcePath' => $path,
'sourceSize' => $fileSize,
'totalSize' => $fileSize,
'sourceChunksTotal' => $chunks,
'sourceChunksUploaded' => $chunksUploaded,
'search' => implode(' ', [$deploymentId]),
@@ -100,6 +100,9 @@ class Delete extends Action
$site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [
'deploymentId' => '',
'deploymentInternalId' => '',
'deploymentScreenshotDark' => '',
'deploymentScreenshotLight' => '',
'deploymentCreatedAt' => '',
])));
}
@@ -111,6 +111,7 @@ class Create extends Action
'$internalId' => '',
'$id' => $deploymentId,
'sourcePath' => $destination,
'totalSize' => $deployment->getAttribute('sourceSize', 0),
'buildCommands' => \implode(' && ', $commands),
'buildOutput' => $site->getAttribute('outputDirectory', ''),
'search' => implode(' ', [$deploymentId]),
@@ -118,8 +119,8 @@ class Create extends Action
'screenshotDark' => '',
'buildStartAt' => null,
'buildEndAt' => null,
'buildDuration' => null,
'buildSize' => null,
'buildDuration' => 0,
'buildSize' => 0,
'status' => 'waiting',
'buildPath' => '',
'buildLogs' => '',
@@ -90,6 +90,9 @@ class Update extends Base
$site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [
'deploymentInternalId' => $deployment->getInternalId(),
'deploymentId' => $deployment->getId(),
'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''),
'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''),
'deploymentCreatedAt' => $deployment->getCreatedAt(),
])));
$queries = [
@@ -1111,6 +1111,7 @@ class Deletes extends Action
*/
Console::info("Deleting rules for deployment " . $deploymentId);
$this->deleteByGroup('rules', [
Query::equal('trigger', ['manual']),
Query::equal('type', ['deployment']),
Query::equal('deploymentResourceInternalId', [$deploymentInternalId]),
Query::equal('projectInternalId', [$project->getInternalId()])
@@ -7,6 +7,7 @@ class Deployments extends Base
public const ALLOWED_ATTRIBUTES = [
'buildSize',
'sourceSize',
'totalSize',
'buildDuration',
'status',
'activate',
@@ -64,6 +64,12 @@ class Deployment extends Model
'default' => 0,
'example' => 128,
])
->addRule('totalSize', [
'type' => self::TYPE_INTEGER,
'description' => 'The total size in bytes (source and build output).',
'default' => 0,
'example' => 128,
])
->addRule('buildId', [
'type' => self::TYPE_STRING,
'description' => 'The current build ID.',
@@ -71,6 +71,12 @@ class Func extends Model
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('deploymentCreatedAt', [
'type' => self::TYPE_DATETIME,
'description' => 'Active deployment creation date in ISO 8601 format.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('scopes', [
'type' => self::TYPE_STRING,
'description' => 'Allowed permission scopes.',
@@ -58,6 +58,24 @@ class Site extends Model
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('deploymentCreatedAt', [
'type' => self::TYPE_DATETIME,
'description' => 'Active deployment creation date in ISO 8601 format.',
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('deploymentScreenshotLight', [
'type' => self::TYPE_STRING,
'description' => 'Screenshot of active deployment with light theme preference file ID.',
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('deploymentScreenshotDark', [
'type' => self::TYPE_STRING,
'description' => 'Screenshot of active deployment with dark theme preference file ID.',
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('vars', [
'type' => Response::MODEL_VARIABLE,
'description' => 'Site variables.',
@@ -408,6 +408,12 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$deployment = $this->getDeployment($functionId, $deployment['body']['$id']);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertEquals(0, $deployment['body']['sourceSize']);
$this->assertEquals(0, $deployment['body']['buildSize']);
$this->assertEquals(0, $deployment['body']['totalSize']);
$deployments = $this->listDeployments($functionId);
$this->assertEquals(200, $deployments['headers']['status-code']);
@@ -480,7 +486,21 @@ class FunctionsCustomServerTest extends Scope
$this->assertStringContainsString("Total users: " . $totalUsers, $execution['body']['logs']);
}, 10000, 500);
$function = $this->deleteFunction($functionId);
$deployment = $this->getDeployment($functionId, $deployment['body']['$id']);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertGreaterThan(0, $deployment['body']['buildSize']);
$totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
$this->assertEquals($totalSize, $deployment['body']['totalSize']);
$function = $this->getFunction($functionId);
$this->assertEquals(200, $function['headers']['status-code']);
$this->assertNotEmpty($function['body']['deploymentId']);
$this->assertNotEmpty($function['body']['deploymentCreatedAt']);
$this->assertEquals($deployment['body']['$id'], $function['body']['deploymentId']);
$this->assertEquals($deployment['body']['$createdAt'], $function['body']['deploymentCreatedAt']);
$function = $this->cleanupFunction($functionId);
}
/**
@@ -1634,11 +1654,14 @@ class FunctionsCustomServerTest extends Scope
'entrypoint' => 'index.php',
'timeout' => 15,
]);
$this->setupDeployment($functionId, [
$this->assertNotEmpty($functionId);
$deploymentId = $this->setupDeployment($functionId, [
'entrypoint' => 'index.php',
'code' => $this->packageFunction('php-cookie'),
'activate' => true
]);
$this->assertNotEmpty($deploymentId);
$cookie = 'cookieName=cookieValue; cookie2=value2; cookie3=value=3; cookie4=val:ue4; cookie5=value5';
$execution = $this->createExecution($functionId, [
@@ -1654,6 +1677,13 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($cookie, $execution['body']['responseBody']);
$this->assertGreaterThan(0, $execution['body']['duration']);
$deployment = $this->getDeployment($functionId, $deploymentId);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertGreaterThan(0, $deployment['body']['buildSize']);
$totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
$this->assertEquals($totalSize, $deployment['body']['totalSize']);
$this->cleanupFunction($functionId);
}
@@ -2029,13 +2059,34 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $function['headers']['status-code']);
$this->assertStringContainsString('maintenance.js', $function['body']['commands']);
$deploymentId2 = $this->setupDuplicateDeployment($functionId, $deploymentId1);
$deployment = $this->createDuplicateDeployment($functionId, $deploymentId1);
$this->assertEquals(202, $deployment['headers']['status-code']);
$deploymentId2 = $deployment['body']['$id'];
$this->assertNotEmpty($deploymentId2);
$deployment = $this->getDeployment($functionId, $deploymentId2);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertEquals(0, $deployment['body']['buildSize']);
$this->assertEquals($deployment['body']['sourceSize'], $deployment['body']['totalSize']);
$this->assertEventually(function () use ($functionId, $deploymentId2) {
$function = $this->getFunction($functionId);
$this->assertEquals($deploymentId2, $function['body']['deploymentId']);
}, 50000, 500);
$execution = $this->createExecution($functionId);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertStringContainsString('Maintenance', $execution['body']['responseBody']);
$deployment = $this->getDeployment($functionId, $deploymentId2);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertGreaterThan(0, $deployment['body']['buildSize']);
$totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
$this->assertEquals($totalSize, $deployment['body']['totalSize']);
$this->cleanupFunction($functionId);
}
@@ -360,6 +360,20 @@ class SitesCustomServerTest extends Scope
$this->assertStringContainsString("Env variable is Appwrite", $response['body']);
$this->assertStringNotContainsString("Variable not found", $response['body']);
$deployment = $this->getDeployment($siteId, $deploymentId);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertGreaterThan(0, $deployment['body']['buildSize']);
$totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
$this->assertEquals($totalSize, $deployment['body']['totalSize']);
$site = $this->getSite($siteId);
$this->assertEquals(200, $site['headers']['status-code']);
$this->assertNotEmpty($site['body']['deploymentId']);
$this->assertNotEmpty($site['body']['deploymentCreatedAt']);
$this->assertEquals($deployment['body']['$id'], $site['body']['deploymentId']);
$this->assertEquals($deployment['body']['$createdAt'], $site['body']['deploymentCreatedAt']);
$this->cleanupSite($siteId);
}
@@ -1515,6 +1529,12 @@ class SitesCustomServerTest extends Scope
$this->assertEquals(202, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$deployment = $this->getDeployment($siteId, $deployment['body']['$id']);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertEquals(0, $deployment['body']['sourceSize']);
$this->assertEquals(0, $deployment['body']['buildSize']);
$this->assertEquals(0, $deployment['body']['totalSize']);
$this->assertEventually(function () use ($siteId) {
$site = $this->getSite($siteId);
$this->assertNotEmpty($site['body']['deploymentId']);
@@ -1536,6 +1556,13 @@ class SitesCustomServerTest extends Scope
$this->assertStringContainsString("Astro Blog", $response['body']);
$this->assertStringContainsString("About Me", $response['body']);
$deployment = $this->getDeployment($siteId, $deployment['body']['$id']);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertGreaterThan(0, $deployment['body']['buildSize']);
$totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
$this->assertEquals($totalSize, $deployment['body']['totalSize']);
$this->cleanupSite($siteId);
}
@@ -1796,11 +1823,15 @@ class SitesCustomServerTest extends Scope
$this->assertStringContainsString("@media (prefers-color-scheme: dark)", $response['body']);
$deployment = $this->getDeployment($siteId, $deploymentId);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['screenshotLight']);
$this->assertNotEmpty($deployment['body']['screenshotDark']);
$site = $this->getSite($siteId);
$this->assertEquals(200, $site['headers']['status-code']);
$this->assertEquals($deployment['body']['screenshotLight'], $site['body']['deploymentScreenshotLight']);
$this->assertEquals($deployment['body']['screenshotDark'], $site['body']['deploymentScreenshotDark']);
$screenshotId = $deployment['body']['screenshotLight'];
$file = $this->client->call(Client::METHOD_GET, "/storage/buckets/screenshots/files/$screenshotId/view?project=console", array_merge([
], $this->getHeaders()));
@@ -1985,12 +2016,33 @@ class SitesCustomServerTest extends Scope
$this->assertEquals(200, $site['headers']['status-code']);
$this->assertEquals('index.html', $site['body']['fallbackFile']);
$deploymentId2 = $this->setupDuplicateDeployment($siteId, $deploymentId1);
$deployment = $this->createDuplicateDeployment($siteId, $deploymentId1);
$this->assertEquals(202, $deployment['headers']['status-code']);
$deploymentId2 = $deployment['body']['$id'];
$this->assertNotEmpty($deploymentId2);
$deployment = $this->getDeployment($siteId, $deploymentId2);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertEquals(0, $deployment['body']['buildSize']);
$this->assertEquals($deployment['body']['sourceSize'], $deployment['body']['totalSize']);
$this->assertEventually(function () use ($siteId, $deploymentId2) {
$site = $this->getSite($siteId);
$this->assertEquals($deploymentId2, $site['body']['deploymentId']);
}, 50000, 500);
$response = $proxyClient->call(Client::METHOD_GET, '/not-found');
$this->assertStringContainsString("Index page", $response['body']);
$deployment = $this->getDeployment($siteId, $deploymentId2);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertGreaterThan(0, $deployment['body']['sourceSize']);
$this->assertGreaterThan(0, $deployment['body']['buildSize']);
$totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize'];
$this->assertEquals($totalSize, $deployment['body']['totalSize']);
$this->cleanupSite($siteId);
}