Running Supabase Tests in GitHub Actions

Dan Lynch

Dan Lynch

Nov 17, 2025

lesson header image

Previously: In Seeding Supabase Test Databases, we learned efficient strategies for seeding test data. Now let's automate our tests with GitHub Actions.

Running tests locally is essential during development, but you need continuous integration to ensure code quality as your team grows. GitHub Actions provides a free CI/CD platform that can run your Supabase tests on every commit and pull request.

In this lesson, you'll set up a GitHub Actions workflow to automatically test your Supabase database with every code change.

Prerequisites

See Prerequisites. Requires: Complete Seeding Supabase Test Databases.

Why Run Tests for Supabase in CI?

Without automated testing, developers often write code directly against production Supabase instances—a risky practice that can lead to data loss or downtime.

Continuous Integration provides a safe alternative:

  • Automated testing on every commit and pull request
  • Consistent environment eliminates "works on my machine" issues
  • Avoid production testing - catch issues before they affect live data
  • Team confidence in merging changes without breaking tests
  • Early detection of schema changes and RLS policy issues

Create GitHub Actions Workflow

This workflow uses the official Supabase GitHub Actions to set up the Supabase CLI in your CI environment.

Create .github/workflows/test.yml in your repository:

name: Supabase tests
on:
  push:
  pull_request:
    types: [opened, synchronized, reopened]
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest
    continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        package:
          - my-supabase-app

    env:
      PGHOST: 127.0.0.1
      PGPORT: 54322
      PGUSER: supabase_admin
      PGPASSWORD: postgres
      DATABASE_URL: "postgresql://postgres:postgres@127.0.0.1:54322/postgres"

    steps:
      - name: Configure Git (for tests)
        run: |
          git config --global user.name "CI Test User"
          git config --global user.email "ci@example.com"

      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Supabase CLI
        uses: supabase/setup-cli@v1
        with:
          version: latest

      - name: Initialize Supabase (if needed)
        run: test -d supabase || supabase init

      - name: Start Supabase stack
        run: supabase start

      - name: Show Supabase status
        run: supabase status

      - name: Install Postgres client
        run: |
          sudo apt-get update
          sudo apt-get install -y postgresql-client

      - name: Wait for Postgres
        run: |
          for i in {1..60}; do
            if pg_isready -h 127.0.0.1 -p 54322 -U postgres; then
              exit 0
            fi
            sleep 2
          done
          echo "postgres not ready in time"
          docker ps
          supabase status
          exit 1

      - name: Enable corepack and pnpm
        run: |
          corepack enable
          corepack prepare pnpm@9 --activate
          pnpm -v
          node -v

      - name: Install
        run: pnpm install

      - name: Install pgpm CLI globally
        run: npm install -g pgpm

      - name: Build
        run: pnpm -r build

      - name: Seed pg and app_user
        run: |
          # bootstrap admin user NOT REQUIRED FOR supabase
          # pgpm admin-users bootstrap --yes
          # optional, but added to avoid concurrent attempts to add user
          pgpm admin-users add --test --yes

      - name: Test ${{ matrix.package }}
        run: cd ./packages/${{ matrix.package }} && pnpm test

Real-World Example

Want to see Supabase tests running in production CI? Check out the supabase-test-suite repository—a comprehensive example with working GitHub Actions workflows.

Key Takeaways

  • GitHub Actions provides free CI/CD for public repositories
  • Supabase CLI can start a local instance in CI environments
  • Official Supabase Actions simplify setup and configuration
  • Real examples like supabase-test-suite demonstrate production patterns

You've automated your Supabase tests with GitHub Actions. Every commit and pull request now runs your full test suite, giving you confidence in your database changes.