Overview
This guide covers:- Restoring snapshots before running tests
- Creating snapshots on a schedule
- Testing schema migrations against production-like data
- Caching Basecut CLI for faster runs
- Best practices for GitHub Actions workflows
For other CI/CD platforms, see the CI/CD Integration guide. For local development with Docker, see Docker Compose Integration.
Quick Start: Test with Production-Like Data
Restore a snapshot before running your test suite:BASECUT_API_KEY: Your Basecut API keyAWS_ACCESS_KEY_ID: AWS credentials (if snapshot stored in S3)AWS_SECRET_ACCESS_KEY: AWS secret key
Create Snapshots on Schedule
Refresh your dev snapshot weekly with latest production data:Test Schema Migrations
Validate migrations against production-like data before deploying:Optimize Performance
Cache Basecut CLI Installation
Speed up workflows by caching the Basecut CLI binary:Parallel Test Jobs
Restore snapshot once, run tests in parallel:Best Practices
1. Use Dedicated Test Snapshots
Create separate snapshots for CI with:- Stable sampling: Use
sampling.seedwhensampling.mode: random - Small size: Faster restore (use
limits.rows.per_table) - Stable schema: Update when schema changes, not on every run
2. Handle Restore Failures Gracefully
3. Use Matrix Strategy for Multiple Environments
Test against different snapshot versions:4. Conditional Snapshot Creation
Only create snapshots on main branch:Troubleshooting
Snapshot Restore Too Slow
- Use smaller snapshot: Reduce
limits.rows.per_tablein your config - Cache restore: Restore once, reuse DB dump (see parallel tests above)
- Local storage: Use local filesystem for CI snapshots (faster than S3)
Authentication Failures
Database Connection Refused
- Ensure
servicescontainer is healthy before restoring - Check that
depends_onisn’t needed (services start in parallel) - Increase
--health-intervalif database starts slowly