setup-cli icon indicating copy to clipboard operation
setup-cli copied to clipboard

Stopped Supabase services, and missing Anon and Service Keys

Open lefado opened this issue 1 year ago • 1 comments

Bug report

  • [ x] I confirm this is a bug with Supabase, not with my own application.
  • [ x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

have a NextJS project which uses Supabase as database, and uses Playwright for e2e testing. I successfully run e2e tests against my local Supabase Database. I have tests for login, and sign up into my app. In my tests, I access local inbuket in order to verify user receives emails, and can signup correctly.

Now, I am trying to run e2e tests from Github Actions which should run against Github action local Supabase setup

To Reproduce

Here is my Github Action file:

name: Playwright Tests
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
  workflow_dispatch:

jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    env:
      SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
      NEXT_PUBLIC_SUPABASE_ENV: local
      NEXT_PUBLIC_SUPABASE_URL_LOCAL: http://localhost:54321
      # NEXT_PUBLIC_SUPABASE_ANON_KEY_LOCAL: ""
      # NEXT_PUBLIC_SUPABASE_SERVICE_KEY_LOCAL: ""

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: lts/*
          # We'll still use built-in npm caching as an extra fallback.
          cache: npm

      # Explicit cache for node_modules to ensure stable caching behavior
      - name: Cache Node Modules
        id: cache-node
        uses: actions/cache@v4
        with:
          path: node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install dependencies
        if: steps.cache-node.outputs.cache-hit != 'true'
        run: npm ci

      - uses: supabase/setup-cli@v1
        with:
          version: 1.187.3
      - run: supabase db start
      - run: supabase status

      - name: Cache Playwright browsers
        id: playwright-cache
        uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: playwright-browsers-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
          restore-keys: |
            playwright-browsers-${{ runner.os }}-

      - name: Install Playwright Browsers
        if: steps.playwright-cache.outputs.cache-hit != 'true'
        run: npx playwright install chromium --with-deps

      - name: Run Playwright tests
        run: npm run test:e2e

Expected behavior

My e2e tests need to access inbucket http://127.0.0.1:54324/api/v1, and also uses auth functions such as: await supabase.auth.signUp(), and await supabase.auth.admin.updateUserById().

How can I get keys for NEXT_PUBLIC_SUPABASE_ANON_KEY_LOCAL, and NEXT_PUBLIC_SUPABASE_SERVICE_KEY_LOCAL when running supabase locally on Github action?

When running Supabase locally I obtain those keys by running npx supabase status. However, when running that command from Github action, I only can see:

runner@fv-az1724-957:~/work/teacher-marketplace/teacher-marketplace$ supabase status
Stopped services: [supabase_kong_teacher-marketplace supabase_auth_teacher-marketplace supabase_inbucket_teacher-marketplace supabase_realtime_teacher-marketplace supabase_rest_teacher-marketplace supabase_storage_teacher-marketplace supabase_imgproxy_teacher-marketplace supabase_pg_meta_teacher-marketplace supabase_studio_teacher-marketplace supabase_edge_runtime_teacher-marketplace supabase_analytics_teacher-marketplace supabase_vector_teacher-marketplace supabase_pooler_teacher-marketplace]
supabase local development setup is running.
          DB URL: postgresql://postgres:[email protected]:54322/postgres

How can I start those services, and get needed keys?

lefado avatar Jan 02 '25 10:01 lefado

I am also affected by this

borecz avatar Feb 01 '25 07:02 borecz

You can get those variables via supabase status -o env command. Probably easiest to append them to your .env file so it's available tests. For eg.

      - uses: supabase/setup-cli@v1
        with:
          version: latest
      - run: supabase db start
      - run: supabase status -o env >> .env

      - name: Cache Playwright browsers
        id: playwright-cache

sweatybridge avatar Jul 23 '25 07:07 sweatybridge