From 9e93c389fc59fcbd13a802db99390fada0b0909b Mon Sep 17 00:00:00 2001 From: Aditya Maru Date: Fri, 13 Dec 2024 18:55:40 -0500 Subject: [PATCH] .github: test npm sticky disk --- .github/workflows/supabase-demo.yaml | 67 +++++++++++++++++++ supabase/config.toml | 57 ++++++++++++++++ .../20231214000000_initial_schema.sql | 25 +++++++ supabase/seed.sql | 5 ++ 4 files changed, 154 insertions(+) create mode 100644 .github/workflows/supabase-demo.yaml create mode 100644 supabase/config.toml create mode 100644 supabase/migrations/20231214000000_initial_schema.sql create mode 100644 supabase/seed.sql diff --git a/.github/workflows/supabase-demo.yaml b/.github/workflows/supabase-demo.yaml new file mode 100644 index 0000000..3e91a13 --- /dev/null +++ b/.github/workflows/supabase-demo.yaml @@ -0,0 +1,67 @@ +name: Start supabase with Sticky Disk +on: + workflow_dispatch: + push: + pull_request: + +permissions: + packages: read + contents: read + id-token: write # This is required for requesting the JWT + +jobs: + github_supabase: + name: Run Supabase without Sticky Disk + runs-on: blacksmith-staging + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node + uses: useblacksmith/setup-node@v4 + with: + node-version: 18 + - name: Run Supabase + run: | + time npx -y supabase start + npx supabase db reset --debug + echo "Supabase is running at http://localhost:54323" + echo "API URL: http://localhost:54321" + echo "DB URL: postgresql://postgres:postgres@localhost:54322/postgres" + + stickydisk_supabase: + name: Run Supabase with Sticky Disk + runs-on: blacksmith-staging + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node + uses: useblacksmith/setup-node@v4 + with: + node-version: 18 + + - name: Setup sticky disk for ~/.npm + uses: useblacksmith/stickydisk@main + with: + key: "npm" + path: "~/.npm" + + - name: Setup sticky disk for ./node_modules + uses: useblacksmith/stickydisk@main + with: + key: "node_modules" + path: "./node_modules" + + - name: Setup sticky disk for /var/lib/docker + uses: useblacksmith/stickydisk@main + with: + key: "docker-data" + path: "/var/lib/docker" + + - name: Run Supabase + run: | + time npx -y supabase start + npx supabase db reset --debug + echo "Supabase is running at http://localhost:54323" + echo "API URL: http://localhost:54321" + echo "DB URL: postgresql://postgres:postgres@localhost:54322/postgres" diff --git a/supabase/config.toml b/supabase/config.toml new file mode 100644 index 0000000..a0109d7 --- /dev/null +++ b/supabase/config.toml @@ -0,0 +1,57 @@ +# A string used to distinguish different Supabase projects on the same host. Defaults to the working +# directory name when running `supabase init`. +project_id = "stickydisk-demo" + +[api] +# Port to use for the API URL. +port = 54321 +# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API +# endpoints. public and storage are always included. +schemas = ["public", "storage"] +# Extra schemas to add to the search_path of every request. public is always included. +extra_search_path = ["public", "extensions"] +# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size +# for accidental or malicious requests. +max_rows = 1000 + +[db] +# Port to use for the local database URL. +port = 54322 +# The database major version to use. This has to be the same as your remote database's. Run `SHOW +# server_version;` on the remote database to check. +major_version = 15 + +[studio] +# Port to use for Supabase Studio. +port = 54323 + +[auth] +# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used +# in emails. +site_url = "http://localhost:3000" +# A list of *exact* URLs that auth providers are permitted to redirect to post authentication. +additional_redirect_urls = ["https://localhost:3000"] +# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one +# week). +jwt_expiry = 3600 +# Allow/disallow new user signups to your project. +enable_signup = true + +[auth.email] +# Allow/disallow new user signups via email to your project. +enable_signup = true +# If enabled, a user will be required to confirm any email change on both the old, and new email +# addresses. If disabled, only the new email is required to confirm. +double_confirm_changes = true +# If enabled, users need to confirm their email address before signing in. +enable_confirmations = false + +[auth.sms] +# Allow/disallow new user signups via SMS to your project. +enable_signup = true +# If enabled, users need to confirm their phone number before signing in. +enable_confirmations = false + +[storage] +# The maximum file size allowed (e.g. "5MB", "500KB"). +file_size_limit = "50MiB" \ No newline at end of file diff --git a/supabase/migrations/20231214000000_initial_schema.sql b/supabase/migrations/20231214000000_initial_schema.sql new file mode 100644 index 0000000..ab10f12 --- /dev/null +++ b/supabase/migrations/20231214000000_initial_schema.sql @@ -0,0 +1,25 @@ +-- Create a todos table +CREATE TABLE todos ( + id BIGSERIAL PRIMARY KEY, + title TEXT NOT NULL, + completed BOOLEAN NOT NULL DEFAULT FALSE, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Enable Row Level Security +ALTER TABLE todos ENABLE ROW LEVEL SECURITY; + +-- Create a trigger to update the updated_at column +CREATE OR REPLACE FUNCTION update_updated_at_column() +RETURNS TRIGGER AS $$ +BEGIN + NEW.updated_at = NOW(); + RETURN NEW; +END; +$$ language 'plpgsql'; + +CREATE TRIGGER update_todos_updated_at + BEFORE UPDATE ON todos + FOR EACH ROW + EXECUTE FUNCTION update_updated_at_column(); \ No newline at end of file diff --git a/supabase/seed.sql b/supabase/seed.sql new file mode 100644 index 0000000..4dad8c9 --- /dev/null +++ b/supabase/seed.sql @@ -0,0 +1,5 @@ +INSERT INTO todos (title, completed) VALUES + ('Buy groceries', false), + ('Walk the dog', true), + ('Learn Supabase', false), + ('Build a demo app', false); \ No newline at end of file