From ec174c179f0284aeab0ec913427621f2e58a90a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 28 Aug 2023 16:23:16 +0200 Subject: [PATCH 1/4] Update compose.phtml --- app/views/install/compose.phtml | 193 ++++++++++++++++++++++++-------- 1 file changed, 148 insertions(+), 45 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 4d8f4510f8..a3656b5f36 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -88,8 +88,6 @@ services: - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS - _APP_CONSOLE_WHITELIST_IPS - - _APP_CONSOLE_INVITES - - _APP_CONSOLE_ROOT_SESSION - _APP_SYSTEM_EMAIL_NAME - _APP_SYSTEM_EMAIL_ADDRESS - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS @@ -100,16 +98,15 @@ services: - _APP_DOMAIN - _APP_DOMAIN_TARGET - _APP_DOMAIN_FUNCTIONS + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_CONNECTIONS_MAX - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_SMTP_HOST - _APP_SMTP_PORT - _APP_SMTP_SECURE @@ -123,7 +120,27 @@ services: - _APP_STORAGE_ANTIVIRUS - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT - - _APP_CONNECTIONS_STORAGE + - _APP_STORAGE_DEVICE + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_FUNCTIONS_SIZE_LIMIT - _APP_FUNCTIONS_TIMEOUT - _APP_FUNCTIONS_BUILD_TIMEOUT @@ -148,6 +165,15 @@ services: - _APP_GRAPHQL_MAX_BATCH_SIZE - _APP_GRAPHQL_MAX_COMPLEXITY - _APP_GRAPHQL_MAX_DEPTH + - _APP_VCS_GITHUB_APP_NAME + - _APP_VCS_GITHUB_PRIVATE_KEY + - _APP_VCS_GITHUB_APP_ID + - _APP_VCS_GITHUB_WEBHOOK_SECRET + - _APP_VCS_GITHUB_CLIENT_SECRET + - _APP_VCS_GITHUB_CLIENT_ID + - _APP_MIGRATIONS_FIREBASE_CLIENT_ID + - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET + - _APP_ASSISTANT_OPENAI_API_KEY appwrite-realtime: image: /: @@ -180,16 +206,15 @@ services: - _APP_WORKER_PER_CORE - _APP_OPTIONS_ABUSE - _APP_OPENSSL_KEY_V1 + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_CONNECTIONS_MAX - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_USAGE_STATS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG @@ -207,16 +232,17 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG @@ -233,6 +259,7 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS - _APP_REDIS_HOST @@ -261,17 +288,38 @@ services: - appwrite-certificates:/storage/certificates:rw environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - - _APP_CONNECTIONS_STORAGE + - _APP_STORAGE_DEVICE + - _APP_STORAGE_S3_ACCESS_KEY + - _APP_STORAGE_S3_SECRET + - _APP_STORAGE_S3_REGION + - _APP_STORAGE_S3_BUCKET + - _APP_STORAGE_DO_SPACES_ACCESS_KEY + - _APP_STORAGE_DO_SPACES_SECRET + - _APP_STORAGE_DO_SPACES_REGION + - _APP_STORAGE_DO_SPACES_BUCKET + - _APP_STORAGE_BACKBLAZE_ACCESS_KEY + - _APP_STORAGE_BACKBLAZE_SECRET + - _APP_STORAGE_BACKBLAZE_REGION + - _APP_STORAGE_BACKBLAZE_BUCKET + - _APP_STORAGE_LINODE_ACCESS_KEY + - _APP_STORAGE_LINODE_SECRET + - _APP_STORAGE_LINODE_REGION + - _APP_STORAGE_LINODE_BUCKET + - _APP_STORAGE_WASABI_ACCESS_KEY + - _APP_STORAGE_WASABI_SECRET + - _APP_STORAGE_WASABI_REGION + - _APP_STORAGE_WASABI_BUCKET - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_EXECUTOR_SECRET @@ -290,16 +338,17 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG @@ -316,9 +365,14 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA @@ -330,6 +384,15 @@ services: - _APP_REDIS_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG + - _APP_VCS_GITHUB_APP_NAME + - _APP_VCS_GITHUB_PRIVATE_KEY + - _APP_VCS_GITHUB_APP_ID + - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY + - _APP_OPTIONS_FORCE_HTTPS + - _APP_DOMAIN appwrite-worker-certificates: image: /: @@ -347,20 +410,21 @@ services: - appwrite-certificates:/storage/certificates:rw environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_DOMAIN - _APP_DOMAIN_TARGET - _APP_DOMAIN_FUNCTIONS - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG @@ -378,20 +442,28 @@ services: - openruntimes-executor environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT + - _APP_FUNCTIONS_CPUS + - _APP_FUNCTIONS_MEMORY - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST - _APP_USAGE_STATS + - _APP_DOCKER_HUB_USERNAME + - _APP_DOCKER_HUB_PASSWORD + - _APP_LOGGING_CONFIG + - _APP_LOGGING_PROVIDER appwrite-worker-mails: image: /: @@ -405,6 +477,7 @@ services: - redis environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_SYSTEM_EMAIL_NAME - _APP_SYSTEM_EMAIL_ADDRESS @@ -432,6 +505,7 @@ services: - redis environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_REDIS_USER @@ -453,25 +527,27 @@ services: - redis environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_DOMAIN - _APP_DOMAIN_TARGET - _APP_DOMAIN_FUNCTIONS + - _APP_REDIS_HOST + - _APP_REDIS_PORT + - _APP_REDIS_USER + - _APP_REDIS_PASS - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_MAINTENANCE_INTERVAL - _APP_MAINTENANCE_RETENTION_EXECUTION - _APP_MAINTENANCE_RETENTION_CACHE - _APP_MAINTENANCE_RETENTION_ABUSE - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY + - _APP_MAINTENANCE_RETENTION_SCHEDULES appwrite-usage: image: /: @@ -486,19 +562,20 @@ services: - mariadb environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 - _APP_DB_HOST - _APP_DB_PORT - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_INFLUXDB_HOST + - _APP_INFLUXDB_PORT - _APP_USAGE_AGGREGATION_INTERVAL - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_REDIS_USER - _APP_REDIS_PASS - - _APP_INFLUXDB_HOST - - _APP_INFLUXDB_PORT - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG @@ -514,17 +591,23 @@ services: - redis environment: - _APP_ENV + - _APP_WORKER_PER_CORE - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_REDIS_USER - _APP_REDIS_PASS + - _APP_DB_HOST + - _APP_DB_PORT + - _APP_DB_SCHEMA + - _APP_DB_USER + - _APP_DB_PASS openruntimes-executor: container_name: openruntimes-executor - hostname: exc1 + hostname: executor <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.1.4 + image: openruntimes/executor:0.3.5 networks: - appwrite - runtimes @@ -534,7 +617,6 @@ services: - appwrite-functions:/storage/functions:rw - /tmp:/tmp:rw environment: - - OPR_EXECUTOR_CONNECTION_STORAGE=$_APP_CONNECTIONS_STORAGE - OPR_EXECUTOR_INACTIVE_TRESHOLD=$_APP_FUNCTIONS_INACTIVE_THRESHOLD - OPR_EXECUTOR_MAINTENANCE_INTERVAL=$_APP_FUNCTIONS_MAINTENANCE_INTERVAL - OPR_EXECUTOR_NETWORK=$_APP_FUNCTIONS_RUNTIMES_NETWORK @@ -545,6 +627,27 @@ services: - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_EXECUTOR_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG + - OPR_EXECUTOR_STORAGE_DEVICE=$_APP_STORAGE_DEVICE + - OPR_EXECUTOR_STORAGE_S3_ACCESS_KEY=$_APP_STORAGE_S3_ACCESS_KEY + - OPR_EXECUTOR_STORAGE_S3_SECRET=$_APP_STORAGE_S3_SECRET + - OPR_EXECUTOR_STORAGE_S3_REGION=$_APP_STORAGE_S3_REGION + - OPR_EXECUTOR_STORAGE_S3_BUCKET=$_APP_STORAGE_S3_BUCKET + - OPR_EXECUTOR_STORAGE_DO_SPACES_ACCESS_KEY=$_APP_STORAGE_DO_SPACES_ACCESS_KEY + - OPR_EXECUTOR_STORAGE_DO_SPACES_SECRET=$_APP_STORAGE_DO_SPACES_SECRET + - OPR_EXECUTOR_STORAGE_DO_SPACES_REGION=$_APP_STORAGE_DO_SPACES_REGION + - OPR_EXECUTOR_STORAGE_DO_SPACES_BUCKET=$_APP_STORAGE_DO_SPACES_BUCKET + - OPR_EXECUTOR_STORAGE_BACKBLAZE_ACCESS_KEY=$_APP_STORAGE_BACKBLAZE_ACCESS_KEY + - OPR_EXECUTOR_STORAGE_BACKBLAZE_SECRET=$_APP_STORAGE_BACKBLAZE_SECRET + - OPR_EXECUTOR_STORAGE_BACKBLAZE_REGION=$_APP_STORAGE_BACKBLAZE_REGION + - OPR_EXECUTOR_STORAGE_BACKBLAZE_BUCKET=$_APP_STORAGE_BACKBLAZE_BUCKET + - OPR_EXECUTOR_STORAGE_LINODE_ACCESS_KEY=$_APP_STORAGE_LINODE_ACCESS_KEY + - OPR_EXECUTOR_STORAGE_LINODE_SECRET=$_APP_STORAGE_LINODE_SECRET + - OPR_EXECUTOR_STORAGE_LINODE_REGION=$_APP_STORAGE_LINODE_REGION + - OPR_EXECUTOR_STORAGE_LINODE_BUCKET=$_APP_STORAGE_LINODE_BUCKET + - OPR_EXECUTOR_STORAGE_WASABI_ACCESS_KEY=$_APP_STORAGE_WASABI_ACCESS_KEY + - OPR_EXECUTOR_STORAGE_WASABI_SECRET=$_APP_STORAGE_WASABI_SECRET + - OPR_EXECUTOR_STORAGE_WASABI_REGION=$_APP_STORAGE_WASABI_REGION + - OPR_EXECUTOR_STORAGE_WASABI_BUCKET=$_APP_STORAGE_WASABI_BUCKET mariadb: image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p @@ -621,7 +724,7 @@ volumes: appwrite-cache: appwrite-uploads: appwrite-certificates: - appwrite-influxdb: - appwrite-config: appwrite-functions: appwrite-builds: + appwrite-influxdb: + appwrite-config: From ece93a14e57dc9d3581de616844e6e82236cf7f8 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 18:09:37 -0400 Subject: [PATCH 2/4] Fix install task --- app/config/variables.php | 12 ++++++ app/console | 2 +- app/views/install/compose.phtml | 4 -- src/Appwrite/Platform/Tasks/Install.php | 56 ++++++++++++------------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index cbbe4c2656..b39eb9c41d 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -1024,11 +1024,19 @@ return [ 'name' => '_APP_MIGRATIONS_FIREBASE_CLIENT_ID', 'description' => 'Google OAuth client ID. You can find it in your GCP application settings.', 'introduction' => '1.4.0', + 'default' => '', + 'required' => false, + 'question' => '', + 'filter' => '' ], [ 'name' => '_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET', 'description' => 'Google OAuth client secret. You can generate secrets in your GCP application settings.', 'introduction' => '1.4.0', + 'default' => '', + 'required' => false, + 'question' => '', + 'filter' => '' ] ] ], @@ -1040,6 +1048,10 @@ return [ 'name' => '_APP_ASSISTANT_OPENAI_API_KEY', 'description' => 'OpenAI API key. You can find it in your OpenAI application settings.', 'introduction' => '1.4.0', + 'default' => '', + 'required' => false, + 'question' => '', + 'filter' => '' ] ] ] diff --git a/app/console b/app/console index 8ced2e82dd..51aa80cc80 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit 8ced2e82dd1cba2c2790c6562211b36f44198d89 +Subproject commit 51aa80cc80e83a41466bb353ccdff0e0e37d492f diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index a3656b5f36..c0e537df91 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -378,10 +378,6 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REDIS_HOST - - _APP_REDIS_PORT - - _APP_REDIS_USER - - _APP_REDIS_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_VCS_GITHUB_APP_NAME diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index be12eadf62..3cb1e17ebc 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -6,7 +6,9 @@ use Appwrite\Auth\Auth; use Appwrite\Docker\Compose; use Appwrite\Docker\Env; use Appwrite\Utopia\View; -use Utopia\Analytics\GoogleAnalytics; +use Utopia\Analytics\Adapter; +use Utopia\Analytics\Adapter\GoogleAnalytics; +use Utopia\Analytics\Event; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Validator\Text; @@ -33,22 +35,6 @@ class Install extends Action public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive): void { - /** - * 1. Start - DONE - * 2. Check for older setup and get older version - DONE - * 2.1 If older version is equal or bigger(?) than current version, **stop setup** - * 2.2. Get ENV vars - DONE - * 2.2.1 Fetch from older docker-compose.yml file - * 2.2.2 Fetch from older .env file (manually parse) - * 2.3 Use old ENV vars as default values - * 2.4 Ask for all required vars not given as CLI args and if in interactive mode - * Otherwise, just use default vars. - DONE - * 3. Ask user to backup important volumes, env vars, and SQL tables - * In th future we can try and automate this for smaller/medium size setups - * 4. Drop new docker-compose.yml setup (located inside the container, no network dependencies with appwrite.io) - DONE - * 5. Run docker compose up -d - DONE - * 6. Run data migration - */ $config = Config::getParam('variables'); $path = '/usr/src/code/appwrite'; $defaultHTTPPort = '80'; @@ -70,7 +56,7 @@ class Install extends Action Console::success('Starting Appwrite installation...'); // Create directory with write permissions - if (null !== $path && !\file_exists(\dirname($path))) { + if (!\file_exists(\dirname($path))) { if (!@\mkdir(\dirname($path), 0755, true)) { Console::error('Can\'t create directory ' . \dirname($path)); Console::exit(1); @@ -198,31 +184,28 @@ class Install extends Action } } - $templateForCompose = new View(__DIR__ . '/../views/install/compose.phtml'); - $templateForEnv = new View(__DIR__ . '/../views/install/env.phtml'); + $templateForCompose = new View(__DIR__ . '/../../../../app/views/install/compose.phtml'); + $templateForEnv = new View(__DIR__ . '/../../../../app/views/install/env.phtml'); $templateForCompose ->setParam('httpPort', $httpPort) ->setParam('httpsPort', $httpsPort) ->setParam('version', APP_VERSION_STABLE) ->setParam('organization', $organization) - ->setParam('image', $image) - ; + ->setParam('image', $image); - $templateForEnv - ->setParam('vars', $input) - ; + $templateForEnv->setParam('vars', $input); if (!file_put_contents($path . '/docker-compose.yml', $templateForCompose->render(false))) { $message = 'Failed to save Docker Compose file'; - $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message); + $this->sendEvent($analytics, $message); Console::error($message); Console::exit(1); } if (!file_put_contents($path . '/.env', $templateForEnv->render(false))) { $message = 'Failed to save environment variables file'; - $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message); + $this->sendEvent($analytics, $message); Console::error($message); Console::exit(1); } @@ -243,14 +226,29 @@ class Install extends Action if ($exit !== 0) { $message = 'Failed to install Appwrite dockers'; - $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message); + $this->sendEvent($analytics, $message); Console::error($message); Console::error($stderr); Console::exit($exit); } else { $message = 'Appwrite installed successfully'; - $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message); + $this->sendEvent($analytics, $message); Console::success($message); } } + + private function sendEvent(Adapter $analytics, string $message): void + { + $event = new Event(); + $event->setName(APP_VERSION_STABLE); + $event->setValue($message); + $event->setUrl('http://localhost/'); + $event->setProps([ + 'category' => 'install/server', + 'action' => 'install', + ]); + $event->setType('install/server'); + + $analytics->createEvent($event); + } } From 08ab9b016e3b09068335417d56a862819d2d9683 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 20:06:34 -0400 Subject: [PATCH 3/4] Fix render called on string --- app/controllers/api/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 694cb81046..bad4bd6f55 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1136,7 +1136,7 @@ App::post('/v1/account/sessions/magic-url') $mails ->setSubject($subject) - ->setBody($body->render()) + ->setBody($body) ->setVariables($emailVariables) ->setFrom($from) ->setRecipient($user->getAttribute('email')) From ef25c176ed39cd13a35c497bc42248d4fa930c50 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Aug 2023 21:11:57 -0400 Subject: [PATCH 4/4] Fix retry build test --- tests/e2e/Services/GraphQL/Base.php | 2 + .../Services/GraphQL/FunctionsServerTest.php | 89 ++++++++++++------- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/tests/e2e/Services/GraphQL/Base.php b/tests/e2e/Services/GraphQL/Base.php index 07c1d55aec..c2319ffa2a 100644 --- a/tests/e2e/Services/GraphQL/Base.php +++ b/tests/e2e/Services/GraphQL/Base.php @@ -1376,8 +1376,10 @@ trait Base return 'query getDeployment($functionId: String!, $deploymentId: String!) { functionsGetDeployment(functionId: $functionId, deploymentId: $deploymentId) { _id + resourceId buildId buildLogs + status } }'; case self::$CREATE_FUNCTION: diff --git a/tests/e2e/Services/GraphQL/FunctionsServerTest.php b/tests/e2e/Services/GraphQL/FunctionsServerTest.php index fb97d10718..dd5f179744 100644 --- a/tests/e2e/Services/GraphQL/FunctionsServerTest.php +++ b/tests/e2e/Services/GraphQL/FunctionsServerTest.php @@ -105,26 +105,59 @@ class FunctionsServerTest extends Scope $this->assertIsArray($deployment['body']['data']); $this->assertArrayNotHasKey('errors', $deployment['body']); - sleep(15); + // Poll get deployment until an error, or status is either 'ready' or 'failed' + $deployment = $deployment['body']['data']['functionsCreateDeployment']; + $deploymentId = $deployment['_id']; - return $deployment['body']['data']['functionsCreateDeployment']; + $query = $this->getQuery(self::$GET_DEPLOYMENT); + $gqlPayload = [ + 'query' => $query, + 'variables' => [ + 'functionId' => $function['_id'], + 'deploymentId' => $deploymentId, + ] + ]; + + while (true) { + $deployment = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], $this->getHeaders()), $gqlPayload); + + $this->assertIsArray($deployment['body']['data']); + $this->assertArrayNotHasKey('errors', $deployment['body']); + + $deployment = $deployment['body']['data']['functionsGetDeployment']; + + if ( + $deployment['status'] === 'ready' + || $deployment['status'] === 'failed' + ) { + break; + } + + \sleep(1); + } + + $this->assertEquals('ready', $deployment['status']); + + return $deployment; } /** - * * @depends testCreateFunction * @depends testCreateDeployment - * @param $function + * @param $deployment * @return array * @throws \Exception */ - public function testCreateExecution($function): array + public function testCreateExecution($deployment): array { $projectId = $this->getProject()['$id']; $query = $this->getQuery(self::$CREATE_EXECUTION); $gqlPayload = [ 'query' => $query, 'variables' => [ - 'functionId' => $function['_id'], + 'functionId' => $deployment['resourceId'], ] ]; @@ -133,6 +166,8 @@ class FunctionsServerTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); + \var_dump($execution); + $this->assertIsArray($execution['body']['data']); $this->assertArrayNotHasKey('errors', $execution['body']); @@ -140,33 +175,31 @@ class FunctionsServerTest extends Scope } /** - * @depends testCreateFunction * @depends testGetDeployment - * @param $function * @param $deployment - * @return array + * @return void * @throws \Exception */ - public function testCreateRetryBuild($function, $deployment): void + public function testCreateRetryBuild($deployment): void { $projectId = $this->getProject()['$id']; $query = $this->getQuery(self::$RETRY_BUILD); $gqlPayload = [ 'query' => $query, 'variables' => [ - 'functionId' => $function['_id'], + 'functionId' => $deployment['resourceId'], 'deploymentId' => $deployment['_id'], 'buildId' => $deployment['buildId'], ] ]; - $retryBuild = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $gqlPayload); - $this->assertIsArray($retryBuild['body']['errors']); - $this->assertEquals("Build not failed", $retryBuild['body']['errors'][0]['message']); + $this->assertIsNotArray($response['body']); + $this->assertEquals(204, $response['headers']['status-code']); } public function testGetFunctions(): array @@ -272,20 +305,19 @@ class FunctionsServerTest extends Scope } /** - * @depends testCreateFunction * @depends testCreateDeployment - * @param $function + * @param $deployment * @return array * @throws \Exception */ - public function testGetDeployment($function, $deployment) + public function testGetDeployment($deployment) { $projectId = $this->getProject()['$id']; $query = $this->getQuery(self::$GET_DEPLOYMENT); $gqlPayload = [ 'query' => $query, 'variables' => [ - 'functionId' => $function['_id'], + 'functionId' => $deployment['resourceId'], 'deploymentId' => $deployment['_id'], ] ]; @@ -334,21 +366,19 @@ class FunctionsServerTest extends Scope } /** - * @depends testCreateFunction * @depends testCreateExecution - * @param $function * @param $execution * @return array * @throws \Exception */ - public function testGetExecution($function, $execution): array + public function testGetExecution($execution): array { $projectId = $this->getProject()['$id']; $query = $this->getQuery(self::$GET_EXECUTION); $gqlPayload = [ 'query' => $query, 'variables' => [ - 'functionId' => $function['_id'], + 'functionId' => $execution['functionId'], 'executionId' => $execution['_id'], ] ]; @@ -405,20 +435,18 @@ class FunctionsServerTest extends Scope } /** - * @depends testCreateFunction * @depends testCreateDeployment - * @param $function * @param $deployment * @throws \Exception */ - public function testDeleteDeployment($function, $deployment): void + public function testDeleteDeployment($deployment): array { $projectId = $this->getProject()['$id']; $query = $this->getQuery(self::$DELETE_DEPLOYMENT); $gqlPayload = [ 'query' => $query, 'variables' => [ - 'functionId' => $function['_id'], + 'functionId' => $deployment['resourceId'], 'deploymentId' => $deployment['_id'], ] ]; @@ -430,22 +458,23 @@ class FunctionsServerTest extends Scope $this->assertIsNotArray($response['body']); $this->assertEquals(204, $response['headers']['status-code']); + + return $deployment; } /** - * @depends testCreateFunction * @depends testDeleteDeployment - * @param $function + * @param $deployment * @throws \Exception */ - public function testDeleteFunction($function): void + public function testDeleteFunction($deployment): void { $projectId = $this->getProject()['$id']; $query = $this->getQuery(self::$DELETE_FUNCTION); $gqlPayload = [ 'query' => $query, 'variables' => [ - 'functionId' => $function['_id'], + 'functionId' => $deployment['resourceId'], ] ];