From 6bf9adfb5140972dca4a0a29af22e62f46eae458 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 2 Jan 2025 02:21:30 +0530 Subject: [PATCH 01/13] Added some sites tests --- tests/e2e/Scopes/ProjectCustom.php | 2 + tests/e2e/Services/Sites/SitesBase.php | 198 +++++++++++++ .../Services/Sites/SitesCustomServerTest.php | 272 ++++++++++++++++++ 3 files changed, 472 insertions(+) create mode 100644 tests/e2e/Services/Sites/SitesBase.php create mode 100644 tests/e2e/Services/Sites/SitesCustomServerTest.php diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index 7f84ace6f2..35ef605a1a 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -76,6 +76,8 @@ trait ProjectCustom 'buckets.write', 'functions.read', 'functions.write', + 'sites.read', + 'sites.write', 'execution.read', 'execution.write', 'locale.read', diff --git a/tests/e2e/Services/Sites/SitesBase.php b/tests/e2e/Services/Sites/SitesBase.php new file mode 100644 index 0000000000..1a3fec86c6 --- /dev/null +++ b/tests/e2e/Services/Sites/SitesBase.php @@ -0,0 +1,198 @@ +client->call(Client::METHOD_POST, '/sites', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]), $params); + + $this->assertEquals($site['headers']['status-code'], 201, 'Setup site failed with status code: ' . $site['headers']['status-code'] . ' and response: ' . json_encode($site['body'], JSON_PRETTY_PRINT)); + + $siteId = $site['body']['$id']; + + return $siteId; + } + + protected function setupDeployment(string $siteId, mixed $params): string + { + $deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]), $params); + $this->assertEquals($deployment['headers']['status-code'], 202, 'Setup deployment failed with status code: ' . $deployment['headers']['status-code'] . ' and response: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $deploymentId = $deployment['body']['$id'] ?? ''; + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ])); + $this->assertEquals('ready', $deployment['body']['status'], 'Deployment status is not ready, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + }, 50000, 500); + + return $deploymentId; + } + + protected function cleanupSite(string $siteId): void + { + $site = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ])); + + $this->assertEquals($site['headers']['status-code'], 204); + } + + protected function createSite(mixed $params): mixed + { + $site = $this->client->call(Client::METHOD_POST, '/sites', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $site; + } + + protected function createVariable(string $siteId, mixed $params): mixed + { + $variable = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/variables', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $variable; + } + + protected function getSite(string $siteId): mixed + { + $site = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + return $site; + } + + protected function getDeployment(string $siteId, string $deploymentId): mixed + { + $deployment = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + return $deployment; + } + + protected function getLog(string $siteId, $logId): mixed + { + $log = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/logs/' . $logId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + return $log; + } + + protected function listSites(mixed $params = []): mixed + { + $sites = $this->client->call(Client::METHOD_GET, '/sites', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $sites; + } + + protected function listDeployments(string $siteId, $params = []): mixed + { + $deployments = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/deployments', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $deployments; + } + + protected function listLogs(string $siteId, mixed $params = []): mixed + { + $logs = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $logs; + } + + protected function packageSite(string $site): CURLFile + { + $folderPath = realpath(__DIR__ . '/../../../resources/sites') . "/$site"; + $tarPath = "$folderPath/code.tar.gz"; + + Console::execute("cd $folderPath && tar --exclude code.tar.gz -czf code.tar.gz .", '', $this->stdout, $this->stderr); + + if (filesize($tarPath) > 1024 * 1024 * 5) { + throw new \Exception('Code package is too large. Use the chunked upload method instead.'); + } + + return new CURLFile($tarPath, 'application/x-gzip', \basename($tarPath)); + } + + protected function createDeployment(string $siteId, mixed $params = []): mixed + { + $deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $deployment; + } + + protected function getSiteUsage(string $siteId, mixed $params): mixed + { + $usage = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/usage', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $usage; + } + + protected function getTemplate(string $templateId) + { + $template = $this->client->call(Client::METHOD_GET, '/sites/templates/' . $templateId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + return $template; + } + + protected function deleteSite(string $siteId): mixed + { + $site = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + return $site; + } +} diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php new file mode 100644 index 0000000000..f6c0bca889 --- /dev/null +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -0,0 +1,272 @@ +createSite([ + 'adapter' => 'ssr', + 'buildCommand' => 'npm run build', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'nextjs', + 'installCommand' => 'npm install', + 'name' => 'Test Site', + 'outputDirectory' => './.next', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique(), + 'templateOwner' => 'appwrite', + 'templateRepository' => 'templates-for-sites', + 'templateRootDirectory' => './nextjs/starter', + 'templateVersion' => '0.2.*' + ]); + + $siteId = $site['body']['$id'] ?? ''; + + $dateValidator = new DateTimeValidator(); + $this->assertEquals(201, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals('Test Site', $site['body']['name']); + $this->assertEquals('nextjs', $site['body']['framework']); + $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); + $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); + $this->assertEquals('ssr', $site['body']['adapter']); + $this->assertEquals('npm run build', $site['body']['buildCommand']); + $this->assertEquals('node-22', $site['body']['buildRuntime']); + $this->assertEquals(null, $site['body']['fallbackFile']); + $this->assertEquals('npm install', $site['body']['installCommand']); + $this->assertEquals('./.next', $site['body']['outputDirectory']); + $this->assertEquals('main', $site['body']['providerBranch']); + $this->assertEquals('./', $site['body']['providerRootDirectory']); + + $variable = $this->createVariable($siteId, [ + 'key' => 'siteKey1', + 'value' => 'siteValue1', + ]); + $variable2 = $this->createVariable($siteId, [ + 'key' => 'siteKey2', + 'value' => 'siteValue2', + ]); + $variable3 = $this->createVariable($siteId, [ + 'key' => 'siteKey3', + 'value' => 'siteValue3', + ]); + + $this->assertEquals(201, $variable['headers']['status-code']); + $this->assertEquals(201, $variable2['headers']['status-code']); + $this->assertEquals(201, $variable3['headers']['status-code']); + + $this->cleanupSite($siteId); + } + + public function testListSites(): void + { + /** + * Test for SUCCESS + */ + $siteId = $this->setupSite([ + 'adapter' => 'ssr', + 'buildCommand' => 'npm run build', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'nextjs', + 'installCommand' => 'npm install', + 'name' => 'Test Site', + 'outputDirectory' => './.next', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique(), + 'templateOwner' => 'appwrite', + 'templateRepository' => 'templates-for-sites', + 'templateRootDirectory' => './nextjs/starter', + 'templateVersion' => '0.2.*' + ]); + + $sites = $this->listSites([ + 'search' => $siteId, + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(1, $sites['body']['sites']); + $this->assertEquals($sites['body']['sites'][0]['name'], 'Test Site'); + + // Test pagination limit + $sites = $this->listSites([ + 'queries' => [ + Query::limit(1)->toString(), + ], + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(1, $sites['body']['sites']); + + // Test pagination offset + $sites = $this->listSites([ + 'queries' => [ + Query::offset(1)->toString(), + ], + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(0, $sites['body']['sites']); + + // Test filter enabled + $sites = $this->listSites([ + 'queries' => [ + Query::equal('enabled', [true])->toString(), + ], + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(1, $sites['body']['sites']); + + // Test filter disabled + $sites = $this->listSites([ + 'queries' => [ + Query::equal('enabled', [false])->toString(), + ], + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(0, $sites['body']['sites']); + + // Test search name + $sites = $this->listSites([ + 'search' => 'Test' + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(1, $sites['body']['sites']); + $this->assertEquals($sites['body']['sites'][0]['$id'], $siteId); + + // Test search framework + $sites = $this->listSites([ + 'search' => 'nextjs' + ]); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertCount(1, $sites['body']['sites']); + $this->assertEquals($sites['body']['sites'][0]['$id'], $siteId); + + /** + * Test pagination + */ + $siteId2 = $this->setupSite([ + 'adapter' => 'ssr', + 'buildCommand' => 'npm run build', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'nextjs', + 'installCommand' => 'npm install', + 'name' => 'Test Site 2', + 'outputDirectory' => './.next', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique(), + 'templateOwner' => 'appwrite', + 'templateRepository' => 'templates-for-sites', + 'templateRootDirectory' => './nextjs/starter', + 'templateVersion' => '0.2.*' + ]); + + $sites = $this->listSites(); + + $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals($sites['body']['total'], 2); + $this->assertIsArray($sites['body']['sites']); + $this->assertCount(2, $sites['body']['sites']); + $this->assertEquals($sites['body']['sites'][0]['name'], 'Test Site'); + $this->assertEquals($sites['body']['sites'][1]['name'], 'Test Site 2'); + + $sites1 = $this->listSites([ + 'queries' => [ + Query::cursorAfter(new Document(['$id' => $sites['body']['sites'][0]['$id']]))->toString(), + ], + ]); + + $this->assertEquals($sites1['headers']['status-code'], 200); + $this->assertCount(1, $sites1['body']['sites']); + $this->assertEquals($sites1['body']['sites'][0]['name'], 'Test Site 2'); + + $sites2 = $this->listSites([ + 'queries' => [ + Query::cursorBefore(new Document(['$id' => $sites['body']['sites'][1]['$id']]))->toString(), + ], + ]); + + $this->assertEquals($sites2['headers']['status-code'], 200); + $this->assertCount(1, $sites2['body']['sites']); + $this->assertEquals($sites2['body']['sites'][0]['name'], 'Test Site'); + + /** + * Test for FAILURE + */ + $sites = $this->listSites([ + 'queries' => [ + Query::cursorAfter(new Document(['$id' => 'unknown']))->toString(), + ], + ]); + $this->assertEquals($sites['headers']['status-code'], 400); + + $this->cleanupSite($siteId); + $this->cleanupSite($siteId2); + } + + public function testGetSite(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'ssr', + 'buildCommand' => 'npm run build', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'nextjs', + 'installCommand' => 'npm install', + 'name' => 'Test Site', + 'outputDirectory' => './.next', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique(), + 'templateOwner' => 'appwrite', + 'templateRepository' => 'templates-for-sites', + 'templateRootDirectory' => './nextjs/starter', + 'templateVersion' => '0.2.*' + ]); + + $this->assertNotNull($siteId); + + /** + * Test for SUCCESS + */ + $site = $this->getSite($siteId); + + $this->assertEquals($site['headers']['status-code'], 200); + $this->assertEquals($site['body']['name'], 'Test Site'); + + /** + * Test for FAILURE + */ + $site = $this->getSite('x'); + + $this->assertEquals($site['headers']['status-code'], 404); + + $this->cleanupSite($siteId); + } +} From 0929ba995a115b739d2b2b5f0283a5a8c6e9762a Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 7 Jan 2025 02:33:32 +0530 Subject: [PATCH 02/13] More tests --- .env | 2 +- app/config/site-templates.php | 6 +- tests/e2e/Services/Sites/SitesBase.php | 24 +- .../Services/Sites/SitesCustomServerTest.php | 541 ++++++++++++++++-- tests/resources/sites/other/code.tar.gz | Bin 0 -> 605 bytes tests/resources/sites/other/index.html | 42 ++ 6 files changed, 563 insertions(+), 52 deletions(-) create mode 100644 tests/resources/sites/other/code.tar.gz create mode 100644 tests/resources/sites/other/index.html diff --git a/.env b/.env index 2d2e335186..04343ed720 100644 --- a/.env +++ b/.env @@ -80,7 +80,7 @@ _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://exc1/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 _APP_SITES_RUNTIMES=static-1,node-22,flutter-3.24 -_APP_SITES_FRAMEWORKS=sveltekit,nextjs,nuxt,astro,remix,static,flutter # TODO: Angular +_APP_SITES_FRAMEWORKS=sveltekit,nextjs,nuxt,astro,remix,static,flutter,other # TODO: Angular _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 diff --git a/app/config/site-templates.php b/app/config/site-templates.php index 79bccc0e2c..40edc4a714 100644 --- a/app/config/site-templates.php +++ b/app/config/site-templates.php @@ -135,12 +135,12 @@ return [ 'demoImage' => 'https://qa17.appwrite.org/console/images/sites/templates/astro-starter.png', 'frameworks' => [ getFramework('ASTRO', [ - 'providerRootDirectory' => './', + 'providerRootDirectory' => './astro/starter', ]), ], 'vcsProvider' => 'github', - 'providerRepositoryId' => 'astro-ssr-test-template', - 'providerOwner' => 'Meldiron', + 'providerRepositoryId' => 'templates-for-sites', + 'providerOwner' => 'appwrite', 'providerVersion' => '0.2.*', 'variables' => [], ], diff --git a/tests/e2e/Services/Sites/SitesBase.php b/tests/e2e/Services/Sites/SitesBase.php index 1a3fec86c6..2e9f69a243 100644 --- a/tests/e2e/Services/Sites/SitesBase.php +++ b/tests/e2e/Services/Sites/SitesBase.php @@ -62,6 +62,17 @@ trait SitesBase $this->assertEquals($site['headers']['status-code'], 204); } + protected function cleanupDeployment(string $siteId, string $deploymentId): void + { + $deployment = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ])); + + $this->assertEquals($deployment['headers']['status-code'], 204); + } + protected function createSite(mixed $params): mixed { $site = $this->client->call(Client::METHOD_POST, '/sites', array_merge([ @@ -72,6 +83,16 @@ trait SitesBase return $site; } + protected function updateSite(mixed $params): mixed + { + $site = $this->client->call(Client::METHOD_PUT, '/sites/' . $params['$id'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), $params); + + return $site; + } + protected function createVariable(string $siteId, mixed $params): mixed { $variable = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/variables', array_merge([ @@ -179,8 +200,7 @@ trait SitesBase protected function getTemplate(string $templateId) { $template = $this->client->call(Client::METHOD_GET, '/sites/templates/' . $templateId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], + 'content-type' => 'application/json' ], $this->getHeaders())); return $template; diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index f6c0bca889..740dfd6a23 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2,6 +2,7 @@ namespace Tests\E2E\Services\Sites; +use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; @@ -22,21 +23,15 @@ class SitesCustomServerTest extends Scope * Test for SUCCESS */ $site = $this->createSite([ - 'adapter' => 'ssr', - 'buildCommand' => 'npm run build', + 'adapter' => 'static', 'buildRuntime' => 'node-22', 'fallbackFile' => null, - 'framework' => 'nextjs', - 'installCommand' => 'npm install', + 'framework' => 'other', 'name' => 'Test Site', - 'outputDirectory' => './.next', + 'outputDirectory' => './', 'providerBranch' => 'main', 'providerRootDirectory' => './', - 'siteId' => ID::unique(), - 'templateOwner' => 'appwrite', - 'templateRepository' => 'templates-for-sites', - 'templateRootDirectory' => './nextjs/starter', - 'templateVersion' => '0.2.*' + 'siteId' => ID::unique() ]); $siteId = $site['body']['$id'] ?? ''; @@ -45,15 +40,13 @@ class SitesCustomServerTest extends Scope $this->assertEquals(201, $site['headers']['status-code']); $this->assertNotEmpty($site['body']['$id']); $this->assertEquals('Test Site', $site['body']['name']); - $this->assertEquals('nextjs', $site['body']['framework']); + $this->assertEquals('other', $site['body']['framework']); $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); - $this->assertEquals('ssr', $site['body']['adapter']); - $this->assertEquals('npm run build', $site['body']['buildCommand']); + $this->assertEquals('static', $site['body']['adapter']); $this->assertEquals('node-22', $site['body']['buildRuntime']); $this->assertEquals(null, $site['body']['fallbackFile']); - $this->assertEquals('npm install', $site['body']['installCommand']); - $this->assertEquals('./.next', $site['body']['outputDirectory']); + $this->assertEquals('./', $site['body']['outputDirectory']); $this->assertEquals('main', $site['body']['providerBranch']); $this->assertEquals('./', $site['body']['providerRootDirectory']); @@ -83,21 +76,15 @@ class SitesCustomServerTest extends Scope * Test for SUCCESS */ $siteId = $this->setupSite([ - 'adapter' => 'ssr', - 'buildCommand' => 'npm run build', + 'adapter' => 'static', 'buildRuntime' => 'node-22', 'fallbackFile' => null, - 'framework' => 'nextjs', - 'installCommand' => 'npm install', + 'framework' => 'other', 'name' => 'Test Site', - 'outputDirectory' => './.next', + 'outputDirectory' => './', 'providerBranch' => 'main', 'providerRootDirectory' => './', - 'siteId' => ID::unique(), - 'templateOwner' => 'appwrite', - 'templateRepository' => 'templates-for-sites', - 'templateRootDirectory' => './nextjs/starter', - 'templateVersion' => '0.2.*' + 'siteId' => ID::unique() ]); $sites = $this->listSites([ @@ -159,7 +146,7 @@ class SitesCustomServerTest extends Scope // Test search framework $sites = $this->listSites([ - 'search' => 'nextjs' + 'search' => 'other' ]); $this->assertEquals($sites['headers']['status-code'], 200); @@ -170,21 +157,15 @@ class SitesCustomServerTest extends Scope * Test pagination */ $siteId2 = $this->setupSite([ - 'adapter' => 'ssr', - 'buildCommand' => 'npm run build', + 'adapter' => 'static', 'buildRuntime' => 'node-22', 'fallbackFile' => null, - 'framework' => 'nextjs', - 'installCommand' => 'npm install', + 'framework' => 'other', 'name' => 'Test Site 2', - 'outputDirectory' => './.next', + 'outputDirectory' => './', 'providerBranch' => 'main', 'providerRootDirectory' => './', - 'siteId' => ID::unique(), - 'templateOwner' => 'appwrite', - 'templateRepository' => 'templates-for-sites', - 'templateRootDirectory' => './nextjs/starter', - 'templateVersion' => '0.2.*' + 'siteId' => ID::unique() ]); $sites = $this->listSites(); @@ -233,21 +214,15 @@ class SitesCustomServerTest extends Scope public function testGetSite(): void { $siteId = $this->setupSite([ - 'adapter' => 'ssr', - 'buildCommand' => 'npm run build', + 'adapter' => 'static', 'buildRuntime' => 'node-22', 'fallbackFile' => null, - 'framework' => 'nextjs', - 'installCommand' => 'npm install', + 'framework' => 'other', 'name' => 'Test Site', - 'outputDirectory' => './.next', + 'outputDirectory' => './', 'providerBranch' => 'main', 'providerRootDirectory' => './', - 'siteId' => ID::unique(), - 'templateOwner' => 'appwrite', - 'templateRepository' => 'templates-for-sites', - 'templateRootDirectory' => './nextjs/starter', - 'templateVersion' => '0.2.*' + 'siteId' => ID::unique() ]); $this->assertNotNull($siteId); @@ -269,4 +244,478 @@ class SitesCustomServerTest extends Scope $this->cleanupSite($siteId); } + + public function testUpdateSite(): void + { + $site = $this->createSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $siteId = $site['body']['$id'] ?? ''; + + $this->assertEquals(201, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals('Test Site', $site['body']['name']); + + $site = $this->updateSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site Updated', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + '$id' => $siteId, + 'installCommand' => 'npm install' + ]); + + $dateValidator = new DatetimeValidator(); + + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals('Test Site Updated', $site['body']['name']); + $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); + $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); + $this->assertEquals('npm install', $site['body']['installCommand']); + + $this->cleanupSite($siteId); + } + + // public function testCreateDeploymentFromCLI() { + // // TODO: Implement testCreateDeploymentFromCLI() later + // } + + // public function testCreateSiteAndDeploymentFromTemplate() + // { + // $starterTemplate = $this->getTemplate('nextjs-starter'); + // $this->assertEquals(200, $starterTemplate['headers']['status-code']); + + // $nextjsFramework = array_values(array_filter($starterTemplate['body']['frameworks'], function ($framework) { + // return $framework['key'] === 'nextjs'; + // }))[0]; + + // // If this fails, the template has variables, and this test needs to be updated + // $this->assertEmpty($starterTemplate['body']['variables']); + + // var_dump("creating site"); + + // $site = $this->createSite( + // [ + // 'siteId' => ID::unique(), + // 'name' => $starterTemplate['body']['name'], + // 'framework' => $nextjsFramework['key'], + // 'adapter' => $nextjsFramework['adapter'], + // 'buildCommand' => $nextjsFramework['buildCommand'], + // 'buildRuntime' => $nextjsFramework['buildRuntime'], + // 'fallbackFile' => $nextjsFramework['fallbackFile'], + // 'installCommand' => $nextjsFramework['installCommand'], + // 'outputDirectory' => $nextjsFramework['outputDirectory'], + // 'providerRootDirectory' => $nextjsFramework['providerRootDirectory'], + // 'templateOwner' => $starterTemplate['body']['providerOwner'], + // 'templateRepository' => $starterTemplate['body']['providerRepositoryId'], + // 'templateRootDirectory' => $nextjsFramework['providerRootDirectory'], + // 'templateVersion' => $starterTemplate['body']['providerVersion'], + // 'providerBranch' => 'main', + // ] + // ); + + // $this->assertEquals(201, $site['headers']['status-code']); + // $this->assertNotEmpty($site['body']['$id']); + + // $siteId = $site['body']['$id'] ?? ''; + // var_dump("Site id"); + + // $deployments = $this->listDeployments($siteId); + + // var_dump($deployments); + + // $this->assertEquals(200, $deployments['headers']['status-code']); + // $this->assertEquals(1, $deployments['body']['total']); + + // $lastDeployment = $deployments['body']['deployments'][0]; + + // $this->assertNotEmpty($lastDeployment['$id']); + // $this->assertEquals(0, $lastDeployment['size']); + + // $deploymentId = $lastDeployment['$id']; + // var_dump("flow reached here"); + + // $this->assertEventually(function () use ($siteId, $deploymentId) { + // $deployment = $this->getDeployment($siteId, $deploymentId); + + // $this->assertEquals(200, $deployment['headers']['status-code']); + // // assert that deployment is ready or failed + // $this->assertContains($deployment['body']['status'], ['ready', 'failed']); + // }, 300000, 1000); + + // var_dump("flow reached here 2"); + + // $site = $this->getSite($siteId); + // $deployment = $this->getDeployment($siteId, $deploymentId); + + // $this->assertEquals(200, $site['headers']['status-code']); + // var_dump($deployment); + + // // $this->cleanupSite($siteId); + // } + + public function testCreateDeployment() + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'siteId' => $siteId, + 'code' => $this->packageSite('other'), + 'activate' => true, + ]); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + $this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt'])); + + $deploymentIdActive = $deployment['body']['$id'] ?? ''; + + $this->assertEventually(function () use ($siteId, $deploymentIdActive) { + $deployment = $this->getDeployment($siteId, $deploymentIdActive); + + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + + $deploymentIdInactive = $deployment['body']['$id'] ?? ''; + + $this->assertEventually(function () use ($siteId, $deploymentIdInactive) { + $deployment = $this->getDeployment($siteId, $deploymentIdInactive); + + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + $site = $this->getSite($siteId); + + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentIdActive, $site['body']['deploymentId']); + $this->assertNotEquals($deploymentIdInactive, $site['body']['deploymentId']); + + $this->cleanupDeployment($siteId, $deploymentIdActive); + $this->cleanupDeployment($siteId, $deploymentIdInactive); + $this->cleanupSite($siteId); + } + + public function testCancelDeploymentBuild(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $deploymentId = $deployment['body']['$id'] ?? ''; + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + $this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt'])); + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertEquals('building', $deployment['body']['status']); + }, 100000, 250); + + // Cancel the deployment + $cancel = $this->client->call(Client::METHOD_PATCH, '/sites/' . $siteId . '/deployments/' . $deploymentId . '/build', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $cancel['headers']['status-code']); + $this->assertEquals('canceled', $cancel['body']['status']); + + /** + * Build worker still runs the build. + * 30s sleep gives worker enough time to finish build. + * After build finished, it should still be canceled, not ready. + */ + \sleep(30); + + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertEquals('canceled', $deployment['body']['status']); + + $this->cleanupDeployment($siteId, $deploymentId); + $this->cleanupSite($siteId); + } + + public function testUpdateDeployment(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $deploymentId = $deployment['body']['$id'] ?? ''; + $this->assertEquals(202, $deployment['headers']['status-code']); + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + /** + * Test for SUCCESS + */ + $dateValidator = new DatetimeValidator(); + + $response = $this->client->call(Client::METHOD_PATCH, '/sites/' . $siteId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']['$id']); + $this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt'])); + $this->assertEquals(true, $dateValidator->isValid($response['body']['$updatedAt'])); + $this->assertEquals($deploymentId, $response['body']['deploymentId']); + + $this->cleanupDeployment($siteId, $deploymentId); + $this->cleanupSite($siteId); + } + + public function testListDeployments(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $deploymentIdActive = $deployment['body']['$id'] ?? ''; + $this->assertEquals(202, $deployment['headers']['status-code']); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + + $deploymentIdInactive = $deployment['body']['$id'] ?? ''; + + $deployments = $this->listDeployments($siteId); + + var_dump($deployments); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals($deployments['body']['total'], 2); + $this->assertIsArray($deployments['body']['deployments']); + $this->assertCount(2, $deployments['body']['deployments']); + $this->assertArrayHasKey('size', $deployments['body']['deployments'][0]); + $this->assertArrayHasKey('buildSize', $deployments['body']['deployments'][0]); + + $deployments = $this->listDeployments($siteId, [ + 'queries' => [ + Query::limit(1)->toString(), + ], + ]); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertCount(1, $deployments['body']['deployments']); + + $deployments = $this->listDeployments($siteId, [ + 'queries' => [ + Query::offset(1)->toString(), + ], + ]); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertCount(1, $deployments['body']['deployments']); + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::equal('type', ['manual'])->toString(), + ], + ] + ); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(2, $deployments['body']['total']); + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::equal('type', ['vcs'])->toString(), + ], + ] + ); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(0, $deployments['body']['total']); + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::equal('type', ['invalid-string'])->toString(), + ], + ] + ); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(0, $deployments['body']['total']); + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::greaterThan('size', 10000)->toString(), + ], + ] + ); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(0, $deployments['body']['total']); + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::greaterThan('size', 0)->toString(), + ], + ] + ); + + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(2, $deployments['body']['total']); + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::greaterThan('size', -100)->toString(), + ], + ] + ); + $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(2, $deployments['body']['total']); + + /** + * Ensure size output and size filters work exactly. + * Prevents buildSize being counted towards deployment size + */ + $deployments = $this->listDeployments( + $siteId, + [ + Query::limit(1)->toString(), + ] + ); + + $this->assertEquals(200, $deployments['headers']['status-code']); + $this->assertGreaterThanOrEqual(1, $deployments['body']['total']); + $this->assertNotEmpty($deployments['body']['deployments'][0]['$id']); + $this->assertNotEmpty($deployments['body']['deployments'][0]['size']); + + $deploymentId = $deployments['body']['deployments'][0]['$id']; + $deploymentSize = $deployments['body']['deployments'][0]['size']; + + $deployments = $this->listDeployments( + $siteId, + [ + 'queries' => [ + Query::equal('size', [$deploymentSize])->toString(), + ], + ] + ); + + $this->assertEquals(200, $deployments['headers']['status-code']); + $this->assertGreaterThan(0, $deployments['body']['total']); + + $matchingDeployment = array_filter( + $deployments['body']['deployments'], + fn ($deployment) => $deployment['$id'] === $deploymentId + ); + + $this->assertNotEmpty($matchingDeployment, "Deployment with ID {$deploymentId} not found"); + + if (!empty($matchingDeployment)) { + $deployment = reset($matchingDeployment); + $this->assertEquals($deploymentSize, $deployment['size']); + } + + $this->cleanupDeployment($siteId, $deploymentIdActive); + $this->cleanupDeployment($siteId, $deploymentIdInactive); + $this->cleanupSite($siteId); + } } diff --git a/tests/resources/sites/other/code.tar.gz b/tests/resources/sites/other/code.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..367467ccce2bad264fbececdaefd027587e9f666 GIT binary patch literal 605 zcmV-j0;2sNiwFP!000001MQScZ`&{ofPL<-V7%>!`{capWbJwiwqg97ShUEH6iH_gdS@qcWaIH>b)2pnIUZ$67A302 zjMQ=dt{+hBywF2IpD%n~SSq7AcC z|MTtp;M(u2Bx%^xUvRc;m9{<5@}hPbpjQf(4t0E8vn_PDEe|BG@z@M0;13 zTft@@m=Fr?lom7(w_97avFp9uF;{dA-w%%+r3)LBq~T&cfgA0DT!A6d1cqr|zCN<0 z+_Zu?yHc>#vFfWE4PLH;-6s)ktpZaMs+R7gFl<*aa$jA|$;;>pcAr7~s(-qJSjQ)) z*;gbB`;Dqvx@G!eN@Gr}fRl-K^!|_9e)>VcU%%I&B6KW r-q%0<_kkb?f*=TjAP9mW2!bF8f*=TjAP9mW$X~!ujWbkK04M+e$Vn~B literal 0 HcmV?d00001 diff --git a/tests/resources/sites/other/index.html b/tests/resources/sites/other/index.html new file mode 100644 index 0000000000..37a8116a5b --- /dev/null +++ b/tests/resources/sites/other/index.html @@ -0,0 +1,42 @@ + + + + + + Hello World + + + +
+

Hello World!

+

Welcome to my first Appwrite deployment

+
+ + \ No newline at end of file From 140b850cef400824d77fb12fe83cb874c7b1a93c Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:35:31 +0530 Subject: [PATCH 03/13] More tests --- .../Services/Sites/SitesCustomServerTest.php | 262 +++++++++++++++++- 1 file changed, 260 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 740dfd6a23..7d3956a13f 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -573,8 +573,6 @@ class SitesCustomServerTest extends Scope $deployments = $this->listDeployments($siteId); - var_dump($deployments); - $this->assertEquals($deployments['headers']['status-code'], 200); $this->assertEquals($deployments['body']['total'], 2); $this->assertIsArray($deployments['body']['deployments']); @@ -718,4 +716,264 @@ class SitesCustomServerTest extends Scope $this->cleanupDeployment($siteId, $deploymentIdInactive); $this->cleanupSite($siteId); } + + public function testGetDeployment(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $deploymentId = $deployment['body']['$id'] ?? ''; + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + /** + * Test for SUCCESS + */ + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertGreaterThan(0, $deployment['body']['buildTime']); + $this->assertNotEmpty($deployment['body']['status']); + $this->assertNotEmpty($deployment['body']['buildLogs']); + $this->assertArrayHasKey('size', $deployment['body']); + $this->assertArrayHasKey('buildSize', $deployment['body']); + + /** + * Test for FAILURE + */ + $deployment = $this->getDeployment($siteId, 'x'); + + $this->assertEquals($deployment['headers']['status-code'], 404); + + $this->cleanupDeployment($siteId, $deploymentId); + $this->cleanupSite($siteId); + } + + // public function testLoadSite(): void + // { + // $site = $this->createSite([ + // 'adapter' => 'static', + // 'buildRuntime' => 'node-22', + // 'fallbackFile' => null, + // 'framework' => 'other', + // 'name' => 'Test Site', + // 'outputDirectory' => './', + // 'providerBranch' => 'main', + // 'providerRootDirectory' => './', + // 'siteId' => ID::unique() + // ]); + + // $siteId = $site['body']['$id'] ?? ''; + // $this->assertNotEmpty($siteId); + + // var_dump($site); + + // $deployment = $this->createDeployment($siteId, [ + // 'code' => $this->packageSite('other'), + // 'activate' => 'false' + // ]); + + // $deploymentId = $deployment['body']['$id'] ?? ''; + + // $this->assertEventually(function () use ($siteId, $deploymentId) { + // $deployment = $this->getDeployment($siteId, $deploymentId); + + // $this->assertEquals('ready', $deployment['body']['status']); + // }, 50000, 500); + + // $domain = $site['body']['domain']; + + // $response = $this->client->call(Client::METHOD_GET, $domain); + // var_dump($response); + // } + + // public function testUpdateSpecs(): void + // { + // $siteId = $this->setupSite([ + // 'adapter' => 'static', + // 'buildRuntime' => 'node-22', + // 'fallbackFile' => null, + // 'framework' => 'other', + // 'name' => 'Test Site', + // 'outputDirectory' => './', + // 'providerBranch' => 'main', + // 'providerRootDirectory' => './', + // 'siteId' => ID::unique() + // ]); + + // $this->assertNotNull($siteId); + + // /** + // * Test for SUCCESS + // */ + // // Change the function specs + // $site = $this->updateSite([ + // 'adapter' => 'static', + // 'buildRuntime' => 'node-22', + // 'fallbackFile' => null, + // 'framework' => 'other', + // 'name' => 'Test Site', + // 'outputDirectory' => './', + // 'providerBranch' => 'main', + // 'providerRootDirectory' => './', + // '$id' => $siteId, + // 'specification' => Specification::S_1VCPU_1GB, + // ]); + + // $this->assertEquals(200, $site['headers']['status-code']); + // $this->assertNotEmpty($site['body']['$id']); + // $this->assertEquals(Speci::S_1VCPU_1GB, $site['body']['specification']); + + // // Change the specs to 1vcpu 512mb + // $site = $this->updateSite([ + // 'adapter' => 'static', + // 'buildRuntime' => 'node-22', + // 'fallbackFile' => null, + // 'framework' => 'other', + // 'name' => 'Test Site', + // 'outputDirectory' => './', + // 'providerBranch' => 'main', + // 'providerRootDirectory' => './', + // '$id' => $siteId, + // 'specification' => Specification::S_1VCPU_512MB, + // ]); + + // $this->assertEquals(200, $site['headers']['status-code']); + // $this->assertNotEmpty($site['body']['$id']); + // $this->assertEquals(Specification::S_1VCPU_512MB, $site['body']['specification']); + + // /** + // * Test for FAILURE + // */ + + // $site = $this->updateSite([ + // 'adapter' => 'static', + // 'buildRuntime' => 'node-22', + // 'fallbackFile' => null, + // 'framework' => 'other', + // 'name' => 'Test Site', + // 'outputDirectory' => './', + // 'providerBranch' => 'main', + // 'providerRootDirectory' => './', + // '$id' => $siteId, + // 'specification' => 's-2vcpu-512mb', // Invalid specification + // ]); + + // var_dump($site); + + // $this->assertEquals(400, $site['headers']['status-code']); + // $this->assertStringStartsWith('Invalid `specification` param: Specification must be one of:', $site['body']['message']); + + // $this->cleanupSite($siteId); + // } + + public function testDeleteDeployment(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $deployment = $this->createDeployment($siteId, [ + 'code' => $this->packageSite('other'), + 'activate' => 'false' + ]); + + $deploymentId = $deployment['body']['$id'] ?? ''; + + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + /** + * Test for SUCCESS + */ + $deployment = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(204, $deployment['headers']['status-code']); + $this->assertEmpty($deployment['body']); + + $deployment = $this->getDeployment($siteId, $deploymentId); + + $this->assertEquals(404, $deployment['headers']['status-code']); + } + + public function testDeleteSite(): void + { + $siteId = $this->setupSite([ + 'adapter' => 'static', + 'buildRuntime' => 'node-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); + + $this->assertNotNull($siteId); + + $site = $this->deleteSite($siteId); + + $this->assertEquals(204, $site['headers']['status-code']); + $this->assertEmpty($site['body']); + + $function = $this->getSite($siteId); + + $this->assertEquals(404, $function['headers']['status-code']); + } + + public function testGetFrameworks(): void + { + $frameworks = $this->client->call(Client::METHOD_GET, '/sites/frameworks', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $frameworks['headers']['status-code']); + $this->assertGreaterThan(0, $frameworks['body']['total']); + + $framework = $frameworks['body']['frameworks'][0]; + + $this->assertArrayHasKey('name', $framework); + $this->assertArrayHasKey('key', $framework); + $this->assertArrayHasKey('buildRuntime', $framework); + $this->assertArrayHasKey('runtimes', $framework); + $this->assertArrayHasKey('adapters', $framework); + } } From f196cfe9939a26cff9d96edc5f7f0014a0696e54 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:07:23 +0530 Subject: [PATCH 04/13] Use ssr-22 runtime --- .env | 2 +- app/config/site-templates.php | 10 +- composer.json | 2 +- composer.lock | 263 +++++++++--------- .../Services/Sites/SitesCustomServerTest.php | 2 +- 5 files changed, 142 insertions(+), 137 deletions(-) diff --git a/.env b/.env index 04343ed720..c2c0cfa678 100644 --- a/.env +++ b/.env @@ -78,7 +78,7 @@ _APP_COMPUTE_MAINTENANCE_INTERVAL=600 _APP_COMPUTE_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://exc1/v1 -_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 +_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1,ssr-22 _APP_SITES_RUNTIMES=static-1,node-22,flutter-3.24 _APP_SITES_FRAMEWORKS=sveltekit,nextjs,nuxt,astro,remix,static,flutter,other # TODO: Angular _APP_MAINTENANCE_INTERVAL=86400 diff --git a/app/config/site-templates.php b/app/config/site-templates.php index 40edc4a714..64696cedfa 100644 --- a/app/config/site-templates.php +++ b/app/config/site-templates.php @@ -13,7 +13,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './build', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -23,7 +23,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './.next', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -33,7 +33,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './.output', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -43,7 +43,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './build', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -53,7 +53,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './dist', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], diff --git a/composer.json b/composer.json index f04239dc1c..54440debe5 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "ext-openssl": "*", "ext-zlib": "*", "ext-sockets": "*", - "appwrite/php-runtimes": "0.16.*", + "appwrite/php-runtimes": "dev-feat-add-ssr-runtime as 0.16.99", "appwrite/php-clamav": "2.0.*", "utopia-php/abuse": "0.43.0", "utopia-php/analytics": "0.10.*", diff --git a/composer.lock b/composer.lock index 123f6bfbe3..1fce704d6b 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": "026d47ead39933ab29b2ea7046bfec4f", + "content-hash": "2a57d56106703cb729370214435feb98", "packages": [ { "name": "adhocore/jwt", @@ -157,16 +157,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.16.5", + "version": "dev-feat-add-ssr-runtime", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "1e430646fdf847a7caf3c611dcf3d6d5a28c3fd9" + "reference": "a021a2b09b045375979f8e7bc2e7aa520fc94847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/1e430646fdf847a7caf3c611dcf3d6d5a28c3fd9", - "reference": "1e430646fdf847a7caf3c611dcf3d6d5a28c3fd9", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/a021a2b09b045375979f8e7bc2e7aa520fc94847", + "reference": "a021a2b09b045375979f8e7bc2e7aa520fc94847", "shasum": "" }, "require": { @@ -206,9 +206,9 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.16.5" + "source": "https://github.com/appwrite/runtimes/tree/feat-add-ssr-runtime" }, - "time": "2024-11-25T15:17:06+00:00" + "time": "2025-01-07T12:14:14+00:00" }, { "name": "beberlei/assert", @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.29.0", + "version": "v4.29.2", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "0ef6b2eb74b782f3f9023276c324d22e440f7587" + "reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/0ef6b2eb74b782f3f9023276c324d22e440f7587", - "reference": "0ef6b2eb74b782f3f9023276c324d22e440f7587", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/79aa5014efeeec3d137df5cdb0ae2fc163953945", + "reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.0" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.2" }, - "time": "2024-11-27T18:37:40+00:00" + "time": "2024-12-18T14:11:12+00:00" }, { "name": "jean85/pretty-package-versions", @@ -1237,16 +1237,16 @@ }, { "name": "open-telemetry/api", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "542064815d38a6df55af7957cd6f1d7d967c99c6" + "reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/542064815d38a6df55af7957cd6f1d7d967c99c6", - "reference": "542064815d38a6df55af7957cd6f1d7d967c99c6", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/04c85a1e41a3d59fa9bdc801a5de1df6624b95ed", + "reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed", "shasum": "" }, "require": { @@ -1260,13 +1260,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.1.x-dev" - }, "spi": { "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [ "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager" ] + }, + "branch-alias": { + "dev-main": "1.1.x-dev" } }, "autoload": { @@ -1303,7 +1303,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-10-15T22:42:37+00:00" + "time": "2024-11-16T04:32:30+00:00" }, { "name": "open-telemetry/context", @@ -1530,13 +1530,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.0.x-dev" - }, "spi": { "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\HookManagerInterface": [ "OpenTelemetry\\API\\Instrumentation\\AutoInstrumentation\\ExtensionHookManager" ] + }, + "branch-alias": { + "dev-main": "1.0.x-dev" } }, "autoload": { @@ -2403,12 +2403,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2453,23 +2453,23 @@ }, { "name": "symfony/http-client", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "955e43336aff03df1e8a8e17daefabb0127a313b" + "reference": "339ba21476eb184290361542f732ad12c97591ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/955e43336aff03df1e8a8e17daefabb0127a313b", - "reference": "955e43336aff03df1e8a8e17daefabb0127a313b", + "url": "https://api.github.com/repos/symfony/http-client/zipball/339ba21476eb184290361542f732ad12c97591ec", + "reference": "339ba21476eb184290361542f732ad12c97591ec", "shasum": "" }, "require": { "php": ">=8.2", "psr/log": "^1|^2|^3", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/http-client-contracts": "~3.4.3|^3.5.1", + "symfony/http-client-contracts": "~3.4.4|^3.5.2", "symfony/service-contracts": "^2.5|^3" }, "conflict": { @@ -2528,7 +2528,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.2.0" + "source": "https://github.com/symfony/http-client/tree/v7.2.2" }, "funding": [ { @@ -2544,20 +2544,20 @@ "type": "tidelift" } ], - "time": "2024-11-29T08:22:02+00:00" + "time": "2024-12-30T18:35:15+00:00" }, { "name": "symfony/http-client-contracts", - "version": "v3.5.1", + "version": "v3.5.2", "source": { "type": "git", "url": "https://github.com/symfony/http-client-contracts.git", - "reference": "c2f3ad828596624ca39ea40f83617ef51ca8bbf9" + "reference": "ee8d807ab20fcb51267fdace50fbe3494c31e645" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/c2f3ad828596624ca39ea40f83617ef51ca8bbf9", - "reference": "c2f3ad828596624ca39ea40f83617ef51ca8bbf9", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/ee8d807ab20fcb51267fdace50fbe3494c31e645", + "reference": "ee8d807ab20fcb51267fdace50fbe3494c31e645", "shasum": "" }, "require": { @@ -2565,12 +2565,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2606,7 +2606,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.2" }, "funding": [ { @@ -2622,7 +2622,7 @@ "type": "tidelift" } ], - "time": "2024-11-25T12:02:18+00:00" + "time": "2024-12-07T08:49:48+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2650,8 +2650,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -2724,8 +2724,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -2804,8 +2804,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -2884,12 +2884,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2970,10 +2970,10 @@ }, "type": "composer-plugin", "extra": { + "class": "Nevay\\SPI\\Composer\\Plugin", "branch-alias": { "dev-main": "0.2.x-dev" }, - "class": "Nevay\\SPI\\Composer\\Plugin", "plugin-optional": true }, "autoload": { @@ -4363,16 +4363,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.7", + "version": "0.18.8", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "0d9228faa1c202f9e01483e45a8950485f01a288" + "reference": "84737afa634e6a833fc4f8b0c967553234d3f215" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/0d9228faa1c202f9e01483e45a8950485f01a288", - "reference": "0d9228faa1c202f9e01483e45a8950485f01a288", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/84737afa634e6a833fc4f8b0c967553234d3f215", + "reference": "84737afa634e6a833fc4f8b0c967553234d3f215", "shasum": "" }, "require": { @@ -4412,9 +4412,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.7" + "source": "https://github.com/utopia-php/storage/tree/0.18.8" }, - "time": "2024-11-28T11:10:53+00:00" + "time": "2024-12-04T08:30:35+00:00" }, { "name": "utopia-php/swoole", @@ -4575,16 +4575,16 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.5", + "version": "0.8.6", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "7622330628d53844a3873ca873338150756bab82" + "reference": "b10225f54d5670f09f83e82e09de9d820ada6931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/7622330628d53844a3873ca873338150756bab82", - "reference": "7622330628d53844a3873ca873338150756bab82", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/b10225f54d5670f09f83e82e09de9d820ada6931", + "reference": "b10225f54d5670f09f83e82e09de9d820ada6931", "shasum": "" }, "require": { @@ -4618,9 +4618,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.5" + "source": "https://github.com/utopia-php/vcs/tree/0.8.6" }, - "time": "2024-11-11T18:33:10+00:00" + "time": "2024-12-10T13:13:23+00:00" }, { "name": "utopia-php/websocket", @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.25", + "version": "0.39.29", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "5b5323636a8d75a1c4faaae9728098dd6a6a47d1" + "reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5b5323636a8d75a1c4faaae9728098dd6a6a47d1", - "reference": "5b5323636a8d75a1c4faaae9728098dd6a6a47d1", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7", + "reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7", "shasum": "" }, "require": { @@ -4852,9 +4852,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.39.25" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.29" }, - "time": "2024-11-08T10:16:34+00:00" + "time": "2025-01-07T05:28:35+00:00" }, { "name": "doctrine/annotations", @@ -4934,29 +4934,27 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "1.4.10 || 1.10.15", - "phpstan/phpstan-phpunit": "^1.0", + "doctrine/coding-standard": "^9 || ^12", + "phpstan/phpstan": "1.4.10 || 2.0.3", + "phpstan/phpstan-phpunit": "^1.0 || ^2", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "0.18.4", - "psr/log": "^1 || ^2 || ^3", - "vimeo/psalm": "4.30.0 || 5.12.0" + "psr/log": "^1 || ^2 || ^3" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -4964,7 +4962,7 @@ "type": "library", "autoload": { "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + "Doctrine\\Deprecations\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4975,9 +4973,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + "source": "https://github.com/doctrine/deprecations/tree/1.1.4" }, - "time": "2024-01-30T19:34:25+00:00" + "time": "2024-12-07T21:18:45+00:00" }, { "name": "doctrine/instantiator", @@ -5128,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.18.3", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "cef51821608239040ab841ad6e1c6ae502ae3026" + "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/cef51821608239040ab841ad6e1c6ae502ae3026", - "reference": "cef51821608239040ab841ad6e1c6ae502ae3026", + "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", + "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", "shasum": "" }, "require": { @@ -5148,10 +5146,10 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.65.0", - "illuminate/view": "^10.48.24", - "larastan/larastan": "^2.9.11", - "laravel-zero/framework": "^10.4.0", + "friendsofphp/php-cs-fixer": "^3.66.0", + "illuminate/view": "^10.48.25", + "larastan/larastan": "^2.9.12", + "laravel-zero/framework": "^10.48.25", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^1.17.0", "pestphp/pest": "^2.36.0" @@ -5190,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-11-26T15:34:00+00:00" + "time": "2024-12-30T16:20:10+00:00" }, { "name": "matthiasmullie/minify", @@ -5378,16 +5376,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.3.1", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { @@ -5430,9 +5428,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-10-08T18:51:32+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "phar-io/manifest", @@ -5809,16 +5807,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.0", + "version": "5.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", "shasum": "" }, "require": { @@ -5867,9 +5865,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" }, - "time": "2024-11-12T11:25:25+00:00" + "time": "2024-12-07T09:39:29+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -7578,16 +7576,16 @@ }, { "name": "symfony/console", - "version": "v7.2.0", + "version": "v7.2.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf" + "reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", - "reference": "23c8aae6d764e2bae02d2a99f7532a7f6ed619cf", + "url": "https://api.github.com/repos/symfony/console/zipball/fefcc18c0f5d0efe3ab3152f15857298868dc2c3", + "reference": "fefcc18c0f5d0efe3ab3152f15857298868dc2c3", "shasum": "" }, "require": { @@ -7651,7 +7649,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.2.0" + "source": "https://github.com/symfony/console/tree/v7.2.1" }, "funding": [ { @@ -7667,7 +7665,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:24:19+00:00" + "time": "2024-12-11T03:49:26+00:00" }, { "name": "symfony/filesystem", @@ -7737,16 +7735,16 @@ }, { "name": "symfony/finder", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49" + "reference": "87a71856f2f56e4100373e92529eed3171695cfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6de263e5868b9a137602dd1e33e4d48bfae99c49", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49", + "url": "https://api.github.com/repos/symfony/finder/zipball/87a71856f2f56e4100373e92529eed3171695cfb", + "reference": "87a71856f2f56e4100373e92529eed3171695cfb", "shasum": "" }, "require": { @@ -7781,7 +7779,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.2.0" + "source": "https://github.com/symfony/finder/tree/v7.2.2" }, "funding": [ { @@ -7797,7 +7795,7 @@ "type": "tidelift" } ], - "time": "2024-10-23T06:56:12+00:00" + "time": "2024-12-30T19:00:17+00:00" }, { "name": "symfony/options-resolver", @@ -7892,8 +7890,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -7968,8 +7966,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -8046,8 +8044,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -8124,8 +8122,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -8557,6 +8555,12 @@ } ], "aliases": [ + { + "package": "appwrite/php-runtimes", + "version": "dev-feat-add-ssr-runtime", + "alias": "0.16.99", + "alias_normalized": "0.16.99.0" + }, { "package": "utopia-php/framework", "version": "dev-fix-prevent-duplicate-compression", @@ -8566,6 +8570,7 @@ ], "minimum-stability": "stable", "stability-flags": { + "appwrite/php-runtimes": 20, "utopia-php/framework": 20 }, "prefer-stable": false, @@ -8591,5 +8596,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 7d3956a13f..5a8b8615e8 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -365,7 +365,7 @@ class SitesCustomServerTest extends Scope // $this->assertEquals(200, $site['headers']['status-code']); // var_dump($deployment); - // // $this->cleanupSite($siteId); + // $this->cleanupSite($siteId); // } public function testCreateDeployment() From 857046ecb81742d7fb5543f971085e6f9c5a6aa0 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:55:21 +0530 Subject: [PATCH 05/13] Address PR comments --- .github/workflows/tests.yml | 1 + .gitignore | 1 + tests/e2e/Services/Sites/SitesBase.php | 2 +- .../Services/Sites/SitesCustomServerTest.php | 7 --- tests/resources/sites/other/code.tar.gz | Bin 605 -> 0 bytes tests/resources/sites/other/index.html | 42 ------------------ tests/resources/sites/static/index.html | 11 +++++ 7 files changed, 14 insertions(+), 50 deletions(-) delete mode 100644 tests/resources/sites/other/code.tar.gz delete mode 100644 tests/resources/sites/other/index.html create mode 100644 tests/resources/sites/static/index.html diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 63c132cd03..19ed58c3a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -122,6 +122,7 @@ jobs: Locale, Projects, Realtime, + Sites, Storage, Teams, Users, diff --git a/.gitignore b/.gitignore index a68af84071..379358e2cf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /node_modules/ /tests/resources/storage/ /tests/resources/functions/**/code.tar.gz +/tests/resources/sites/**/code.tar.gz /app/sdks/* /.idea/ !/.idea/workspace.xml diff --git a/tests/e2e/Services/Sites/SitesBase.php b/tests/e2e/Services/Sites/SitesBase.php index 2e9f69a243..d19f20b24d 100644 --- a/tests/e2e/Services/Sites/SitesBase.php +++ b/tests/e2e/Services/Sites/SitesBase.php @@ -155,7 +155,7 @@ trait SitesBase protected function listLogs(string $siteId, mixed $params = []): mixed { - $logs = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/executions', array_merge([ + $logs = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/logs', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), $params); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 5a8b8615e8..f8fc06591b 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -23,14 +23,11 @@ class SitesCustomServerTest extends Scope * Test for SUCCESS */ $site = $this->createSite([ - 'adapter' => 'static', 'buildRuntime' => 'node-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', 'outputDirectory' => './', - 'providerBranch' => 'main', - 'providerRootDirectory' => './', 'siteId' => ID::unique() ]); @@ -43,12 +40,9 @@ class SitesCustomServerTest extends Scope $this->assertEquals('other', $site['body']['framework']); $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); - $this->assertEquals('static', $site['body']['adapter']); $this->assertEquals('node-22', $site['body']['buildRuntime']); $this->assertEquals(null, $site['body']['fallbackFile']); $this->assertEquals('./', $site['body']['outputDirectory']); - $this->assertEquals('main', $site['body']['providerBranch']); - $this->assertEquals('./', $site['body']['providerRootDirectory']); $variable = $this->createVariable($siteId, [ 'key' => 'siteKey1', @@ -76,7 +70,6 @@ class SitesCustomServerTest extends Scope * Test for SUCCESS */ $siteId = $this->setupSite([ - 'adapter' => 'static', 'buildRuntime' => 'node-22', 'fallbackFile' => null, 'framework' => 'other', diff --git a/tests/resources/sites/other/code.tar.gz b/tests/resources/sites/other/code.tar.gz deleted file mode 100644 index 367467ccce2bad264fbececdaefd027587e9f666..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 605 zcmV-j0;2sNiwFP!000001MQScZ`&{ofPL<-V7%>!`{capWbJwiwqg97ShUEH6iH_gdS@qcWaIH>b)2pnIUZ$67A302 zjMQ=dt{+hBywF2IpD%n~SSq7AcC z|MTtp;M(u2Bx%^xUvRc;m9{<5@}hPbpjQf(4t0E8vn_PDEe|BG@z@M0;13 zTft@@m=Fr?lom7(w_97avFp9uF;{dA-w%%+r3)LBq~T&cfgA0DT!A6d1cqr|zCN<0 z+_Zu?yHc>#vFfWE4PLH;-6s)ktpZaMs+R7gFl<*aa$jA|$;;>pcAr7~s(-qJSjQ)) z*;gbB`;Dqvx@G!eN@Gr}fRl-K^!|_9e)>VcU%%I&B6KW r-q%0<_kkb?f*=TjAP9mW2!bF8f*=TjAP9mW$X~!ujWbkK04M+e$Vn~B diff --git a/tests/resources/sites/other/index.html b/tests/resources/sites/other/index.html deleted file mode 100644 index 37a8116a5b..0000000000 --- a/tests/resources/sites/other/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - Hello World - - - -
-

Hello World!

-

Welcome to my first Appwrite deployment

-
- - \ No newline at end of file diff --git a/tests/resources/sites/static/index.html b/tests/resources/sites/static/index.html new file mode 100644 index 0000000000..ca1b1cc78d --- /dev/null +++ b/tests/resources/sites/static/index.html @@ -0,0 +1,11 @@ + + + + + + Hello Appwrite + + +

Hello Appwrite

+ + \ No newline at end of file From 3c9ea6cabad30c5b27e21ee730431adbeefc2bb9 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:16:26 +0530 Subject: [PATCH 06/13] Fix tests --- app/config/frameworks.php | 12 ++-- .../Services/Sites/SitesCustomServerTest.php | 72 ++++++++----------- 2 files changed, 34 insertions(+), 50 deletions(-) diff --git a/app/config/frameworks.php b/app/config/frameworks.php index 35c9c9909c..ff54c0aacb 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -21,7 +21,7 @@ return [ 'nextjs' => [ 'key' => 'nextjs', 'name' => 'Next.js', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -45,7 +45,7 @@ return [ 'nuxt' => [ 'key' => 'nuxt', 'name' => 'Nuxt', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -69,7 +69,7 @@ return [ 'sveltekit' => [ 'key' => 'sveltekit', 'name' => 'SvelteKit', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -93,7 +93,7 @@ return [ 'astro' => [ 'key' => 'astro', 'name' => 'Astro', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -117,7 +117,7 @@ return [ 'remix' => [ 'key' => 'remix', 'name' => 'Remix', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -157,7 +157,7 @@ return [ 'other' => [ 'key' => 'other', 'name' => 'Other', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'static' => [ diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index f8fc06591b..2bb8ef44d4 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -23,7 +23,7 @@ class SitesCustomServerTest extends Scope * Test for SUCCESS */ $site = $this->createSite([ - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -40,7 +40,7 @@ class SitesCustomServerTest extends Scope $this->assertEquals('other', $site['body']['framework']); $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); - $this->assertEquals('node-22', $site['body']['buildRuntime']); + $this->assertEquals('ssr-22', $site['body']['buildRuntime']); $this->assertEquals(null, $site['body']['fallbackFile']); $this->assertEquals('./', $site['body']['outputDirectory']); @@ -70,7 +70,7 @@ class SitesCustomServerTest extends Scope * Test for SUCCESS */ $siteId = $this->setupSite([ - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -150,8 +150,7 @@ class SitesCustomServerTest extends Scope * Test pagination */ $siteId2 = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site 2', @@ -207,8 +206,7 @@ class SitesCustomServerTest extends Scope public function testGetSite(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -241,8 +239,7 @@ class SitesCustomServerTest extends Scope public function testUpdateSite(): void { $site = $this->createSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -259,8 +256,7 @@ class SitesCustomServerTest extends Scope $this->assertEquals('Test Site', $site['body']['name']); $site = $this->updateSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site Updated', @@ -364,8 +360,7 @@ class SitesCustomServerTest extends Scope public function testCreateDeployment() { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -379,7 +374,7 @@ class SitesCustomServerTest extends Scope $deployment = $this->createDeployment($siteId, [ 'siteId' => $siteId, - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => true, ]); @@ -396,7 +391,7 @@ class SitesCustomServerTest extends Scope }, 50000, 500); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -425,8 +420,7 @@ class SitesCustomServerTest extends Scope public function testCancelDeploymentBuild(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -439,7 +433,7 @@ class SitesCustomServerTest extends Scope $this->assertNotNull($siteId); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -483,8 +477,7 @@ class SitesCustomServerTest extends Scope public function testUpdateDeployment(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -497,7 +490,7 @@ class SitesCustomServerTest extends Scope $this->assertNotNull($siteId); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -533,8 +526,7 @@ class SitesCustomServerTest extends Scope public function testListDeployments(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -547,7 +539,7 @@ class SitesCustomServerTest extends Scope $this->assertNotNull($siteId); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -555,7 +547,7 @@ class SitesCustomServerTest extends Scope $this->assertEquals(202, $deployment['headers']['status-code']); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -713,8 +705,7 @@ class SitesCustomServerTest extends Scope public function testGetDeployment(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -727,7 +718,7 @@ class SitesCustomServerTest extends Scope $this->assertNotNull($siteId); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -765,8 +756,7 @@ class SitesCustomServerTest extends Scope // public function testLoadSite(): void // { // $site = $this->createSite([ - // 'adapter' => 'static', - // 'buildRuntime' => 'node-22', + // 'buildRuntime' => 'ssr-22', // 'fallbackFile' => null, // 'framework' => 'other', // 'name' => 'Test Site', @@ -782,7 +772,7 @@ class SitesCustomServerTest extends Scope // var_dump($site); // $deployment = $this->createDeployment($siteId, [ - // 'code' => $this->packageSite('other'), + // 'code' => $this->packageSite('static'), // 'activate' => 'false' // ]); @@ -803,8 +793,7 @@ class SitesCustomServerTest extends Scope // public function testUpdateSpecs(): void // { // $siteId = $this->setupSite([ - // 'adapter' => 'static', - // 'buildRuntime' => 'node-22', + // 'buildRuntime' => 'ssr-22', // 'fallbackFile' => null, // 'framework' => 'other', // 'name' => 'Test Site', @@ -821,8 +810,7 @@ class SitesCustomServerTest extends Scope // */ // // Change the function specs // $site = $this->updateSite([ - // 'adapter' => 'static', - // 'buildRuntime' => 'node-22', + // 'buildRuntime' => 'ssr-22', // 'fallbackFile' => null, // 'framework' => 'other', // 'name' => 'Test Site', @@ -839,8 +827,7 @@ class SitesCustomServerTest extends Scope // // Change the specs to 1vcpu 512mb // $site = $this->updateSite([ - // 'adapter' => 'static', - // 'buildRuntime' => 'node-22', + // 'buildRuntime' => 'ssr-22', // 'fallbackFile' => null, // 'framework' => 'other', // 'name' => 'Test Site', @@ -860,8 +847,7 @@ class SitesCustomServerTest extends Scope // */ // $site = $this->updateSite([ - // 'adapter' => 'static', - // 'buildRuntime' => 'node-22', + // 'buildRuntime' => 'ssr-22', // 'fallbackFile' => null, // 'framework' => 'other', // 'name' => 'Test Site', @@ -883,8 +869,7 @@ class SitesCustomServerTest extends Scope public function testDeleteDeployment(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', @@ -897,7 +882,7 @@ class SitesCustomServerTest extends Scope $this->assertNotNull($siteId); $deployment = $this->createDeployment($siteId, [ - 'code' => $this->packageSite('other'), + 'code' => $this->packageSite('static'), 'activate' => 'false' ]); @@ -928,8 +913,7 @@ class SitesCustomServerTest extends Scope public function testDeleteSite(): void { $siteId = $this->setupSite([ - 'adapter' => 'static', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'fallbackFile' => null, 'framework' => 'other', 'name' => 'Test Site', From 4a3ea540bf7539ec4eb18e3002d75fceb7035222 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 20 Jan 2025 01:01:21 +0530 Subject: [PATCH 07/13] Fix specification tests --- .env | 4 +- app/config/frameworks/specifications.php | 51 ++++ app/config/runtimes/specifications.php | 8 +- app/init.php | 1 + src/Appwrite/Sites/Specification.php | 16 ++ .../Functions/FunctionsCustomServerTest.php | 8 +- .../Services/Sites/SitesCustomServerTest.php | 245 +++++++++--------- 7 files changed, 194 insertions(+), 139 deletions(-) create mode 100644 app/config/frameworks/specifications.php create mode 100644 src/Appwrite/Sites/Specification.php diff --git a/.env b/.env index c2c0cfa678..b22ab2ddcf 100644 --- a/.env +++ b/.env @@ -78,8 +78,8 @@ _APP_COMPUTE_MAINTENANCE_INTERVAL=600 _APP_COMPUTE_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://exc1/v1 -_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1,ssr-22 -_APP_SITES_RUNTIMES=static-1,node-22,flutter-3.24 +_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 +_APP_SITES_RUNTIMES=static-1,node-22,flutter-3.24,ssr-22 _APP_SITES_FRAMEWORKS=sveltekit,nextjs,nuxt,astro,remix,static,flutter,other # TODO: Angular _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_DELAY= diff --git a/app/config/frameworks/specifications.php b/app/config/frameworks/specifications.php new file mode 100644 index 0000000000..63ca3ea423 --- /dev/null +++ b/app/config/frameworks/specifications.php @@ -0,0 +1,51 @@ + [ + 'slug' => Specification::S_05VCPU_512MB, + 'memory' => 512, + 'cpus' => 0.5 + ], + Specification::S_1VCPU_512MB => [ + 'slug' => Specification::S_1VCPU_512MB, + 'memory' => 512, + 'cpus' => 1 + ], + Specification::S_1VCPU_1GB => [ + 'slug' => Specification::S_1VCPU_1GB, + 'memory' => 1024, + 'cpus' => 1 + ], + Specification::S_2VCPU_2GB => [ + 'slug' => Specification::S_2VCPU_2GB, + 'memory' => 2048, + 'cpus' => 2 + ], + Specification::S_2VCPU_4GB => [ + 'slug' => Specification::S_2VCPU_4GB, + 'memory' => 4096, + 'cpus' => 2 + ], + Specification::S_4VCPU_4GB => [ + 'slug' => Specification::S_4VCPU_4GB, + 'memory' => 4096, + 'cpus' => 4 + ], + Specification::S_4VCPU_8GB => [ + 'slug' => Specification::S_4VCPU_8GB, + 'memory' => 8192, + 'cpus' => 4 + ], + Specification::S_8VCPU_4GB => [ + 'slug' => Specification::S_8VCPU_4GB, + 'memory' => 4096, + 'cpus' => 8 + ], + Specification::S_8VCPU_8GB => [ + 'slug' => Specification::S_8VCPU_8GB, + 'memory' => 8192, + 'cpus' => 8 + ] +]; diff --git a/app/config/runtimes/specifications.php b/app/config/runtimes/specifications.php index 9ec6fc6059..d3625db8a2 100644 --- a/app/config/runtimes/specifications.php +++ b/app/config/runtimes/specifications.php @@ -5,17 +5,17 @@ use Appwrite\Functions\Specification; return [ Specification::S_05VCPU_512MB => [ 'slug' => Specification::S_05VCPU_512MB, - 'memory' => 4096, // TODO: Revert this, it was just for QA server - 'cpus' => 1 // TODO: revert this, it's a temporary change to test function performance. + 'memory' => 512, + 'cpus' => 0.5 ], Specification::S_1VCPU_512MB => [ 'slug' => Specification::S_1VCPU_512MB, - 'memory' => 4096, // TODO: Revert this, it was just for QA server + 'memory' => 512, 'cpus' => 1 ], Specification::S_1VCPU_1GB => [ 'slug' => Specification::S_1VCPU_1GB, - 'memory' => 4096, // TODO: Revert this, it was just for QA server + 'memory' => 1024, 'cpus' => 1 ], Specification::S_2VCPU_2GB => [ diff --git a/app/init.php b/app/init.php index dfa849c002..c2feb0f066 100644 --- a/app/init.php +++ b/app/init.php @@ -363,6 +363,7 @@ Config::load('storage-mimes', __DIR__ . '/config/storage/mimes.php'); Config::load('storage-inputs', __DIR__ . '/config/storage/inputs.php'); Config::load('storage-outputs', __DIR__ . '/config/storage/outputs.php'); Config::load('runtime-specifications', __DIR__ . '/config/runtimes/specifications.php'); +Config::load('framework-specifications', __DIR__ . '/config/frameworks/specifications.php'); Config::load('function-templates', __DIR__ . '/config/function-templates.php'); Config::load('site-templates', __DIR__ . '/config/site-templates.php'); diff --git a/src/Appwrite/Sites/Specification.php b/src/Appwrite/Sites/Specification.php new file mode 100644 index 0000000000..c6e725ec31 --- /dev/null +++ b/src/Appwrite/Sites/Specification.php @@ -0,0 +1,16 @@ +assertEquals(201, $execution['headers']['status-code']); $this->assertNotEmpty($execution['body']['$id']); - $this->assertNotEmpty($execution['body']['functionId']); + $this->assertNotEmpty($execution['body']['resourceId']); $this->assertEquals(true, (new DatetimeValidator())->isValid($execution['body']['$createdAt'])); - $this->assertEquals($data['functionId'], $execution['body']['functionId']); + $this->assertEquals($data['functionId'], $execution['body']['resourceId']); $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals(200, $execution['body']['responseStatusCode']); - $this->assertStringContainsString($execution['body']['functionId'], $execution['body']['responseBody']); + $this->assertStringContainsString($execution['body']['resourceId'], $execution['body']['responseBody']); $this->assertStringContainsString($data['deploymentId'], $execution['body']['responseBody']); $this->assertStringContainsString('Test1', $execution['body']['responseBody']); $this->assertStringContainsString('http', $execution['body']['responseBody']); @@ -941,7 +941,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(1, $executions['body']['total']); $this->assertIsInt($executions['body']['total']); $this->assertCount(1, $executions['body']['executions']); - $this->assertEquals($data['functionId'], $executions['body']['executions'][0]['functionId']); + $this->assertEquals($data['functionId'], $executions['body']['executions'][0]['resourceId']); $executions = $this->listExecutions($data['functionId'], [ 'search' => $data['functionId'], diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 2bb8ef44d4..d5863aea2f 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2,6 +2,7 @@ namespace Tests\E2E\Services\Sites; +use Appwrite\Sites\Specification; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; @@ -283,79 +284,67 @@ class SitesCustomServerTest extends Scope // // TODO: Implement testCreateDeploymentFromCLI() later // } - // public function testCreateSiteAndDeploymentFromTemplate() - // { - // $starterTemplate = $this->getTemplate('nextjs-starter'); - // $this->assertEquals(200, $starterTemplate['headers']['status-code']); + public function testCreateSiteAndDeploymentFromTemplate() + { + $starterTemplate = $this->getTemplate('nextjs-starter'); + $this->assertEquals(200, $starterTemplate['headers']['status-code']); - // $nextjsFramework = array_values(array_filter($starterTemplate['body']['frameworks'], function ($framework) { - // return $framework['key'] === 'nextjs'; - // }))[0]; + $nextjsFramework = array_values(array_filter($starterTemplate['body']['frameworks'], function ($framework) { + return $framework['key'] === 'nextjs'; + }))[0]; - // // If this fails, the template has variables, and this test needs to be updated - // $this->assertEmpty($starterTemplate['body']['variables']); + // If this fails, the template has variables, and this test needs to be updated + $this->assertEmpty($starterTemplate['body']['variables']); - // var_dump("creating site"); + $site = $this->createSite( + [ + 'siteId' => ID::unique(), + 'name' => $starterTemplate['body']['name'], + 'framework' => $nextjsFramework['key'], + 'adapter' => $nextjsFramework['adapter'], + 'buildCommand' => $nextjsFramework['buildCommand'], + 'buildRuntime' => $nextjsFramework['buildRuntime'], + 'fallbackFile' => $nextjsFramework['fallbackFile'], + 'installCommand' => $nextjsFramework['installCommand'], + 'outputDirectory' => $nextjsFramework['outputDirectory'], + 'providerRootDirectory' => $nextjsFramework['providerRootDirectory'], + 'templateOwner' => $starterTemplate['body']['providerOwner'], + 'templateRepository' => $starterTemplate['body']['providerRepositoryId'], + 'templateRootDirectory' => $nextjsFramework['providerRootDirectory'], + 'templateVersion' => $starterTemplate['body']['providerVersion'], + 'providerBranch' => 'main', + ] + ); - // $site = $this->createSite( - // [ - // 'siteId' => ID::unique(), - // 'name' => $starterTemplate['body']['name'], - // 'framework' => $nextjsFramework['key'], - // 'adapter' => $nextjsFramework['adapter'], - // 'buildCommand' => $nextjsFramework['buildCommand'], - // 'buildRuntime' => $nextjsFramework['buildRuntime'], - // 'fallbackFile' => $nextjsFramework['fallbackFile'], - // 'installCommand' => $nextjsFramework['installCommand'], - // 'outputDirectory' => $nextjsFramework['outputDirectory'], - // 'providerRootDirectory' => $nextjsFramework['providerRootDirectory'], - // 'templateOwner' => $starterTemplate['body']['providerOwner'], - // 'templateRepository' => $starterTemplate['body']['providerRepositoryId'], - // 'templateRootDirectory' => $nextjsFramework['providerRootDirectory'], - // 'templateVersion' => $starterTemplate['body']['providerVersion'], - // 'providerBranch' => 'main', - // ] - // ); + $this->assertEquals(201, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); - // $this->assertEquals(201, $site['headers']['status-code']); - // $this->assertNotEmpty($site['body']['$id']); + $siteId = $site['body']['$id'] ?? ''; - // $siteId = $site['body']['$id'] ?? ''; - // var_dump("Site id"); + $deployments = $this->listDeployments($siteId); - // $deployments = $this->listDeployments($siteId); + $this->assertEquals(200, $deployments['headers']['status-code']); + $this->assertEquals(1, $deployments['body']['total']); - // var_dump($deployments); + $lastDeployment = $deployments['body']['deployments'][0]; - // $this->assertEquals(200, $deployments['headers']['status-code']); - // $this->assertEquals(1, $deployments['body']['total']); + $this->assertNotEmpty($lastDeployment['$id']); + $this->assertEquals(0, $lastDeployment['size']); - // $lastDeployment = $deployments['body']['deployments'][0]; + $deploymentId = $lastDeployment['$id']; - // $this->assertNotEmpty($lastDeployment['$id']); - // $this->assertEquals(0, $lastDeployment['size']); + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); - // $deploymentId = $lastDeployment['$id']; - // var_dump("flow reached here"); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertEquals('ready', $deployment['body']['status']); + }, 300000, 1000); - // $this->assertEventually(function () use ($siteId, $deploymentId) { - // $deployment = $this->getDeployment($siteId, $deploymentId); + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); - // $this->assertEquals(200, $deployment['headers']['status-code']); - // // assert that deployment is ready or failed - // $this->assertContains($deployment['body']['status'], ['ready', 'failed']); - // }, 300000, 1000); - - // var_dump("flow reached here 2"); - - // $site = $this->getSite($siteId); - // $deployment = $this->getDeployment($siteId, $deploymentId); - - // $this->assertEquals(200, $site['headers']['status-code']); - // var_dump($deployment); - - // $this->cleanupSite($siteId); - // } + $this->cleanupSite($siteId); + } public function testCreateDeployment() { @@ -769,8 +758,6 @@ class SitesCustomServerTest extends Scope // $siteId = $site['body']['$id'] ?? ''; // $this->assertNotEmpty($siteId); - // var_dump($site); - // $deployment = $this->createDeployment($siteId, [ // 'code' => $this->packageSite('static'), // 'activate' => 'false' @@ -782,89 +769,87 @@ class SitesCustomServerTest extends Scope // $deployment = $this->getDeployment($siteId, $deploymentId); // $this->assertEquals('ready', $deployment['body']['status']); - // }, 50000, 500); + // }, 30000, 300); - // $domain = $site['body']['domain']; + // // get rule for this site from rules collection // $response = $this->client->call(Client::METHOD_GET, $domain); // var_dump($response); // } - // public function testUpdateSpecs(): void - // { - // $siteId = $this->setupSite([ - // 'buildRuntime' => 'ssr-22', - // 'fallbackFile' => null, - // 'framework' => 'other', - // 'name' => 'Test Site', - // 'outputDirectory' => './', - // 'providerBranch' => 'main', - // 'providerRootDirectory' => './', - // 'siteId' => ID::unique() - // ]); + public function testUpdateSpecs(): void + { + $siteId = $this->setupSite([ + 'buildRuntime' => 'ssr-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + 'siteId' => ID::unique() + ]); - // $this->assertNotNull($siteId); + $this->assertNotNull($siteId); - // /** - // * Test for SUCCESS - // */ - // // Change the function specs - // $site = $this->updateSite([ - // 'buildRuntime' => 'ssr-22', - // 'fallbackFile' => null, - // 'framework' => 'other', - // 'name' => 'Test Site', - // 'outputDirectory' => './', - // 'providerBranch' => 'main', - // 'providerRootDirectory' => './', - // '$id' => $siteId, - // 'specification' => Specification::S_1VCPU_1GB, - // ]); + /** + * Test for SUCCESS + */ + // Change the function specs + $site = $this->updateSite([ + 'buildRuntime' => 'ssr-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + '$id' => $siteId, + 'specification' => Specification::S_1VCPU_1GB, + ]); - // $this->assertEquals(200, $site['headers']['status-code']); - // $this->assertNotEmpty($site['body']['$id']); - // $this->assertEquals(Speci::S_1VCPU_1GB, $site['body']['specification']); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals(Specification::S_1VCPU_1GB, $site['body']['specification']); - // // Change the specs to 1vcpu 512mb - // $site = $this->updateSite([ - // 'buildRuntime' => 'ssr-22', - // 'fallbackFile' => null, - // 'framework' => 'other', - // 'name' => 'Test Site', - // 'outputDirectory' => './', - // 'providerBranch' => 'main', - // 'providerRootDirectory' => './', - // '$id' => $siteId, - // 'specification' => Specification::S_1VCPU_512MB, - // ]); + // Change the specs to 1vcpu 512mb + $site = $this->updateSite([ + 'buildRuntime' => 'ssr-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + '$id' => $siteId, + 'specification' => Specification::S_1VCPU_512MB, + ]); - // $this->assertEquals(200, $site['headers']['status-code']); - // $this->assertNotEmpty($site['body']['$id']); - // $this->assertEquals(Specification::S_1VCPU_512MB, $site['body']['specification']); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals(Specification::S_1VCPU_512MB, $site['body']['specification']); - // /** - // * Test for FAILURE - // */ + /** + * Test for FAILURE + */ - // $site = $this->updateSite([ - // 'buildRuntime' => 'ssr-22', - // 'fallbackFile' => null, - // 'framework' => 'other', - // 'name' => 'Test Site', - // 'outputDirectory' => './', - // 'providerBranch' => 'main', - // 'providerRootDirectory' => './', - // '$id' => $siteId, - // 'specification' => 's-2vcpu-512mb', // Invalid specification - // ]); + $site = $this->updateSite([ + 'buildRuntime' => 'ssr-22', + 'fallbackFile' => null, + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + '$id' => $siteId, + 'specification' => 's-2vcpu-512mb', // Invalid specification + ]); - // var_dump($site); + $this->assertEquals(400, $site['headers']['status-code']); + $this->assertStringStartsWith('Invalid `specification` param: Specification must be one of:', $site['body']['message']); - // $this->assertEquals(400, $site['headers']['status-code']); - // $this->assertStringStartsWith('Invalid `specification` param: Specification must be one of:', $site['body']['message']); - - // $this->cleanupSite($siteId); - // } + $this->cleanupSite($siteId); + } public function testDeleteDeployment(): void { @@ -953,4 +938,6 @@ class SitesCustomServerTest extends Scope $this->assertArrayHasKey('runtimes', $framework); $this->assertArrayHasKey('adapters', $framework); } + + // TODO: Add tests for deletion of resources when site is deleted } From e49d9f39a894fab102e00bb267cd8af6e5dd0957 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 20 Jan 2025 01:18:43 +0530 Subject: [PATCH 08/13] Fix usageTest --- tests/e2e/General/UsageTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index c50a15fd3f..51e8322544 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -937,7 +937,7 @@ class UsageTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals($functionId, $response['body']['functionId']); + $this->assertEquals($functionId, $response['body']['resourceId']); $executionTime += (int) ($response['body']['duration'] * 1000); @@ -961,7 +961,7 @@ class UsageTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals($functionId, $response['body']['functionId']); + $this->assertEquals($functionId, $response['body']['resourceId']); if ($response['body']['status'] == 'failed') { $failures += 1; @@ -984,7 +984,7 @@ class UsageTest extends Scope $this->assertEquals(202, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals($functionId, $response['body']['functionId']); + $this->assertEquals($functionId, $response['body']['resourceId']); sleep(self::WAIT); From 3ee67e620cebfcbefba9cb91ed6048e40f219024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 21 Jan 2025 15:28:37 +0000 Subject: [PATCH 09/13] Resolve conflicts --- composer.lock | 107 +++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 57 deletions(-) diff --git a/composer.lock b/composer.lock index 5622b3a4f9..83d77ab9f0 100644 --- a/composer.lock +++ b/composer.lock @@ -709,16 +709,16 @@ }, { "name": "google/protobuf", - "version": "v4.29.2", + "version": "v4.29.3", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945" + "reference": "ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/79aa5014efeeec3d137df5cdb0ae2fc163953945", - "reference": "79aa5014efeeec3d137df5cdb0ae2fc163953945", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7", + "reference": "ab5077c2cfdd1f415f42d11fdbdf903ba8e3d9b7", "shasum": "" }, "require": { @@ -747,9 +747,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.2" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.29.3" }, - "time": "2024-12-18T14:11:12+00:00" + "time": "2025-01-08T21:00:13+00:00" }, { "name": "jean85/pretty-package-versions", @@ -1237,16 +1237,16 @@ }, { "name": "open-telemetry/api", - "version": "1.1.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed" + "reference": "351a30baa79699de3de3a814c8ccc7b52ccdfb1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/04c85a1e41a3d59fa9bdc801a5de1df6624b95ed", - "reference": "04c85a1e41a3d59fa9bdc801a5de1df6624b95ed", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/351a30baa79699de3de3a814c8ccc7b52ccdfb1d", + "reference": "351a30baa79699de3de3a814c8ccc7b52ccdfb1d", "shasum": "" }, "require": { @@ -1303,7 +1303,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-11-16T04:32:30+00:00" + "time": "2025-01-08T23:50:34+00:00" }, { "name": "open-telemetry/context", @@ -1366,16 +1366,16 @@ }, { "name": "open-telemetry/exporter-otlp", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/exporter-otlp.git", - "reference": "9b6de12204f25f8ab9540b46d6e7b5151897ce18" + "reference": "243d9657c44a06f740cf384f486afe954c2b725f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/9b6de12204f25f8ab9540b46d6e7b5151897ce18", - "reference": "9b6de12204f25f8ab9540b46d6e7b5151897ce18", + "url": "https://api.github.com/repos/opentelemetry-php/exporter-otlp/zipball/243d9657c44a06f740cf384f486afe954c2b725f", + "reference": "243d9657c44a06f740cf384f486afe954c2b725f", "shasum": "" }, "require": { @@ -1426,20 +1426,20 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-04-30T18:28:30+00:00" + "time": "2025-01-08T23:50:03+00:00" }, { "name": "open-telemetry/gen-otlp-protobuf", - "version": "1.2.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d" + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d", + "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/585bafddd4ae6565de154610b10a787a455c9ba0", + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0", "shasum": "" }, "require": { @@ -1489,20 +1489,20 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-10-30T11:49:49+00:00" + "time": "2025-01-15T23:07:07+00:00" }, { "name": "open-telemetry/sdk", - "version": "1.1.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sdk.git", - "reference": "fb0ff8d8279a3776bd604791e2531dd0cc147e8b" + "reference": "9a1c3b866239dbff291e5cc555bb7793eab08127" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/fb0ff8d8279a3776bd604791e2531dd0cc147e8b", - "reference": "fb0ff8d8279a3776bd604791e2531dd0cc147e8b", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/9a1c3b866239dbff291e5cc555bb7793eab08127", + "reference": "9a1c3b866239dbff291e5cc555bb7793eab08127", "shasum": "" }, "require": { @@ -1579,7 +1579,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-10-18T21:01:35+00:00" + "time": "2025-01-08T23:50:34+00:00" }, { "name": "open-telemetry/sem-conv", @@ -3379,16 +3379,16 @@ }, { "name": "utopia-php/compression", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/utopia-php/compression.git", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98" + "reference": "66f093557ba66d98245e562036182016c7dcfe8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/compression/zipball/6062f70596415f8d5de40a589367b0eb2a435f98", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98", + "url": "https://api.github.com/repos/utopia-php/compression/zipball/66f093557ba66d98245e562036182016c7dcfe8a", + "reference": "66f093557ba66d98245e562036182016c7dcfe8a", "shasum": "" }, "require": { @@ -3419,9 +3419,9 @@ ], "support": { "issues": "https://github.com/utopia-php/compression/issues", - "source": "https://github.com/utopia-php/compression/tree/0.1.2" + "source": "https://github.com/utopia-php/compression/tree/0.1.3" }, - "time": "2024-11-08T14:59:54+00:00" + "time": "2025-01-15T15:15:51+00:00" }, { "name": "utopia-php/config", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf", + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.1" + "source": "https://github.com/utopia-php/platform/tree/0.7.2" }, - "time": "2024-10-22T10:27:49+00:00" + "time": "2025-01-15T05:56:26+00:00" }, { "name": "utopia-php/pools", @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.29", + "version": "0.39.30", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7" + "reference": "830198d501f51163514305befefb775106a7198b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7", - "reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/830198d501f51163514305befefb775106a7198b", + "reference": "830198d501f51163514305befefb775106a7198b", "shasum": "" }, "require": { @@ -4852,9 +4852,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.39.29" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.30" }, - "time": "2025-01-07T05:28:35+00:00" + "time": "2025-01-20T06:10:03+00:00" }, { "name": "doctrine/annotations", @@ -5126,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", + "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", "shasum": "" }, "require": { @@ -5188,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-12-30T16:20:10+00:00" + "time": "2025-01-14T16:20:53+00:00" }, { "name": "matthiasmullie/minify", @@ -8555,12 +8555,6 @@ } ], "aliases": [ - { - "package": "appwrite/php-runtimes", - "version": "dev-feat-add-ssr-runtime", - "alias": "0.16.99", - "alias_normalized": "0.16.99.0" - }, { "package": "utopia-php/framework", "version": "dev-fix-prevent-duplicate-compression", @@ -8570,7 +8564,6 @@ ], "minimum-stability": "stable", "stability-flags": { - "appwrite/php-runtimes": 20, "utopia-php/framework": 20 }, "prefer-stable": false, @@ -8596,5 +8589,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 58dc4a02808eb5078751e7b342b15b36feec26eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 3 Feb 2025 16:33:28 +0100 Subject: [PATCH 10/13] Fix tests --- tests/e2e/General/UsageTest.php | 8 ++++---- .../e2e/Services/Functions/FunctionsCustomServerTest.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 7c9c473697..12a3ce3ac2 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -1,4 +1,4 @@ -assertEquals(201, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals($functionId, $response['body']['resourceId']); + $this->assertEquals($functionId, $response['body']['functionId']); $executionTime += (int) ($response['body']['duration'] * 1000); @@ -961,7 +961,7 @@ class UsageTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals($functionId, $response['body']['resourceId']); + $this->assertEquals($functionId, $response['body']['functionId']); if ($response['body']['status'] == 'failed') { $failures += 1; @@ -984,7 +984,7 @@ class UsageTest extends Scope $this->assertEquals(202, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals($functionId, $response['body']['resourceId']); + $this->assertEquals($functionId, $response['body']['functionId']); sleep(self::WAIT); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 3a8653d77f..712d6d3948 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -850,12 +850,12 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(201, $execution['headers']['status-code']); $this->assertNotEmpty($execution['body']['$id']); - $this->assertNotEmpty($execution['body']['resourceId']); + $this->assertNotEmpty($execution['body']['functionId']); $this->assertEquals(true, (new DatetimeValidator())->isValid($execution['body']['$createdAt'])); - $this->assertEquals($data['functionId'], $execution['body']['resourceId']); + $this->assertEquals($data['functionId'], $execution['body']['functionId']); $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals(200, $execution['body']['responseStatusCode']); - $this->assertStringContainsString($execution['body']['resourceId'], $execution['body']['responseBody']); + $this->assertStringContainsString($execution['body']['functionId'], $execution['body']['responseBody']); $this->assertStringContainsString($data['deploymentId'], $execution['body']['responseBody']); $this->assertStringContainsString('Test1', $execution['body']['responseBody']); $this->assertStringContainsString('http', $execution['body']['responseBody']); @@ -941,7 +941,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(1, $executions['body']['total']); $this->assertIsInt($executions['body']['total']); $this->assertCount(1, $executions['body']['executions']); - $this->assertEquals($data['functionId'], $executions['body']['executions'][0]['resourceId']); + $this->assertEquals($data['functionId'], $executions['body']['executions'][0]['functionId']); $executions = $this->listExecutions($data['functionId'], [ 'search' => $data['functionId'], From c5d4378069a6cfc77631a213ae033a0b87b35508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 3 Feb 2025 16:38:07 +0100 Subject: [PATCH 11/13] Remove leftover --- tests/e2e/General/UsageTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 12a3ce3ac2..74ae1c00bc 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -1,4 +1,4 @@ - Date: Tue, 4 Feb 2025 10:51:33 +0100 Subject: [PATCH 12/13] Fix site tests --- app/controllers/api/proxy.php | 6 +++--- app/controllers/api/vcs.php | 2 +- phpunit.xml | 2 +- src/Appwrite/Platform/Modules/Compute/Base.php | 4 ++-- .../Sites/Http/Deployments/CreateDeployment.php | 8 ++++---- .../Sites/Http/Deployments/ListDeployments.php | 6 +++--- .../Modules/Sites/Http/Sites/CreateSite.php | 16 ++++++++-------- .../Modules/Sites/Http/Sites/UpdateSite.php | 12 ++++++------ 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 6df4b94adb..e691077adf 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -426,13 +426,13 @@ App::get('/v1/proxy/subdomains') ->param('resourceType', null, new WhiteList(['function', 'site']), 'Action definition for the rule. Possible values are "function" and "site"') ->param('subdomain', '', new Text(256), 'Subdomain name.') ->inject('response') - ->inject('dbForConsole') - ->action(function (string $resourceType, string $subdomain, Response $response, Database $dbForConsole) { + ->inject('dbForPlatform') + ->action(function (string $resourceType, string $subdomain, Response $response, Database $dbForPlatform) { //TODO: Add tests for this endpoint $resourceDomain = $resourceType === 'site' ? System::getEnv('_APP_DOMAIN_SITES', '') : System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); $domain = $subdomain . '.' . $resourceDomain; - $document = $dbForConsole->findOne('rules', [ + $document = $dbForPlatform->findOne('rules', [ Query::equal('domain', [$domain]), ]); diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 5f0a07dc62..921a840c0a 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -240,7 +240,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $ruleId = md5($domain); $rule = Authorization::skip( - fn () => $dbForConsole->createDocument('rules', new Document([ + fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), 'projectInternalId' => $project->getInternalId(), diff --git a/phpunit.xml b/phpunit.xml index 4c4e55ea4e..598b730908 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" + stopOnFailure="true" > diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index c6e5653724..9ea0ef86c5 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -93,7 +93,7 @@ class Base extends Action ->setTemplate($template); } - public function redeployVcsSite(Request $request, Document $site, Document $project, Document $installation, Database $dbForProject, Database $dbForConsole, Build $queueForBuilds, Document $template, GitHub $github) + public function redeployVcsSite(Request $request, Document $site, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, Build $queueForBuilds, Document $template, GitHub $github) { $deploymentId = ID::unique(); $providerInstallationId = $installation->getAttribute('providerInstallationId', ''); @@ -169,7 +169,7 @@ class Base extends Action $ruleId = md5($domain); $rule = Authorization::skip( - fn () => $dbForConsole->createDocument('rules', new Document([ + fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), 'projectInternalId' => $project->getInternalId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php index 450bb71b02..94bee7bb12 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php @@ -65,7 +65,7 @@ class CreateDeployment extends Action ->inject('request') ->inject('response') ->inject('dbForProject') - ->inject('dbForConsole') + ->inject('dbForPlatform') ->inject('project') ->inject('queueForEvents') ->inject('deviceForSites') @@ -75,7 +75,7 @@ class CreateDeployment extends Action ->callback([$this, 'action']); } - public function action(string $siteId, ?string $installCommand, ?string $buildCommand, ?string $outputDirectory, mixed $code, mixed $activate, Request $request, Response $response, Database $dbForProject, Database $dbForConsole, Document $project, Event $queueForEvents, Device $deviceForSites, Device $deviceForFunctions, Device $deviceForLocal, Build $queueForBuilds) + public function action(string $siteId, ?string $installCommand, ?string $buildCommand, ?string $outputDirectory, mixed $code, mixed $activate, Request $request, Response $response, Database $dbForProject, Database $dbForPlatform, Document $project, Event $queueForEvents, Device $deviceForSites, Device $deviceForFunctions, Device $deviceForLocal, Build $queueForBuilds) { $activate = \strval($activate) === 'true' || \strval($activate) === '1'; @@ -225,7 +225,7 @@ class CreateDeployment extends Action $ruleId = md5($domain); $rule = Authorization::skip( - fn () => $dbForConsole->createDocument('rules', new Document([ + fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), 'projectInternalId' => $project->getInternalId(), @@ -280,7 +280,7 @@ class CreateDeployment extends Action $ruleId = md5($domain); $rule = Authorization::skip( - fn () => $dbForConsole->createDocument('rules', new Document([ + fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), 'projectInternalId' => $project->getInternalId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php index f32a597837..7ad71e7212 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php @@ -54,11 +54,11 @@ class ListDeployments extends Action ->inject('response') ->inject('project') ->inject('dbForProject') - ->inject('dbForConsole') + ->inject('dbForPlatform') ->callback([$this, 'action']); } - public function action(string $siteId, array $queries, string $search, Response $response, Document $project, Database $dbForProject, Database $dbForConsole) + public function action(string $siteId, array $queries, string $search, Response $response, Document $project, Database $dbForProject, Database $dbForPlatform) { $site = $dbForProject->getDocument('sites', $siteId); @@ -118,7 +118,7 @@ class ListDeployments extends Action $result->setAttribute('buildSize', $build->getAttribute('size', 0)); $result->setAttribute('size', $result->getAttribute('size', 0)); - $rule = Authorization::skip(fn () => $dbForConsole->findOne('rules', [ + $rule = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [ Query::equal("projectInternalId", [$project->getInternalId()]), Query::equal("resourceType", ["deployment"]), Query::equal("resourceInternalId", [$result->getInternalId()]) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index 1d67a1d5c4..5d19899af9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -90,12 +90,12 @@ class CreateSite extends Base ->inject('user') ->inject('queueForEvents') ->inject('queueForBuilds') - ->inject('dbForConsole') + ->inject('dbForPlatform') ->inject('gitHub') ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $adapter, string $installationId, ?string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $adapter, string $installationId, ?string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github) { if (!empty($adapter)) { $configFramework = Config::getParam('frameworks')[$framework] ?? []; @@ -114,7 +114,7 @@ class CreateSite extends Base $routeSubdomain = $subdomain ?: ID::unique(); $domain = "{$routeSubdomain}.{$sitesDomain}"; - $subdomain = Authorization::skip(fn () => $dbForConsole->getDocument('rules', \md5($domain))); + $subdomain = Authorization::skip(fn () => $dbForPlatform->getDocument('rules', \md5($domain))); if ($subdomain && !$subdomain->isEmpty()) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Subdomain already exists. Please choose a different subdomain.'); @@ -143,7 +143,7 @@ class CreateSite extends Base ->setAttribute('version', $templateVersion); } - $installation = $dbForConsole->getDocument('installations', $installationId); + $installation = $dbForPlatform->getDocument('installations', $installationId); if (!empty($installationId) && $installation->isEmpty()) { throw new Exception(Exception::INSTALLATION_NOT_FOUND); @@ -184,7 +184,7 @@ class CreateSite extends Base if (!empty($providerRepositoryId)) { $teamId = $project->getAttribute('teamId', ''); - $repository = $dbForConsole->createDocument('repositories', new Document([ + $repository = $dbForPlatform->createDocument('repositories', new Document([ '$id' => ID::unique(), '$permissions' => [ Permission::read(Role::team(ID::custom($teamId))), @@ -212,7 +212,7 @@ class CreateSite extends Base if (!empty($providerRepositoryId)) { // Deploy VCS - $this->redeployVcsSite($request, $site, $project, $installation, $dbForProject, $dbForConsole, $queueForBuilds, $template, $github); + $this->redeployVcsSite($request, $site, $project, $installation, $dbForProject, $dbForPlatform, $queueForBuilds, $template, $github); } elseif (!$template->isEmpty()) { // Deploy non-VCS from template $deploymentId = ID::unique(); @@ -241,7 +241,7 @@ class CreateSite extends Base $previewDomain = "{$deploymentId}-{$projectId}.{$sitesDomain}"; $rule = Authorization::skip( - fn () => $dbForConsole->createDocument('rules', new Document([ + fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => \md5($previewDomain), 'projectId' => $project->getId(), 'projectInternalId' => $project->getInternalId(), @@ -263,7 +263,7 @@ class CreateSite extends Base if (!empty($sitesDomain)) { $rule = Authorization::skip( - fn () => $dbForConsole->createDocument('rules', new Document([ + fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => \md5($domain), 'projectId' => $project->getId(), 'projectInternalId' => $project->getInternalId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php index af8b2f2c12..e888826d5e 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php @@ -82,12 +82,12 @@ class UpdateSite extends Base ->inject('project') ->inject('queueForEvents') ->inject('queueForBuilds') - ->inject('dbForConsole') + ->inject('dbForPlatform') ->inject('gitHub') ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $adapter, ?string $fallbackFile, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $adapter, ?string $fallbackFile, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github) { if (!empty($adapter)) { $configFramework = Config::getParam('frameworks')[$framework] ?? []; @@ -105,7 +105,7 @@ class UpdateSite extends Base throw new Exception(Exception::SITE_NOT_FOUND); } - $installation = $dbForConsole->getDocument('installations', $installationId); + $installation = $dbForPlatform->getDocument('installations', $installationId); if (!empty($installationId) && $installation->isEmpty()) { throw new Exception(Exception::INSTALLATION_NOT_FOUND); @@ -132,7 +132,7 @@ class UpdateSite extends Base // Git disconnect logic. Disconnecting only when providerRepositoryId is empty, allowing for continue updates without disconnecting git if ($isConnected && ($providerRepositoryId !== null && empty($providerRepositoryId))) { - $repositories = $dbForConsole->find('repositories', [ + $repositories = $dbForPlatform->find('repositories', [ Query::equal('projectInternalId', [$project->getInternalId()]), Query::equal('resourceInternalId', [$site->getInternalId()]), Query::equal('resourceType', ['site']), @@ -140,7 +140,7 @@ class UpdateSite extends Base ]); foreach ($repositories as $repository) { - $dbForConsole->deleteDocument('repositories', $repository->getId()); + $dbForPlatform->deleteDocument('repositories', $repository->getId()); } $providerRepositoryId = ''; @@ -156,7 +156,7 @@ class UpdateSite extends Base if (!$isConnected && !empty($providerRepositoryId)) { $teamId = $project->getAttribute('teamId', ''); - $repository = $dbForConsole->createDocument('repositories', new Document([ + $repository = $dbForPlatform->createDocument('repositories', new Document([ '$id' => ID::unique(), '$permissions' => [ Permission::read(Role::team(ID::custom($teamId))), From d272a474ab8746cb6e85e02fd45c4c4c98198b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 4 Feb 2025 10:51:44 +0100 Subject: [PATCH 13/13] Update phpunit.xml --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 598b730908..4c4e55ea4e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="true" + stopOnFailure="false" >