diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4780cba..f9fd44f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: - "*/*" env: - SUPABASE_VERSION: 1.187.10 + SUPABASE_VERSION: 2.75.0 EXCLUDED_SUPABASE_SERVICES: imgproxy,inbucket,pgadmin-schema-diff,migra,studio,deno-relay # Qemu release page: https://github.com/espressif/qemu/releases/tag/esp-develop-8.2.0-20240122 QEMU_LINUX_URL: https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/qemu-xtensa-softmmu-esp_develop_8.2.0_20240122-x86_64-linux-gnu.tar.xz @@ -123,22 +123,9 @@ jobs: supabase start -x "$EXCLUDED_SUPABASE_SERVICES" supabase status - # Sample output of supabase status: - # supabase local development setup is running. - # - # API URL: http://localhost:54321 - # DB URL: postgresql://postgres:postgres@localhost:54322/postgres - # Studio URL: http://localhost:54323 - # Inbucket URL: http://localhost:54324 - # JWT secret: super-secret-jwt-token-with-at-least-32-characters-long - # anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs - # service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU - - API_URL_LINE=$(supabase status | grep "API URL:") - API_URL=${API_URL_LINE#*API URL: } + source <(supabase status --output=env) + API_HOST=${API_URL#*http://} - ANON_KEY_LINE=$(supabase status | grep "anon key:") - ANON_KEY=${ANON_KEY_LINE#*anon key: } echo "SUPABASE_TOITWARE_API_HOST=$API_HOST" >> $GITHUB_ENV echo "SUPABASE_TOITWARE_ANON_KEY=$ANON_KEY" >> $GITHUB_ENV @@ -150,11 +137,9 @@ jobs: supabase start -x "$EXCLUDED_SUPABASE_SERVICES" supabase status - API_URL_LINE=$(supabase status | grep "API URL:") - API_URL=${API_URL_LINE#*API URL: } + source <(supabase status --output=env) + API_HOST=${API_URL#*http://} - ANON_KEY_LINE=$(supabase status | grep "anon key:") - ANON_KEY=${ANON_KEY_LINE#*anon key: } echo "SUPABASE_BROKER_API_HOST=$API_HOST" >> $GITHUB_ENV echo "SUPABASE_BROKER_ANON_KEY=$ANON_KEY" >> $GITHUB_ENV diff --git a/public/supabase_broker/supabase/functions/b/index.ts b/public/supabase_broker/supabase/functions/b/index.ts index 64710bf6..f70ea079 100644 --- a/public/supabase_broker/supabase/functions/b/index.ts +++ b/public/supabase_broker/supabase/functions/b/index.ts @@ -1,7 +1,6 @@ // Copyright (C) 2023 Toitware ApS. All rights reserved. import { createClient } from "@supabase/supabase-js"; -import { serve } from "std/server"; const STATUS_IM_A_TEAPOT = 418; @@ -275,7 +274,7 @@ async function handleRequest(req: Request) { } } -serve(async (req: Request) => { +Deno.serve(async (req: Request) => { try { const result = await handleRequest(req); if (result instanceof Response) { diff --git a/public/supabase_broker/supabase/functions/import_map.json b/public/supabase_broker/supabase/functions/deno.json similarity index 100% rename from public/supabase_broker/supabase/functions/import_map.json rename to public/supabase_broker/supabase/functions/deno.json diff --git a/supabase_artemis/supabase/functions/b/index.ts b/supabase_artemis/supabase/functions/b/index.ts index 64710bf6..f70ea079 100644 --- a/supabase_artemis/supabase/functions/b/index.ts +++ b/supabase_artemis/supabase/functions/b/index.ts @@ -1,7 +1,6 @@ // Copyright (C) 2023 Toitware ApS. All rights reserved. import { createClient } from "@supabase/supabase-js"; -import { serve } from "std/server"; const STATUS_IM_A_TEAPOT = 418; @@ -275,7 +274,7 @@ async function handleRequest(req: Request) { } } -serve(async (req: Request) => { +Deno.serve(async (req: Request) => { try { const result = await handleRequest(req); if (result instanceof Response) { diff --git a/supabase_artemis/supabase/functions/import_map.json b/supabase_artemis/supabase/functions/deno.json similarity index 100% rename from supabase_artemis/supabase/functions/import_map.json rename to supabase_artemis/supabase/functions/deno.json diff --git a/tests/supabase-artemis-broker-policies-test.toit b/tests/supabase-artemis-broker-policies-test.toit index 6fbdf724..aa27606a 100644 --- a/tests/supabase-artemis-broker-policies-test.toit +++ b/tests/supabase-artemis-broker-policies-test.toit @@ -114,8 +114,13 @@ main args: expect-equals "foo".to-byte-array client2.storage.download --path="$path-org1/foo.txt" - expect-throws --contains="Not found": - client3.storage.download --path="$path-org1/foo.txt" + if bucket == ASSETS-BUCKET: + // Assets are public. + expect-equals "foo".to-byte-array + client3.storage.download --path="$path-org1/foo.txt" + else: + expect-throws --contains="Not found": + client3.storage.download --path="$path-org1/foo.txt" // Client3 has access to its own org bucket/path. path-org3 := "$bucket/$organization-id3" @@ -125,8 +130,13 @@ main args: expect-equals "bar".to-byte-array client3.storage.download --path="$path-org3/bar.txt" - expect-throws --contains="Not found": - client1.storage.download --path="$path-org3/bar.txt" + if bucket == ASSETS-BUCKET: + // Assets are public. + expect-equals "bar".to-byte-array + client1.storage.download --path="$path-org3/bar.txt" + else: + expect-throws --contains="Not found": + client1.storage.download --path="$path-org3/bar.txt" // Remember: device_id3 is in the same org as client1 and client2 (organization_id). // client3 is in a different org. diff --git a/tests/supabase-local-server.toit b/tests/supabase-local-server.toit index ee7ef78a..1ca90e7f 100644 --- a/tests/supabase-local-server.toit +++ b/tests/supabase-local-server.toit @@ -15,17 +15,9 @@ get-supabase-config --sub-directory/string -> ServerConfigSupabase: anon-key/string? := null api-url/string? := null - out := get-status_ sub-directory - lines := out.split "\n" - lines.map --in-place: it.trim - lines.do: - if it.starts-with "anon key:": - anon-key = it[(it.index-of ":") + 1..].trim - else if it.starts-with "API URL:": - api-url = it[(it.index-of ":") + 1..].trim - - if not anon-key or not api-url: - throw "Could not get supabase info" + status := get-status_ sub-directory + api-url = status["API_URL"] + anon-key = status["ANON_KEY"] host := api-url.trim --left "http://" print-on-stderr_ "HOST: $host ANON_KEY: $anon-key" @@ -39,17 +31,13 @@ get-supabase-config --sub-directory/string -> ServerConfigSupabase: return ServerConfigSupabase name --host=host --anon=anon-key get-supabase-service-key --sub-directory/string -> string: - out := get-status_ sub-directory - lines := out.split "\n" - lines.map --in-place: it.trim - lines.do: - if it.starts-with "service_role key:": - return it[(it.index-of ":") + 1..].trim - unreachable - -get-status_ sub-directory/string -> string: + status := get-status_ sub-directory + return status["SERVICE_ROLE_KEY"] + +get-status_ sub-directory/string -> Map: supabase-exe := os.env.get "SUPABASE_EXE" or "supabase" - return pipe.backticks supabase-exe "--workdir" "$sub-directory" "status" + out := pipe.backticks supabase-exe "--output=json" "--workdir" "$sub-directory" "status" + return json.parse out // Prints the arguments needed for adding the local supabase service to the configuration. main args: