From 5524fdb7b68c28c6f2857f279e6ec2ec66bbad85 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:48:11 +0100 Subject: [PATCH 1/6] fix: cache-docker --- .github/workflows/tests.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e7012527d..a733814dfb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,6 @@ concurrency: env: IMAGE: appwrite-dev - CACHE_KEY: appwrite-dev-${{ github.event.pull_request.head.sha }} on: [pull_request] @@ -30,8 +29,8 @@ jobs: push: false tags: ${{ env.IMAGE }} load: true - cache-from: type=gha,scope=appwrite - cache-to: type=gha,mode=max,scope=appwrite + cache-from: type=gha,scope=${{ env.CACHE_KEY }} + cache-to: type=gha,mode=max,scope=${{ env.CACHE_KEY }} outputs: type=docker,dest=/tmp/${{ env.IMAGE }}.tar build-args: | DEBUG=false @@ -41,9 +40,7 @@ jobs: - name: Cache Docker Image uses: actions/cache@v4 with: - key: ${{ env.CACHE_KEY }} - restore-keys: | - appwrite-dev- + key: appwrite-dev-${{ hashFiles('**') }} path: /tmp/${{ env.IMAGE }}.tar unit_test: @@ -58,7 +55,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: ${{ env.CACHE_KEY }} + key: appwrite-dev-${{ hashFiles('**') }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true @@ -88,7 +85,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: ${{ env.CACHE_KEY }} + key: appwrite-dev-${{ hashFiles('**') }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true @@ -136,7 +133,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: ${{ env.CACHE_KEY }} + key: appwrite-dev-${{ hashFiles('**') }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true @@ -162,7 +159,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: ${{ env.CACHE_KEY }} + key: appwrite-dev-${{ hashFiles('**') }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true - name: Load and Start Appwrite From 919bb9f4bd09d9dce44ab52e93192fc9a7f8a963 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:43:38 +0100 Subject: [PATCH 2/6] chore: remove restore-keys --- .github/workflows/tests.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a733814dfb..46c82910cb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,7 @@ concurrency: env: IMAGE: appwrite-dev + CACHE_KEY: appwrite-dev-${{ github.event.pull_request.head.sha }} on: [pull_request] @@ -29,8 +30,8 @@ jobs: push: false tags: ${{ env.IMAGE }} load: true - cache-from: type=gha,scope=${{ env.CACHE_KEY }} - cache-to: type=gha,mode=max,scope=${{ env.CACHE_KEY }} + cache-from: type=gha,scope=appwrite + cache-to: type=gha,mode=max,scope=appwrite outputs: type=docker,dest=/tmp/${{ env.IMAGE }}.tar build-args: | DEBUG=false @@ -40,7 +41,7 @@ jobs: - name: Cache Docker Image uses: actions/cache@v4 with: - key: appwrite-dev-${{ hashFiles('**') }} + key: ${{ env.CACHE_KEY }} path: /tmp/${{ env.IMAGE }}.tar unit_test: @@ -55,7 +56,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: appwrite-dev-${{ hashFiles('**') }} + key: ${{ env.CACHE_KEY }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true @@ -85,7 +86,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: appwrite-dev-${{ hashFiles('**') }} + key: ${{ env.CACHE_KEY }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true @@ -133,7 +134,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: appwrite-dev-${{ hashFiles('**') }} + key: ${{ env.CACHE_KEY }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true @@ -159,7 +160,7 @@ jobs: - name: Load Cache uses: actions/cache@v4 with: - key: appwrite-dev-${{ hashFiles('**') }} + key: ${{ env.CACHE_KEY }} path: /tmp/${{ env.IMAGE }}.tar fail-on-cache-miss: true - name: Load and Start Appwrite From 7c2b6d9330f8920361a486b778914086bec68c52 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 9 Oct 2024 13:05:13 +0100 Subject: [PATCH 3/6] fix: remove cache scope --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 46c82910cb..7c53b03b52 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,8 +30,8 @@ jobs: push: false tags: ${{ env.IMAGE }} load: true - cache-from: type=gha,scope=appwrite - cache-to: type=gha,mode=max,scope=appwrite + cache-from: type=gha + cache-to: type=gha,mode=max outputs: type=docker,dest=/tmp/${{ env.IMAGE }}.tar build-args: | DEBUG=false From e90df389dd3f83ccb66247af98adac94667841c4 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:02:55 +0100 Subject: [PATCH 4/6] debug: non override --- .../Functions/FunctionsCustomClientTest.php | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 31cc05f423..adce8e2cfe 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -6,6 +6,7 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; +use Utopia\CLI\Console; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role; @@ -249,20 +250,29 @@ class FunctionsCustomClientTest extends Scope 'activate' => true ]); - $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'x-appwrite-event' => "OVERRIDDEN", - 'x-appwrite-trigger' => "OVERRIDDEN", - 'x-appwrite-user-id' => "OVERRIDDEN", - 'x-appwrite-user-jwt' => "OVERRIDDEN", - ]); - $output = json_decode($execution['body']['responseBody'], true); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_JWT']); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_EVENT']); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_TRIGGER']); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_USER_ID']); + try { + $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'x-appwrite-event' => "OVERRIDDEN", + 'x-appwrite-trigger' => "OVERRIDDEN", + 'x-appwrite-user-id' => "OVERRIDDEN", + 'x-appwrite-user-jwt' => "OVERRIDDEN", + ]); + + $output = json_decode($execution['body']['responseBody'], true); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_JWT']); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_EVENT']); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_TRIGGER']); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_USER_ID']); + } catch (\Exception $e) { + // output docker logs + $out = ''; + Console::execute('docker compose logs appwrite', '', $out, $out); + fwrite(STDOUT, print_r($out, true)); + } + $this->cleanupFunction($functionId); } From 8f4594babb3e6381cf03a54544246be89df2d83b Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:12:46 +0100 Subject: [PATCH 5/6] debug: ci docker logs --- .github/workflows/tests.yml | 8 ++++ .../Functions/FunctionsCustomClientTest.php | 37 ++++++++----------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c53b03b52..9ddba90595 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -147,9 +147,17 @@ jobs: - name: Run ${{matrix.service}} Tests run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug + - name: Log docker-compose logs + run: docker compose logs appwrite + if: failure() + - name: Run ${{matrix.service}} Shared Tables Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug + - name: Log docker-compose logs + run: docker compose logs appwrite + if: failure() + benchmarking: name: Benchmark runs-on: ubuntu-latest diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index adce8e2cfe..c809d3a15a 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -250,28 +250,21 @@ class FunctionsCustomClientTest extends Scope 'activate' => true ]); - try { - $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'x-appwrite-event' => "OVERRIDDEN", - 'x-appwrite-trigger' => "OVERRIDDEN", - 'x-appwrite-user-id' => "OVERRIDDEN", - 'x-appwrite-user-jwt' => "OVERRIDDEN", - ]); - - $output = json_decode($execution['body']['responseBody'], true); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_JWT']); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_EVENT']); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_TRIGGER']); - $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_USER_ID']); - } catch (\Exception $e) { - // output docker logs - $out = ''; - Console::execute('docker compose logs appwrite', '', $out, $out); - fwrite(STDOUT, print_r($out, true)); - } + $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'x-appwrite-event' => "OVERRIDDEN", + 'x-appwrite-trigger' => "OVERRIDDEN", + 'x-appwrite-user-id' => "OVERRIDDEN", + 'x-appwrite-user-jwt' => "OVERRIDDEN", + ]); + + $output = json_decode($execution['body']['responseBody'], true); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_JWT']); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_EVENT']); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_TRIGGER']); + $this->assertNotEquals('OVERRIDDEN', $output['APPWRITE_FUNCTION_USER_ID']); $this->cleanupFunction($functionId); From 3b4fea655a09571423d4f46b2de481e007cbc210 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:27:38 +0100 Subject: [PATCH 6/6] chore: revert logs --- .github/workflows/tests.yml | 8 -------- .../e2e/Services/Functions/FunctionsCustomClientTest.php | 1 - 2 files changed, 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9ddba90595..7c53b03b52 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -147,17 +147,9 @@ jobs: - name: Run ${{matrix.service}} Tests run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - - name: Log docker-compose logs - run: docker compose logs appwrite - if: failure() - - name: Run ${{matrix.service}} Shared Tables Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - - name: Log docker-compose logs - run: docker compose logs appwrite - if: failure() - benchmarking: name: Benchmark runs-on: ubuntu-latest diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index c809d3a15a..914a255663 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -6,7 +6,6 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; -use Utopia\CLI\Console; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role;