From b4536a94e0610abc7c3e2343b55a29f0e04c439b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 17 Mar 2025 17:35:03 +0100 Subject: [PATCH 1/7] Introduce dpeloyment totalSize + tests --- app/config/collections/projects.php | 18 +++++++ .../Functions/Http/Deployments/Create.php | 2 + .../Http/Deployments/Duplicate/Create.php | 1 + .../Modules/Functions/Workers/Builds.php | 7 ++- .../Modules/Sites/Http/Deployments/Create.php | 2 + .../Http/Deployments/Duplicate/Create.php | 5 +- .../Validator/Queries/Deployments.php | 1 + .../Utopia/Response/Model/Deployment.php | 6 +++ .../Functions/FunctionsCustomServerTest.php | 50 +++++++++++++++++-- .../Services/Sites/SitesCustomServerTest.php | 43 +++++++++++++++- 10 files changed, 127 insertions(+), 8 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 244f5ae13e..3ef817cd73 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1550,6 +1550,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 +1631,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, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php index 69ebb6f68c..1f49568249 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php @@ -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]), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php index c09b68aef5..aa1142570b 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php @@ -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')]), diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 15e0eb985c..6cc084ee88 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -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) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index d5185a8438..c52f958da5 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -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]), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index fdf6eaeaf6..9982828ec2 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -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' => '', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php index 75035ad501..73631ecfb8 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php @@ -7,6 +7,7 @@ class Deployments extends Base public const ALLOWED_ATTRIBUTES = [ 'buildSize', 'sourceSize', + 'totalSize', 'buildDuration', 'status', 'activate', diff --git a/src/Appwrite/Utopia/Response/Model/Deployment.php b/src/Appwrite/Utopia/Response/Model/Deployment.php index 8321b548c9..4729e8a122 100644 --- a/src/Appwrite/Utopia/Response/Model/Deployment.php +++ b/src/Appwrite/Utopia/Response/Model/Deployment.php @@ -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.', diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index b6416b0167..b238ba2768 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -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,14 @@ 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->cleanupFunction($functionId); } /** @@ -1634,11 +1647,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 +1670,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 +2052,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); } diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 6ecb35d5a9..4a4211b22c 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -360,6 +360,13 @@ 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']); + $this->cleanupSite($siteId); } @@ -1510,6 +1517,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']); @@ -1531,6 +1544,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); } @@ -1980,12 +2000,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); } From fd4b43569b8901369f8c59bb36403398486dffd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 17 Mar 2025 17:48:33 +0100 Subject: [PATCH 2/7] Enable CodeRabbit for feat-sites --- .coderabbit.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .coderabbit.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000000..0b8534b7c9 --- /dev/null +++ b/.coderabbit.yaml @@ -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 \ No newline at end of file From 3f1c4c20959041a79eee5d02cc5a97664ba83761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Mar 2025 11:02:32 +0100 Subject: [PATCH 3/7] Add per-framework screenshot sleep --- app/config/frameworks.php | 12 ++++++++++++ .../Platform/Modules/Functions/Workers/Builds.php | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/config/frameworks.php b/app/config/frameworks.php index e1b31a28ec..cc9e913523 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -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' => [ diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 15e0eb985c..a302f2f79d 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -784,12 +784,12 @@ class Builds extends Action 'x-appwrite-key' => API_KEY_DYNAMIC . '_' . $apiKey ]); - $config['sleep'] = 3000; // 3 seconds - - // Makes tests much faster - $isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development'; - if ($isDevelopment) { - $config['sleep'] = 0; // Override this when running Screenshot.php task + $config['sleep'] = 3000; + + $frameworks = Config::getParam('frameworks', []); + $framework = $frameworks[$resource->getAttribute('framework', '')] ?? null; + if (!is_null($framework)) { + $config['sleep'] = $framework['screenshotSleep']; } $response = $client->fetch( From ef163e851721fea475071d90e44720b9f0be2768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Mar 2025 12:01:30 +0100 Subject: [PATCH 4/7] Add screenshots to site --- app/config/collections/projects.php | 23 +++++++++++++++++++ .../Modules/Functions/Workers/Builds.php | 4 +++- .../Modules/Sites/Http/Deployments/Delete.php | 2 ++ .../Sites/Http/Sites/Deployment/Update.php | 2 ++ src/Appwrite/Utopia/Response/Model/Site.php | 12 ++++++++++ .../Services/Sites/SitesCustomServerTest.php | 6 ++++- 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 3ef817cd73..c2228f6a4c 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1003,6 +1003,29 @@ return [ 'array' => false, 'filters' => [], ], + + [ + '$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, diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 84328f9e6e..1af57fd4e3 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -788,7 +788,7 @@ class Builds extends Action ]); $config['sleep'] = 3000; - + $frameworks = Config::getParam('frameworks', []); $framework = $frameworks[$resource->getAttribute('framework', '')] ?? null; if (!is_null($framework)) { @@ -898,6 +898,8 @@ 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 = $dbForProject->updateDocument('sites', $resource->getId(), $resource); $queries = [ Query::equal("projectInternalId", [$project->getInternalId()]), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php index ab3b17c8bd..56b601d302 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php @@ -100,6 +100,8 @@ class Delete extends Action $site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [ 'deploymentId' => '', 'deploymentInternalId' => '', + 'deploymentScreenshotDark' => '', + 'deploymentScreenshotLight' => '', ]))); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php index 9498a3f799..403579d8fd 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php @@ -90,6 +90,8 @@ 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', ''), ]))); $queries = [ diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index 9a760a3e2a..b756e5f1eb 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -58,6 +58,18 @@ class Site extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) + ->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.', diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index b04e5e3a65..36a688ed4d 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1816,11 +1816,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())); From 7cade1a27df4a7d686d5d423caf9bb389b57da9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Mar 2025 12:44:21 +0100 Subject: [PATCH 5/7] Add active deployment status and creation date --- app/config/collections/projects.php | 45 ++++++++++++++++++- .../Functions/Http/Deployments/Delete.php | 2 + .../Http/Functions/Deployment/Update.php | 2 + .../Modules/Functions/Workers/Builds.php | 4 ++ .../Modules/Sites/Http/Deployments/Delete.php | 2 + .../Sites/Http/Sites/Deployment/Update.php | 2 + src/Appwrite/Utopia/Response/Model/Func.php | 12 +++++ src/Appwrite/Utopia/Response/Model/Site.php | 12 +++++ .../Functions/FunctionsCustomServerTest.php | 9 ++++ .../Services/Sites/SitesCustomServerTest.php | 9 ++++ 10 files changed, 98 insertions(+), 1 deletion(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index c2228f6a4c..a8a1d34e14 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -579,6 +579,28 @@ return [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('deploymentStatus'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => '', + '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,7 +1025,28 @@ return [ 'array' => false, 'filters' => [], ], - + [ + '$id' => ID::custom('deploymentStatus'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => '', + '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, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php index ec4a90f426..eb1ac6ae50 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php @@ -100,6 +100,8 @@ class Delete extends Action $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ 'deploymentId' => '', 'deploymentInternalId' => '', + 'deploymentStatus' => '', + 'deploymentCreatedAt' => '', ]))); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php index 42608ab47e..088237d58c 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php @@ -93,6 +93,8 @@ class Update extends Base $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ 'deploymentInternalId' => $deployment->getInternalId(), 'deploymentId' => $deployment->getId(), + 'deploymentStatus' => $deployment->getAttribute('status', ''), + 'deploymentCreatedAt' => $deployment->getCreatedAt(), ]))); // Inform scheduler if function is still active diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 1af57fd4e3..cbc41c5df7 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -868,6 +868,8 @@ class Builds extends Action $resource->setAttribute('deploymentId', $deployment->getId()); $resource->setAttribute('deploymentInternalId', $deployment->getInternalId()); + $resource->setAttribute('deploymentStatus', $deployment->getAttribute('status', '')); + $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); $resource = $dbForProject->updateDocument('functions', $resource->getId(), $resource); $queries = [ @@ -900,6 +902,8 @@ class Builds extends Action $resource->setAttribute('deploymentInternalId', $deployment->getInternalId()); $resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', '')); $resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', '')); + $resource->setAttribute('deploymentStatus', $deployment->getAttribute('status', '')); + $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); $queries = [ Query::equal("projectInternalId", [$project->getInternalId()]), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php index 56b601d302..fac61616d0 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php @@ -102,6 +102,8 @@ class Delete extends Action 'deploymentInternalId' => '', 'deploymentScreenshotDark' => '', 'deploymentScreenshotLight' => '', + 'deploymentStatus' => '', + 'deploymentCreatedAt' => '', ]))); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php index 403579d8fd..5cd7f6fbd8 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php @@ -92,6 +92,8 @@ class Update extends Base 'deploymentId' => $deployment->getId(), 'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''), 'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''), + 'deploymentStatus' => $deployment->getAttribute('status', ''), + 'deploymentCreatedAt' => $deployment->getCreatedAt(), ]))); $queries = [ diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index bf16f91b59..40a9b77c2b 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -71,6 +71,18 @@ 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('deploymentStatus', [ + 'type' => self::TYPE_STRING, + 'description' => 'Active deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".', + 'default' => '', + 'example' => 'ready', + ]) ->addRule('scopes', [ 'type' => self::TYPE_STRING, 'description' => 'Allowed permission scopes.', diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index b756e5f1eb..c5caf4e76e 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -58,6 +58,18 @@ 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('deploymentStatus', [ + 'type' => self::TYPE_STRING, + 'description' => 'Active deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".', + 'default' => '', + 'example' => 'ready', + ]) ->addRule('deploymentScreenshotLight', [ 'type' => self::TYPE_STRING, 'description' => 'Screenshot of active deployment with light theme preference file ID.', diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index b238ba2768..3d2cfbd597 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -493,6 +493,15 @@ class FunctionsCustomServerTest extends Scope $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']['deploymentStatus']); + $this->assertNotEmpty($function['body']['deploymentCreatedAt']); + $this->assertEquals($deployment['body']['$id'], $function['body']['deploymentId']); + $this->assertEquals($deployment['body']['status'], $function['body']['deploymentStatus']); + $this->assertEquals($deployment['body']['$createdAt'], $function['body']['deploymentCreatedAt']); + $function = $this->cleanupFunction($functionId); } diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 36a688ed4d..d09bc42d4b 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -367,6 +367,15 @@ class SitesCustomServerTest extends Scope $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']['deploymentStatus']); + $this->assertNotEmpty($site['body']['deploymentCreatedAt']); + $this->assertEquals($deployment['body']['$id'], $site['body']['deploymentId']); + $this->assertEquals($deployment['body']['status'], $site['body']['deploymentStatus']); + $this->assertEquals($deployment['body']['$createdAt'], $site['body']['deploymentCreatedAt']); + $this->cleanupSite($siteId); } From 1299fffdb24a6aaa511203d5e37584ed7e2a6e65 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:18:08 +0530 Subject: [PATCH 6/7] Fix incorrect URL for git commits --- composer.json | 2 +- composer.lock | 59 +++++++++---------- docker-compose.yml | 2 +- .../Platform/Modules/Compute/Base.php | 6 +- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index dd42aa607c..c25efaca10 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "utopia-php/swoole": "0.8.*", "utopia-php/system": "0.9.*", "utopia-php/telemetry": "0.1.*", - "utopia-php/vcs": "0.9.*", + "utopia-php/vcs": "0.10.*", "utopia-php/websocket": "0.1.*", "matomo/device-detector": "6.1.*", "dragonmantank/cron-expression": "3.3.2", diff --git a/composer.lock b/composer.lock index 92eb37880e..3ac8abaead 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "566b9b71f179c9ff6368dbd353bc20d2", + "content-hash": "eca74b44aa6dc476aa8056344e87f363", "packages": [ { "name": "adhocore/jwt", @@ -3761,16 +3761,16 @@ }, { "name": "utopia-php/detector", - "version": "0.1.1", + "version": "0.1.2", "source": { "type": "git", "url": "https://github.com/utopia-php/detector.git", - "reference": "5dcabbfcf99731f3a37d86b7cb1e93c968baf64b" + "reference": "8617ea205738743ef3363ad95791139e82ae44d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/detector/zipball/5dcabbfcf99731f3a37d86b7cb1e93c968baf64b", - "reference": "5dcabbfcf99731f3a37d86b7cb1e93c968baf64b", + "url": "https://api.github.com/repos/utopia-php/detector/zipball/8617ea205738743ef3363ad95791139e82ae44d5", + "reference": "8617ea205738743ef3363ad95791139e82ae44d5", "shasum": "" }, "require": { @@ -3800,9 +3800,9 @@ ], "support": { "issues": "https://github.com/utopia-php/detector/issues", - "source": "https://github.com/utopia-php/detector/tree/0.1.1" + "source": "https://github.com/utopia-php/detector/tree/0.1.2" }, - "time": "2025-03-08T22:25:49+00:00" + "time": "2025-03-11T13:01:25+00:00" }, { "name": "utopia-php/domains", @@ -4805,16 +4805,16 @@ }, { "name": "utopia-php/telemetry", - "version": "0.1.0", + "version": "0.1.1", "source": { "type": "git", "url": "https://github.com/utopia-php/telemetry.git", - "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80" + "reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", - "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", + "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/437f0021777f0e575dfb9e8a1a081b3aed75e33f", + "reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f", "shasum": "" }, "require": { @@ -4835,7 +4835,7 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\": "src/" + "Utopia\\Telemetry\\": "src/Telemetry" } }, "notification-url": "https://packagist.org/downloads/", @@ -4849,22 +4849,22 @@ ], "support": { "issues": "https://github.com/utopia-php/telemetry/issues", - "source": "https://github.com/utopia-php/telemetry/tree/0.1.0" + "source": "https://github.com/utopia-php/telemetry/tree/0.1.1" }, - "time": "2024-11-13T10:29:53+00:00" + "time": "2025-03-17T11:57:52+00:00" }, { "name": "utopia-php/vcs", - "version": "0.9.4", + "version": "0.10.1", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a" + "reference": "6be02650cc361764900ade8c129f309df263eb74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/1a8d280b176acc99ea8d9e7364b8767cbb206b4a", - "reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/6be02650cc361764900ade8c129f309df263eb74", + "reference": "6be02650cc361764900ade8c129f309df263eb74", "shasum": "" }, "require": { @@ -4882,8 +4882,7 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\VCS\\": "src/VCS", - "Utopia\\Detector\\": "src/Detector" + "Utopia\\VCS\\": "src/VCS" } }, "notification-url": "https://packagist.org/downloads/", @@ -4899,9 +4898,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.9.4" + "source": "https://github.com/utopia-php/vcs/tree/0.10.1" }, - "time": "2025-03-13T10:09:45+00:00" + "time": "2025-03-18T11:44:09+00:00" }, { "name": "utopia-php/websocket", @@ -5088,16 +5087,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.40.7", + "version": "0.40.9", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873" + "reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9e89b0bc4d8e6c81817d27096629f34a149fa873", - "reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/dbb45a5db22cdc3368fe2573c07ba6088f188fa4", + "reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4", "shasum": "" }, "require": { @@ -5133,9 +5132,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.40.7" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.9" }, - "time": "2025-03-12T08:43:55+00:00" + "time": "2025-03-17T18:39:14+00:00" }, { "name": "doctrine/annotations", @@ -8506,7 +8505,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8530,5 +8529,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/docker-compose.yml b/docker-compose.yml index 7a392bca7b..4d6dfaf682 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -205,7 +205,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:5.3.0-sites-rc.26 + image: appwrite/console:5.3.0-sites-rc.27 restart: unless-stopped networks: - appwrite diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 35a2776864..1e70c106a7 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -59,7 +59,6 @@ class Base extends Action } } - $authorUrl = "https://github.com/$owner"; $repositoryUrl = "https://github.com/$owner/$repositoryName"; $deployment = $dbForProject->createDocument('deployments', new Document([ @@ -85,7 +84,7 @@ class Base extends Action 'providerRepositoryOwner' => $owner, 'providerRepositoryUrl' => $repositoryUrl, 'providerCommitHash' => $commitDetails['commitHash'] ?? '', - 'providerCommitAuthorUrl' => $authorUrl, + 'providerCommitAuthorUrl' => $commitDetails['commitAuthorUrl'] ?? '', 'providerCommitAuthor' => $commitDetails['commitAuthor'] ?? '', 'providerCommitMessage' => mb_strimwidth($commitDetails['commitMessage'] ?? '', 0, 255, '...'), 'providerCommitUrl' => $commitDetails['commitUrl'] ?? '', @@ -143,7 +142,6 @@ class Base extends Action } } - $authorUrl = "https://github.com/$owner"; $repositoryUrl = "https://github.com/$owner/$repositoryName"; $commands = []; @@ -177,7 +175,7 @@ class Base extends Action 'providerRepositoryOwner' => $owner, 'providerRepositoryUrl' => $repositoryUrl, 'providerCommitHash' => $commitDetails['commitHash'] ?? '', - 'providerCommitAuthorUrl' => $authorUrl, + 'providerCommitAuthorUrl' => $commitDetails['commitAuthorUrl'] ?? '', 'providerCommitAuthor' => $commitDetails['commitAuthor'] ?? '', 'providerCommitMessage' => mb_strimwidth($commitDetails['commitMessage'] ?? '', 0, 255, '...'), 'providerCommitUrl' => $commitDetails['commitUrl'] ?? '', From 362520ff4ac5571e2c2ea5a13aaa6ac5a774c22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Mar 2025 12:56:44 +0100 Subject: [PATCH 7/7] Remove active depoyment status (not relevant, always ready) --- app/config/collections/projects.php | 22 ------------------- .../Functions/Http/Deployments/Delete.php | 1 - .../Http/Functions/Deployment/Update.php | 1 - .../Modules/Functions/Workers/Builds.php | 2 -- .../Modules/Sites/Http/Deployments/Delete.php | 1 - .../Sites/Http/Sites/Deployment/Update.php | 1 - src/Appwrite/Utopia/Response/Model/Func.php | 6 ----- src/Appwrite/Utopia/Response/Model/Site.php | 6 ----- .../Functions/FunctionsCustomServerTest.php | 2 -- .../Services/Sites/SitesCustomServerTest.php | 2 -- 10 files changed, 44 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index a8a1d34e14..f9a44e169c 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -579,17 +579,6 @@ return [ 'array' => false, 'filters' => [], ], - [ - '$id' => ID::custom('deploymentStatus'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], [ '$id' => ID::custom('deploymentCreatedAt'), 'type' => Database::VAR_DATETIME, @@ -1025,17 +1014,6 @@ return [ 'array' => false, 'filters' => [], ], - [ - '$id' => ID::custom('deploymentStatus'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], [ '$id' => ID::custom('deploymentCreatedAt'), 'type' => Database::VAR_DATETIME, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php index eb1ac6ae50..27eded178a 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php @@ -100,7 +100,6 @@ class Delete extends Action $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ 'deploymentId' => '', 'deploymentInternalId' => '', - 'deploymentStatus' => '', 'deploymentCreatedAt' => '', ]))); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php index 088237d58c..c957a688e2 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php @@ -93,7 +93,6 @@ class Update extends Base $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ 'deploymentInternalId' => $deployment->getInternalId(), 'deploymentId' => $deployment->getId(), - 'deploymentStatus' => $deployment->getAttribute('status', ''), 'deploymentCreatedAt' => $deployment->getCreatedAt(), ]))); diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index cbc41c5df7..16b2e08be1 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -868,7 +868,6 @@ class Builds extends Action $resource->setAttribute('deploymentId', $deployment->getId()); $resource->setAttribute('deploymentInternalId', $deployment->getInternalId()); - $resource->setAttribute('deploymentStatus', $deployment->getAttribute('status', '')); $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); $resource = $dbForProject->updateDocument('functions', $resource->getId(), $resource); @@ -902,7 +901,6 @@ class Builds extends Action $resource->setAttribute('deploymentInternalId', $deployment->getInternalId()); $resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', '')); $resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', '')); - $resource->setAttribute('deploymentStatus', $deployment->getAttribute('status', '')); $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); $queries = [ diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php index fac61616d0..00342a7667 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php @@ -102,7 +102,6 @@ class Delete extends Action 'deploymentInternalId' => '', 'deploymentScreenshotDark' => '', 'deploymentScreenshotLight' => '', - 'deploymentStatus' => '', 'deploymentCreatedAt' => '', ]))); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php index 5cd7f6fbd8..7cfe1a50a2 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php @@ -92,7 +92,6 @@ class Update extends Base 'deploymentId' => $deployment->getId(), 'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''), 'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''), - 'deploymentStatus' => $deployment->getAttribute('status', ''), 'deploymentCreatedAt' => $deployment->getCreatedAt(), ]))); diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index 40a9b77c2b..5d937ab075 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -77,12 +77,6 @@ class Func extends Model 'default' => '', 'example' => self::TYPE_DATETIME_EXAMPLE, ]) - ->addRule('deploymentStatus', [ - 'type' => self::TYPE_STRING, - 'description' => 'Active deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".', - 'default' => '', - 'example' => 'ready', - ]) ->addRule('scopes', [ 'type' => self::TYPE_STRING, 'description' => 'Allowed permission scopes.', diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index c5caf4e76e..fad4856f3e 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -64,12 +64,6 @@ class Site extends Model 'default' => '', 'example' => self::TYPE_DATETIME_EXAMPLE, ]) - ->addRule('deploymentStatus', [ - 'type' => self::TYPE_STRING, - 'description' => 'Active deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".', - 'default' => '', - 'example' => 'ready', - ]) ->addRule('deploymentScreenshotLight', [ 'type' => self::TYPE_STRING, 'description' => 'Screenshot of active deployment with light theme preference file ID.', diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 3d2cfbd597..e13e7f9147 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -496,10 +496,8 @@ class FunctionsCustomServerTest extends Scope $function = $this->getFunction($functionId); $this->assertEquals(200, $function['headers']['status-code']); $this->assertNotEmpty($function['body']['deploymentId']); - $this->assertNotEmpty($function['body']['deploymentStatus']); $this->assertNotEmpty($function['body']['deploymentCreatedAt']); $this->assertEquals($deployment['body']['$id'], $function['body']['deploymentId']); - $this->assertEquals($deployment['body']['status'], $function['body']['deploymentStatus']); $this->assertEquals($deployment['body']['$createdAt'], $function['body']['deploymentCreatedAt']); $function = $this->cleanupFunction($functionId); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index d09bc42d4b..c1609bfb80 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -370,10 +370,8 @@ class SitesCustomServerTest extends Scope $site = $this->getSite($siteId); $this->assertEquals(200, $site['headers']['status-code']); $this->assertNotEmpty($site['body']['deploymentId']); - $this->assertNotEmpty($site['body']['deploymentStatus']); $this->assertNotEmpty($site['body']['deploymentCreatedAt']); $this->assertEquals($deployment['body']['$id'], $site['body']['deploymentId']); - $this->assertEquals($deployment['body']['status'], $site['body']['deploymentStatus']); $this->assertEquals($deployment['body']['$createdAt'], $site['body']['deploymentCreatedAt']); $this->cleanupSite($siteId);