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:
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.
