From 0a335ed8ac114e2912612c78fd7c6f9295c73770 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:13:15 +0530 Subject: [PATCH] Add appwrite version --- app/controllers/api/functions.php | 1 + app/controllers/general.php | 1 + src/Appwrite/Platform/Workers/Builds.php | 1 + src/Appwrite/Platform/Workers/Functions.php | 1 + tests/e2e/Services/Functions/FunctionsCustomClientTest.php | 2 ++ tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 1 + tests/resources/functions/php-fn/index.php | 1 + tests/resources/functions/php-large/index.php | 1 + tests/resources/functions/php/index.php | 1 + 9 files changed, 10 insertions(+) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 21788d2a23..491dea6b80 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1793,6 +1793,7 @@ App::post('/v1/functions/:functionId/executions') 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE ]); /** Execute function */ diff --git a/app/controllers/general.php b/app/controllers/general.php index 92ddec58f5..b4fc3df34e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -250,6 +250,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE ]); /** Execute function */ diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 53fc589cc1..922498c3fa 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -400,6 +400,7 @@ class Builds extends Action 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE ]); $command = $deployment->getAttribute('commands', ''); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 5285e03e21..d4d6f75966 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -462,6 +462,7 @@ class Functions extends Action 'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(), 'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'] ?? '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE ]); /** Execute function */ diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 6274f5ddae..222716947f 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -314,6 +314,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); + $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); @@ -698,6 +699,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); + $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index f35776455b..dfbfaa6c01 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1265,6 +1265,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); $this->assertEquals($runtimeName, $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals($runtimeVersion, $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); + $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals('variable', $output['CUSTOM_VARIABLE']); diff --git a/tests/resources/functions/php-fn/index.php b/tests/resources/functions/php-fn/index.php index 3eea2d6fea..5fc8ed0437 100644 --- a/tests/resources/functions/php-fn/index.php +++ b/tests/resources/functions/php-fn/index.php @@ -10,6 +10,7 @@ return function ($context) { 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE, 'APPWRITE_FUNCTION_EVENT' => $context->req->headers['x-appwrite-event'] ?? '', 'APPWRITE_FUNCTION_EVENT_DATA' => $context->req->bodyRaw ?? '', 'APPWRITE_FUNCTION_DATA' => $context->req->bodyRaw ?? '', diff --git a/tests/resources/functions/php-large/index.php b/tests/resources/functions/php-large/index.php index 5a9666488e..1f408cc1af 100644 --- a/tests/resources/functions/php-large/index.php +++ b/tests/resources/functions/php-large/index.php @@ -8,6 +8,7 @@ return function ($context) { 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE, 'UNICODE_TEST' => "êä" ]); }; diff --git a/tests/resources/functions/php/index.php b/tests/resources/functions/php/index.php index ac7b85a43a..d56ed3a5bb 100644 --- a/tests/resources/functions/php/index.php +++ b/tests/resources/functions/php/index.php @@ -8,6 +8,7 @@ return function ($context) { 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', + 'APPWRITE_VERSION' => APP_VERSION_STABLE, 'UNICODE_TEST' => "êä", 'GLOBAL_VARIABLE' => \getenv('GLOBAL_VARIABLE') ?: '' ]);