From 67fb7f0e2f6e78e891e73d6d30d8ed5cb0354c06 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 07:27:00 +0200 Subject: [PATCH 01/10] Added a Ruby env --- app/config/environments.php | 8 ++++++++ docker/environments/build.sh | 3 +++ docker/environments/ruby-3.0/Dockerfile | 12 ++++++++++++ .../Services/Functions/FunctionsCustomServerTest.php | 8 ++++++++ 4 files changed, 31 insertions(+) create mode 100644 docker/environments/ruby-3.0/Dockerfile diff --git a/app/config/environments.php b/app/config/environments.php index 228e7e4608..e2ddc5ed24 100644 --- a/app/config/environments.php +++ b/app/config/environments.php @@ -35,6 +35,14 @@ return [ 'build' => '/usr/src/code/docker/environments/ruby-2.7', 'logo' => 'ruby.png', ], + 'ruby-3.0' => [ + 'name' => 'Ruby', + 'version' => '3.0', + 'base' => 'ruby:3.0-alpine', + 'image' => 'appwrite/env-ruby-3.0:1.0.0', + 'build' => '/usr/src/code/docker/environments/ruby-3.0', + 'logo' => 'ruby.png', + ], 'python-3.8' => [ 'name' => 'Python', 'version' => '3.8', diff --git a/docker/environments/build.sh b/docker/environments/build.sh index 0dc07947a8..c758908aa4 100644 --- a/docker/environments/build.sh +++ b/docker/environments/build.sh @@ -20,3 +20,6 @@ docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 echo 'Ruby 2.7...' docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-ruby-2.7:1.0.2 ./docker/environments/ruby-2.7/ --push + +echo 'Ruby 3.0...' +docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-ruby-3.0:1.0.0 ./docker/environments/ruby-3.0/ --push diff --git a/docker/environments/ruby-3.0/Dockerfile b/docker/environments/ruby-3.0/Dockerfile new file mode 100644 index 0000000000..7f1600fa75 --- /dev/null +++ b/docker/environments/ruby-3.0/Dockerfile @@ -0,0 +1,12 @@ +FROM ruby:3.0-alpine + +LABEL maintainer="team@appwrite.io" + +RUN apk add tar + +RUN mkdir /usr/local/src + +WORKDIR /usr/local/src/ + +ENV GEM_PATH=/usr/local/src/.appwrite +ENV GEM_SPEC_CACHE=/usr/local/src/.appwrite/specs \ No newline at end of file diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 377d728e11..3ebad22924 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -521,6 +521,14 @@ class FunctionsCustomServerTest extends Scope 'command' => 'ruby app.rb', 'timeout' => 15, ], + [ + 'language' => 'Ruby', + 'version' => '3.0', + 'name' => 'ruby-3.0', + 'code' => $functions.'/ruby.tar.gz', + 'command' => 'ruby app.rb', + 'timeout' => 15, + ], [ 'language' => 'Deno', 'version' => '1.5', From 2f941fc08b844254515b27a1d9f1a78f9aa71e69 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 09:46:37 +0200 Subject: [PATCH 02/10] Deploy buildx --- .travis-ci/deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis-ci/deploy.sh b/.travis-ci/deploy.sh index b4c132022a..672761072d 100644 --- a/.travis-ci/deploy.sh +++ b/.travis-ci/deploy.sh @@ -1 +1,2 @@ -echo 'Nothing to deploy right now.' \ No newline at end of file +# echo 'Nothing to deploy right now.' +docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-ruby-3.0:1.0.0 ./docker/environments/ruby-3.0/ --push \ No newline at end of file From bdbb196e8073f153b2ae1960957c5381d0ef67c6 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 10:06:37 +0200 Subject: [PATCH 03/10] Push image --- .travis.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index f51de1e8ab..0651ce6921 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,16 +28,16 @@ before_install: - docker buildx create --use - chmod -R u+x ./.travis-ci -install: -- docker-compose up -d -- sleep 10 +# install: +# - docker-compose up -d +# - sleep 10 -script: -- docker ps -- docker-compose logs appwrite -- docker-compose exec appwrite doctor -- docker-compose exec appwrite vars -- docker-compose exec appwrite test +# script: +# - docker ps +# - docker-compose logs appwrite +# - docker-compose exec appwrite doctor +# - docker-compose exec appwrite vars +# - docker-compose exec appwrite test deploy: - provider: script @@ -45,4 +45,4 @@ deploy: script: ./deploy.sh on: repo: appwrite/appwrite - branch: deploy + # branch: deploy \ No newline at end of file From 090536adb71389fc0300de7bccbfb4f1d026e671 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 11:00:35 +0200 Subject: [PATCH 04/10] Updated omage push --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0651ce6921..b5600f15e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,4 +45,4 @@ deploy: script: ./deploy.sh on: repo: appwrite/appwrite - # branch: deploy \ No newline at end of file + branch: feat-new-ruby-version \ No newline at end of file From da7f0b995bd00981fedeb9e95a6ae185c8b526da Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 11:31:53 +0200 Subject: [PATCH 05/10] Deploy image --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b5600f15e5..0b8de833c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ before_install: - docker --version - docker buildx create --use - chmod -R u+x ./.travis-ci +- ./deploy.sh # install: # - docker-compose up -d From 7ebe5e7c5da6119e330f6678857dc956155954cc Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 11:34:47 +0200 Subject: [PATCH 06/10] Fixed deploy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b8de833c7..cf69b1c0d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ before_install: - docker --version - docker buildx create --use - chmod -R u+x ./.travis-ci -- ./deploy.sh +- ./.travis-ci/deploy.sh # install: # - docker-compose up -d From 6b2b50c77edb3719cfa8fcd5834558b15634b25f Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 14:55:02 +0200 Subject: [PATCH 07/10] Updated tests --- .travis.yml | 23 ++++++----- .../Functions/FunctionsCustomServerTest.php | 38 ++++++++++--------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf69b1c0d6..8406222a16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,23 +27,22 @@ before_install: - docker --version - docker buildx create --use - chmod -R u+x ./.travis-ci -- ./.travis-ci/deploy.sh -# install: -# - docker-compose up -d -# - sleep 10 +install: +- docker-compose up -d +- sleep 10 -# script: -# - docker ps -# - docker-compose logs appwrite -# - docker-compose exec appwrite doctor -# - docker-compose exec appwrite vars -# - docker-compose exec appwrite test +script: +- docker ps +- docker-compose logs appwrite +- docker-compose exec appwrite doctor +- docker-compose exec appwrite vars +- docker-compose exec appwrite test deploy: - provider: script edge: true - script: ./deploy.sh + script: ./.travis-ci/deploy.sh on: repo: appwrite/appwrite - branch: feat-new-ruby-version \ No newline at end of file + branch: deploy diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 3ebad22924..f9cce1d115 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -455,24 +455,6 @@ class FunctionsCustomServerTest extends Scope public function testENVS():array { - sleep(120); - /** - * Test for SUCCESS - */ - $file = $this->client->call(Client::METHOD_POST, '/storage/files', array_merge([ - 'content-type' => 'multipart/form-data', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), - 'read' => ['*'], - 'write' => ['*'], - 'folderId' => 'xyz', - ]); - - $this->assertEquals($file['headers']['status-code'], 201); - $this->assertNotEmpty($file['body']['$id']); - - $fileId = $file['body']['$id'] ?? ''; $functions = realpath(__DIR__ . '/../../../resources/functions'); @@ -539,6 +521,26 @@ class FunctionsCustomServerTest extends Scope ], ]; + sleep(count($envs) * 25); + + /** + * Test for SUCCESS + */ + $file = $this->client->call(Client::METHOD_POST, '/storage/files', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), + 'read' => ['*'], + 'write' => ['*'], + 'folderId' => 'xyz', + ]); + + $this->assertEquals($file['headers']['status-code'], 201); + $this->assertNotEmpty($file['body']['$id']); + + $fileId = $file['body']['$id'] ?? ''; + foreach ($envs as $key => $env) { $language = $env['language'] ?? ''; $version = $env['version'] ?? ''; From 3f833b71a99ec3682fb7dea2eff6034cfffbd48d Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 19 Jan 2021 18:32:53 +0200 Subject: [PATCH 08/10] Better check + CI test --- .travis.yml | 1 + app/workers/functions.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8406222a16..13cb083f7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ install: script: - docker ps +- docker stop appwrite-maintenance - docker-compose logs appwrite - docker-compose exec appwrite doctor - docker-compose exec appwrite vars diff --git a/app/workers/functions.php b/app/workers/functions.php index 2712dc74f1..22c3c22ef5 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -278,8 +278,8 @@ class FunctionsV1 'time' => 0, ]); - if(false === $execution) { - throw new Exception('Failed to create execution'); + if(false === $execution || ($execution instanceof Document && $execution->isEmpty())) { + throw new Exception('Failed to create or read execution'); } Authorization::reset(); From 6108b7bf9c35fcb7f33aced35c2ac5d507202900 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 20 Jan 2021 06:46:35 +0200 Subject: [PATCH 09/10] Removed CI tests --- .travis-ci/deploy.sh | 3 +-- .travis.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis-ci/deploy.sh b/.travis-ci/deploy.sh index 672761072d..b4c132022a 100644 --- a/.travis-ci/deploy.sh +++ b/.travis-ci/deploy.sh @@ -1,2 +1 @@ -# echo 'Nothing to deploy right now.' -docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-ruby-3.0:1.0.0 ./docker/environments/ruby-3.0/ --push \ No newline at end of file +echo 'Nothing to deploy right now.' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 13cb083f7a..8406222a16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ install: script: - docker ps -- docker stop appwrite-maintenance - docker-compose logs appwrite - docker-compose exec appwrite doctor - docker-compose exec appwrite vars From 467afebd96947aa3ab0f9d4cd2613126260fb7da Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 20 Jan 2021 06:47:57 +0200 Subject: [PATCH 10/10] Remove FX patch from this PR --- app/workers/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/workers/functions.php b/app/workers/functions.php index c9f925493c..cc276ed522 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -278,8 +278,8 @@ class FunctionsV1 'time' => 0, ]); - if(false === $execution || ($execution instanceof Document && $execution->isEmpty())) { - throw new Exception('Failed to create or read execution'); + if(false === $execution) { + throw new Exception('Failed to create execution'); } Authorization::reset();