From 65bcf7898eca5525d4c0c42d13c1e2ac128d0d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sat, 8 Mar 2025 22:56:16 +0100 Subject: [PATCH] Improve CI/CD logs --- .github/workflows/tests.yml | 4 ++- .../Modules/Functions/Workers/Builds.php | 28 ++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5313ff392b..6363c95e49 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -88,4 +88,6 @@ jobs: docker compose exec -T \ -e _APP_DATABASE_SHARED_TABLES \ -e _APP_DATABASE_SHARED_TABLES_V1 \ - appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug \ No newline at end of file + appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug + + docker compose logs appwrite-worker-builds \ No newline at end of file diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 608c001b70..0dcb27a950 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -671,11 +671,16 @@ class Builds extends Action } }), ]); + + \var_dump("Finish"); if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') { Console::info('Build has been canceled'); return; } + + \var_dump("Problem"); + \var_dump($err); if ($err) { throw $err; @@ -686,33 +691,48 @@ class Builds extends Action $buildSizeLimit = (int)System::getEnv('_APP_COMPUTE_BUILD_SIZE_LIMIT', '2000000000'); if ($response['size'] > $buildSizeLimit) { + \var_dump("Limit issue"); throw new \Exception('Build size should be less than ' . number_format($buildSizeLimit / 1048576, 2) . ' MBs.'); } - if ($resource->getCollection() === 'sites' && empty($resource->getAttribute('adapter'))) { + \var_dump($resource->getCollection() === 'sites'); + \var_dump($resource->getAttribute('adapter', '')); + if ($resource->getCollection() === 'sites' && empty($resource->getAttribute('adapter', ''))) { + \var_dump($resource->getAttribute('outputDirectory', './')); + \var_dump(\escapeshellarg($resource->getAttribute('outputDirectory', './'))); // TODO: Refactor with structured command in future, using utopia library (CLI) - $listFilesCommand = "cd /usr/local/build && cd " . \escapeshellarg($resource->getAttribute('outputDirectory')) . " && find . -name 'node_modules' -prune -o -type f -print"; + $listFilesCommand = "cd /usr/local/build && cd " . \escapeshellarg($resource->getAttribute('outputDirectory', './')) . " && find . -name 'node_modules' -prune -o -type f -print"; $command = $executor->createCommand( deploymentId: $deployment->getId(), projectId: $project->getId(), command: $listFilesCommand, timeout: 15 ); - + + \var_dump($command); + $files = \explode("\n", $command['output']); // Parse output $files = \array_filter($files); // Remove empty $files = \array_map(fn ($file) => \trim($file), $files); // Remove whitepsaces $files = \array_map(fn ($file) => \str_starts_with($file, './') ? \substr($file, 2) : $file, $files); // Remove beginning ./ + + \var_dump($files); $detector = new Rendering($files, $resource->getAttribute('framework', '')); $detector ->addOption(new SSR()) ->addOption(new XStatic()); $detection = $detector->detect(); - + + \var_dump($detection->getName()); + \var_dump($detection->getFallbackFile()); + $resource->setAttribute('adapter', $detection->getName()); $resource->setAttribute('fallbackFile', $detection->getFallbackFile() ?? ''); $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); + + \var_dump("Updated"); + \var_dump($resource->getAttribute('fallbackFile', '')); } $executor->deleteRuntime($project->getId(), $deployment->getId(), '-build');