diff --git a/app/config/collections.php b/app/config/collections.php index 7678b9c697..15471c8c77 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1915,7 +1915,18 @@ $collections = [ 'filters' => [], ], [ - '$id' => 'functionId', + '$id' => 'resourceId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'resourceType', 'type' => Database::VAR_STRING, 'format' => '', 'size' => Database::LENGTH_KEY, @@ -1981,39 +1992,6 @@ $collections = [ 'array' => false, 'filters' => [], ], - [ - '$id' => 'status', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'buildStdout', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4096, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'buildStderr', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4096, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], [ '$id' => 'deploy', 'type' => Database::VAR_BOOLEAN, @@ -2028,9 +2006,16 @@ $collections = [ ], 'indexes' => [ [ - '$id' => '_key_function', + '$id' => '_key_resource', 'type' => Database::INDEX_KEY, - 'attributes' => ['functionId'], + 'attributes' => ['resourceId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_resource_type', + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceType'], 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], ], @@ -2050,7 +2035,7 @@ $collections = [ 'name' => 'Builds', 'attributes' => [ [ - '$id' => 'dateCreated', + '$id' => 'startTime', 'type' => Database::VAR_INTEGER, 'format' => '', 'size' => 0, @@ -2060,6 +2045,39 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => 'endTime', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'duration', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'deploymentId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => 'runtime', 'type' => Database::VAR_STRING, @@ -2115,28 +2133,6 @@ $collections = [ 'array' => false, 'filters' => [], ], - [ - '$id' => 'time', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'vars', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => new stdClass(), - 'array' => false, - 'filters' => ['json'], - ], [ '$id' => 'sourceType', 'type' => Database::VAR_STRING, @@ -2158,18 +2154,7 @@ $collections = [ 'default' => '', 'array' => false, 'filters' => [], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + ] ], 'indexes' => [ [ @@ -2178,14 +2163,7 @@ $collections = [ 'attributes' => ['status'], 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], + ] ], ], diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f30adfc096..3c1da0b370 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -554,7 +554,8 @@ App::post('/v1/functions/:functionId/deployments') // Remove deploy for all other deployments. $deployments = $dbForProject->find('deployments', [ new Query('deploy', Query::TYPE_EQUAL, [true]), - new Query('functionId', Query::TYPE_EQUAL, [$functionId]) + new Query('resourceId', Query::TYPE_EQUAL, [$functionId]), + new Query('resourceType', Query::TYPE_EQUAL, ['functions']) ]); foreach ($deployments as $deployment) { @@ -568,15 +569,13 @@ App::post('/v1/functions/:functionId/deployments') '$id' => $deploymentId, '$read' => ['role:all'], '$write' => ['role:all'], - 'functionId' => $function->getId(), + 'resourceId' => $function->getId(), + 'resourceType' => 'functions', 'dateCreated' => time(), 'entrypoint' => $entrypoint, 'path' => $path, 'size' => $size, 'search' => implode(' ', [$deploymentId, $entrypoint]), - 'status' => 'processing', - 'buildStdout' => '', - 'buildStderr' => '', 'deploy' => ($deploy === 'true'), ])); @@ -641,18 +640,17 @@ App::get('/v1/functions/:functionId/deployments') $queries[] = new Query('search', Query::TYPE_SEARCH, [$search]); } - $queries[] = new Query('functionId', Query::TYPE_EQUAL, [$function->getId()]); + $queries[] = new Query('resourceId', Query::TYPE_EQUAL, [$function->getId()]); + $queries[] = new Query('resourceType', Query::TYPE_EQUAL, ['functions']); $results = $dbForProject->find('deployments', $queries, $limit, $offset, [], [$orderType], $cursorDeployment ?? null, $cursorDirection); $sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT); - // Get Current Build Data - foreach ($results as &$deployment) { - $build = $dbForProject->getDocument('builds', $deployment->getAttribute('buildId', '')); - - $deployment['status'] = $build->getAttribute('status', 'processing'); - $deployment['buildStdout'] = $build->getAttribute('stdout', ''); - $deployment['buildStderr'] = $build->getAttribute('stderr', ''); + foreach ($results as $result) { + $build = $dbForProject->getDocument('builds', $result->getAttribute('buildId')); + $result->setAttribute('status', $build->getAttribute('status', 'pending')); + $result->setAttribute('buildStderr', $build->getAttribute('stderr', '')); + $result->setAttribute('buildStdout', $build->getAttribute('stdout', '')); } $response->dynamic(new Document([ @@ -688,7 +686,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId') $deployment = $dbForProject->getDocument('deployments', $deploymentId); - if ($deployment->getAttribute('functionId') !== $function->getId()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception('Deployment not found', 404); } @@ -730,7 +728,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId') $deployment = $dbForProject->getDocument('deployments', $deploymentId); - if ($deployment->getAttribute('functionId') !== $function->getId()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception('Deployment not found', 404); } @@ -823,7 +821,7 @@ App::post('/v1/functions/:functionId/executions') $deployment = Authorization::skip(fn() => $dbForProject->getDocument('deployments', $function->getAttribute('deployment'))); - if ($deployment->getAttribute('functionId') !== $function->getId()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404); } @@ -1021,76 +1019,6 @@ App::get('/v1/functions/:functionId/executions/:executionId') $response->dynamic($execution, Response::MODEL_EXECUTION); }); -App::get('/v1/builds') -->groups(['api', 'functions']) -->desc('List Builds') -->label('scope', 'functions.read') -->label('sdk.auth', [APP_AUTH_TYPE_KEY]) -->label('sdk.namespace', 'functions') -->label('sdk.method', 'builds') -->label('sdk.description', '/docs/references/functions/list-builds.md') -->label('sdk.response.code', Response::STATUS_CODE_OK) -->label('sdk.response.type', Response::CONTENT_TYPE_JSON) -->label('sdk.response.model', Response::MODEL_BUILD_LIST) -->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) -->param('limit', 25, new Range(0, 100), 'Maximum number of builds to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) -->param('offset', 0, new Range(0, APP_LIMIT_COUNT), 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) -->param('cursor', '', new UID(), 'ID of the function used as the starting point for the query, excluding the function itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) -->param('cursorDirection', Database::CURSOR_AFTER, new WhiteList([Database::CURSOR_AFTER, Database::CURSOR_BEFORE]), 'Direction of the cursor.', true) -->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) -->inject('response') -->inject('dbForProject') -->action(function ($search, $limit, $offset, $cursor, $cursorDirection, $orderType, $response, $dbForProject) { - /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\Database\Database $dbForProject */ - - if (!empty($cursor)) { - $cursorFunction = $dbForProject->getDocument('builds', $cursor); - - if ($cursorFunction->isEmpty()) { - throw new Exception("Build '{$cursor}' for the 'cursor' value not found.", 400); - } - } - - $queries = []; - - if (!empty($search)) { - $queries[] = new Query('search', Query::TYPE_SEARCH, [$search]); - } - - $response->dynamic(new Document([ - 'builds' => $dbForProject->find('builds', $queries, $limit, $offset, [], [$orderType], $cursorFunction ?? null, $cursorDirection), - 'sum' => $dbForProject->count('builds', $queries, APP_LIMIT_COUNT), - ]), Response::MODEL_BUILD_LIST); -}); - -App::get('/v1/builds/:buildId') - ->groups(['api', 'functions']) - ->desc('Get Build') - ->label('scope', 'execution.read') - ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) - ->label('sdk.namespace', 'functions') - ->label('sdk.method', 'getBuild') - ->label('sdk.description', '/docs/references/functions/get-build.md') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_BUILD) - ->param('buildId', '', new UID(), 'Build unique ID.') - ->inject('response') - ->inject('dbForProject') - ->action(function ($buildId, $response, $dbForProject) { - /** @var Appwrite\Utopia\Response $response */ - /** @var Utopia\Database\Database $dbForProject */ - - $build = Authorization::skip(fn() => $dbForProject->getDocument('builds', $buildId)); - - if ($build->isEmpty()) { - throw new Exception('Build not found', 404); - } - - $response->dynamic($build, Response::MODEL_BUILD); - }); - App::post('/v1/builds/:buildId') ->groups(['api', 'functions']) ->desc('Retry Build') diff --git a/app/executor.php b/app/executor.php index 2e966055fe..19f8946087 100644 --- a/app/executor.php +++ b/app/executor.php @@ -183,7 +183,7 @@ function createRuntimeServer(string $functionId, string $projectId, string $depl // Check if runtime is active $runtime = $runtimes[$function->getAttribute('runtime', '')] ?? null; - if ($deployment->getAttribute('functionId') !== $function->getId()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception('deployment not found', 404); } @@ -193,6 +193,7 @@ function createRuntimeServer(string $functionId, string $projectId, string $depl // Process environment variables $vars = \array_merge($function->getAttribute('vars', []), [ + 'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint', ''), 'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), @@ -202,8 +203,6 @@ function createRuntimeServer(string $functionId, string $projectId, string $depl 'INTERNAL_RUNTIME_KEY' => $secret ]); - $vars = \array_merge($vars, $build->getAttribute('vars', [])); // for gettng endpoint. - $container = 'appwrite-function-' . $deployment->getId(); if ($activeFunctions->exists($container) && !(\substr($activeFunctions->get($container)['status'], 0, 2) === 'Up')) { // Remove container if not online @@ -335,7 +334,7 @@ function execute(string $trigger, string $projectId, string $executionId, string $deployment = $database->getDocument('deployments', $function->getAttribute('deployment', '')); $build = $database->getDocument('builds', $deployment->getAttribute('buildId', '')); - if ($deployment->getAttribute('functionId') !== $function->getId()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception('Deployment not found', 404); } @@ -386,6 +385,7 @@ function execute(string $trigger, string $projectId, string $executionId, string // Process environment variables $vars = \array_merge($function->getAttribute('vars', []), [ + 'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint', ''), 'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), @@ -400,8 +400,6 @@ function execute(string $trigger, string $projectId, string $executionId, string 'APPWRITE_FUNCTION_PROJECT_ID' => $projectId, ]); - $vars = \array_merge($vars, $build->getAttribute('vars', [])); - $container = 'appwrite-function-' . $deployment->getId(); try { @@ -412,7 +410,8 @@ function execute(string $trigger, string $projectId, string $executionId, string '$id' => $buildId, '$read' => ($userId !== '') ? ['user:' . $userId] : [], '$write' => [], - 'dateCreated' => time(), + 'startTime' => time(), + 'deploymentId' => $deployment->getId(), 'status' => 'processing', 'outputPath' => '', 'runtime' => $function->getAttribute('runtime', ''), @@ -420,15 +419,8 @@ function execute(string $trigger, string $projectId, string $executionId, string 'sourceType' => Storage::DEVICE_LOCAL, 'stdout' => '', 'stderr' => '', - 'time' => 0, - 'vars' => [ - 'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint'), - 'APPWRITE_FUNCTION_ID' => $function->getId(), - 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), - 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'], - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'], - 'APPWRITE_FUNCTION_PROJECT_ID' => $projectId, - ] + 'endTime' => 0, + 'duration' => 0 ])); $deployment->setAttribute('buildId', $buildId); @@ -482,6 +474,7 @@ function execute(string $trigger, string $projectId, string $executionId, string // Process environment variables $vars = \array_merge($function->getAttribute('vars', []), [ + 'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint', ''), 'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), @@ -496,8 +489,6 @@ function execute(string $trigger, string $projectId, string $executionId, string 'APPWRITE_FUNCTION_PROJECT_ID' => $projectId ]); - $vars = \array_merge($vars, $build->getAttribute('vars', [])); - $stdout = ''; $stderr = ''; @@ -518,7 +509,7 @@ function execute(string $trigger, string $projectId, string $executionId, string $body = \json_encode([ 'path' => '/usr/code', - 'file' => $build->getAttribute('vars', [])['ENTRYPOINT_NAME'], + 'file' => $vars['ENTRYPOINT_NAME'], 'env' => $vars, 'payload' => $data, 'timeout' => $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)) @@ -682,6 +673,10 @@ function runBuildStage(string $buildId, string $deploymentId, string $projectID) $build = $database->getDocument('builds', $buildId); $deployment = $database->getDocument('deployments', $deploymentId); + + // Start tracking time + $buildStart = \time(); + try { // If we already have a built package ready there is no need to rebuild. if ($build->getAttribute('status') === 'ready' && \file_exists($build->getAttribute('outputPath'))) { @@ -734,11 +729,25 @@ function runBuildStage(string $buildId, string $deploymentId, string $projectID) throw new Exception('Code is not readable: ' . $build->getAttribute('source', '')); } - $vars = $build->getAttribute('vars', []); + $deployment = $database->getDocument('deployments', $build->getAttribute('deploymentId', '')); + $resourceId = $deployment->getAttribute('resourceId', ''); + $resourceType = $deployment->getAttribute('resourceType', ''); - // Start tracking time - $buildStart = \microtime(true); - $time = \time(); + if (empty($resourceId)) { + throw new Exception('Invalid resource ID on build ' . $build->getId()); + } + + if (empty($resourceType)) { + throw new Exception('Invalid resource type on build' . $build->getId()); + } + + $resource = $database->getDocument($resourceType, $resourceId); + + if ($resource->isEmpty()) { + throw new Exception('Resource not found on build ' . $build->getId()); + } + + $vars = $resource->getAttribute('vars', []); $orchestration ->setCpus(App::getEnv('_APP_FUNCTIONS_CPUS', 0)) @@ -764,7 +773,7 @@ function runBuildStage(string $buildId, string $deploymentId, string $projectID) workdir: '/usr/code', labels: [ 'appwrite-type' => 'function', - 'appwrite-created' => strval($time), + 'appwrite-created' => strval($buildStart), 'appwrite-runtime' => $build->getAttribute('runtime', ''), 'appwrite-project' => $projectID, 'appwrite-build' => $buildId, @@ -878,22 +887,24 @@ function runBuildStage(string $buildId, string $deploymentId, string $projectID) ->setAttribute('status', 'ready') ->setAttribute('stdout', \utf8_encode(\mb_substr($buildStdout, -4096))) ->setAttribute('stderr', \utf8_encode(\mb_substr($buildStderr, -4096))) - ->setAttribute('time', $time); + ->setAttribute('startTime', $buildStart) + ->setAttribute('endTime', \time()) + ->setAttribute('duration', \time() - $buildStart); // Update build with built code attribute $build = $database->updateDocument('builds', $buildId, $build); - $deployment->setAttribute('status', 'ready'); - $database->updateDocument('deployments', $deploymentId, $deployment); - - $buildEnd = \microtime(true); + $buildEnd = \time(); Console::info('Build Stage Ran in ' . ($buildEnd - $buildStart) . ' seconds'); } catch (Exception $e) { $build ->setAttribute('status', 'failed') ->setAttribute('stdout', \utf8_encode(\mb_substr($buildStdout, -4096))) - ->setAttribute('stderr', \utf8_encode(\mb_substr($e->getMessage(), -4096))); + ->setAttribute('stderr', \utf8_encode(\mb_substr($e->getMessage(), -4096))) + ->setAttribute('startTime', $buildStart) + ->setAttribute('endTime', \microtime(true)) + ->setAttribute('duration', \microtime(true) - $buildStart); $build = $database->updateDocument('builds', $buildId, $build); diff --git a/app/workers/builds.php b/app/workers/builds.php index ac20e0031a..21236c2da3 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -137,7 +137,6 @@ class BuildsV1 extends Worker ] ])); } catch (\Throwable $th) { - $deployment->setAttribute('status', 'failed'); $deployment->setAttribute('buildId', ''); $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); Console::error($th->getMessage()); @@ -151,8 +150,6 @@ class BuildsV1 extends Worker $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); $this->createBuild($projectId, $functionId, $deploymentId, $buildId); } catch (\Throwable $th) { - $deployment->setAttribute('status', 'failed'); - $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); Console::error($th->getMessage()); throw $th; } diff --git a/src/Appwrite/Utopia/Response/Model/Build.php b/src/Appwrite/Utopia/Response/Model/Build.php index fbf55a4a25..218e82d5e3 100644 --- a/src/Appwrite/Utopia/Response/Model/Build.php +++ b/src/Appwrite/Utopia/Response/Model/Build.php @@ -16,12 +16,18 @@ class Build extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) - ->addRule('dateCreated', [ + ->addRule('startTime', [ 'type' => self::TYPE_INTEGER, 'description' => 'The deployment creation date in Unix timestamp.', 'default' => 0, 'example' => 1592981250, ]) + ->addRule('deploymentId', [ + 'type' => self::TYPE_STRING, + 'description' => 'The deployment that created this build', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) // Build Status // Failed - The deployment build has failed. More details can usually be found in buildStderr // Ready - The deployment build was successful and the deployment is ready to be deployed @@ -45,7 +51,13 @@ class Build extends Model 'default' => '', 'example' => '', ]) - ->addRule('time', [ + ->addRule('endTime', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'The time the build was finished in Unix timestamp.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('duration', [ 'type' => self::TYPE_INTEGER, 'description' => 'The build time in seconds.', 'default' => 0, diff --git a/src/Appwrite/Utopia/Response/Model/Deployment.php b/src/Appwrite/Utopia/Response/Model/Deployment.php index db1f518c92..28a01ad6c0 100644 --- a/src/Appwrite/Utopia/Response/Model/Deployment.php +++ b/src/Appwrite/Utopia/Response/Model/Deployment.php @@ -16,12 +16,18 @@ class Deployment extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) - ->addRule('functionId', [ + ->addRule('resourceId', [ 'type' => self::TYPE_STRING, - 'description' => 'Function ID.', + 'description' => 'Resource ID.', 'default' => '', 'example' => '5e5ea6g16897e', ]) + ->addRule('resourceType', [ + 'type' => self::TYPE_STRING, + 'description' => 'Resource type.', + 'default' => '', + 'example' => 'functions', + ]) ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'The deployment creation date in Unix timestamp.', @@ -30,7 +36,7 @@ class Deployment extends Model ]) ->addRule('entrypoint', [ 'type' => self::TYPE_STRING, - 'description' => 'The entrypoint file to use to execute the delpoyment code.', + 'description' => 'The entrypoint file to use to execute the deployment code.', 'default' => '', 'example' => 'enabled', ]) @@ -40,41 +46,36 @@ class Deployment extends Model 'default' => 0, 'example' => 128, ]) - // Build Status - // Failed - The deployment build has failed. More details can usually be found in buildStderr - // Ready - The deployment build was successful and the deployment is ready to be deployed - // Processing - The deployment is currently waiting to have a build triggered - // Building - The deployment is currently being built - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'The deployment\'s current built status', - 'default' => '', - 'example' => 'ready', - ]) ->addRule('buildId', [ 'type' => self::TYPE_STRING, 'description' => 'The current build ID.', 'default' => '', 'example' => '5e5ea5c16897e', ]) - ->addRule('buildStdout', [ - 'type' => self::TYPE_STRING, - 'description' => 'The stdout of the build.', - 'default' => '', - 'example' => '', - ]) - ->addRule('buildStderr', [ - 'type' => self::TYPE_STRING, - 'description' => 'The stderr of the build.', - 'default' => '', - 'example' => '', - ]) ->addRule('deploy', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Whether the deployment should be automatically deployed.', 'default' => false, 'example' => true, ]) + ->addRule('status', [ + 'type' => self::TYPE_STRING, + 'description' => 'The deployment status.', + 'default' => '', + 'example' => 'enabled', + ]) + ->addRule('buildStdout', [ + 'type' => self::TYPE_STRING, + 'description' => 'The build stdout.', + 'default' => '', + 'example' => 'enabled', + ]) + ->addRule('buildStderr', [ + 'type' => self::TYPE_STRING, + 'description' => 'The build stderr.', + 'default' => '', + 'example' => 'enabled', + ]) ; } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index a9e9096fe6..ce220806bb 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -331,38 +331,6 @@ class FunctionsCustomServerTest extends Scope return $data; } - /** - * @depends testCreateDeployment - */ - public function testListBuild(array $data):array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/builds', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(1, $response['body']['sum']); - $this->assertEquals($response['body']['builds'][0]['status'], 'ready'); - - /** - * Check Queries work - */ - $responseQuery = $this->client->call(Client::METHOD_GET, '/builds?status=status.equal(\"ready\")', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(200, $responseQuery['headers']['status-code']); - $this->assertEquals(1, $responseQuery['body']['sum']); - $this->assertEquals($responseQuery['body']['builds'][0]['status'], 'ready'); - - return $data; - } - /** * @depends testCreateDeployment */