Skip to main content

Testing Scripts

run-tests.sh

Location: scripts/run-tests.sh Comprehensive test runner with coverage measurement.
  • Basic Usage
  • Package Testing
  • Advanced
# Run all tests
./scripts/run-tests.sh

# Run with coverage
./scripts/run-tests.sh --coverage

# Run and open HTML report
./scripts/run-tests.sh --coverage --open
Flags:
  • --coverage - Generate coverage report
  • --open - Open HTML report in browser
  • --package NAME - Test specific package
  • --clean - Clean derived data first
  • --threshold N - Fail if coverage < N%
Output:
  • Console test results
  • coverage-report.txt - Text summary
  • coverage-report.html - Detailed HTML report

Supabase Scripts

Deploy Edge Function

# Login
supabase login

# Link project
cd supabase
supabase link --project-ref YOUR_REF

# Set secrets
supabase secrets set OPENROUTER_API_KEY=sk-or-v1-YOUR_KEY

# Deploy
supabase functions deploy ai

# Test
curl https://YOUR_PROJECT.supabase.co/functions/v1/ai

Run Migrations

# Push all migrations
supabase db push

# Create new migration
supabase migration new your_migration_name

# Reset database (DANGER!)
supabase db reset

Local Development

# Start local Supabase
supabase start

# Run functions locally
supabase functions serve

# Stop local Supabase
supabase stop

Xcode Build Scripts

Clean Build

# In Xcode
 + Shift + K

# Or terminal
xcodebuild clean \
  -scheme SwiftAIBoilerplatePro \
  -configuration Debug

Archive

# Terminal archive
xcodebuild archive \
  -scheme SwiftAIBoilerplatePro \
  -archivePath ./build/SwiftAIBoilerplatePro.xcarchive

Run Tests

xcodebuild test \
  -scheme SwiftAIBoilerplatePro \
  -destination 'platform=iOS Simulator,name=iPhone 15' \
  -enableCodeCoverage YES

Git Workflows

Pre-commit Checks

# Run linter
swiftlint

# Run tests
./scripts/run-tests.sh

# Check coverage
./scripts/run-tests.sh --coverage --threshold 85

Branch Management

# Create feature branch
git checkout -b feature/your-feature

# Commit with message
git commit -m "feat: your feature description"

# Push and create PR
git push origin feature/your-feature

Package Management

Update Dependencies

# In Xcode
File Packages Update to Latest Package Versions

# Or terminal
xcodebuild -resolvePackageDependencies

Reset Package Cache

# In Xcode
File Packages Reset Package Caches

# Or terminal
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/Developer/Xcode/DerivedData

Common Commands

Development

# Open project
open SwiftAIBoilerplatePro.xcodeproj

# Run app (requires Xcode)
xcodebuild -scheme SwiftAIBoilerplatePro

# Build only
xcodebuild build -scheme SwiftAIBoilerplatePro

Configuration

# Copy config template
cp Config/Secrets.example.xcconfig Config/Secrets.xcconfig

# Edit config
nano Config/Secrets.xcconfig
# or
open -a Xcode Config/Secrets.xcconfig

Cleaning

# Clean derived data
rm -rf ~/Library/Developer/Xcode/DerivedData

# Clean build folder
xcodebuild clean

# Reset simulators
xcrun simctl erase all

CI/CD Commands

GitHub Actions

Workflows in .github/workflows/: Main CI (ci.yml):
# Runs on push and PR
- Build app
- Run tests
- Check coverage (≥85%)
- SwiftLint check
Coverage Report (coverage-report.yml):
# Runs weekly
- Generate detailed coverage
- Create HTML report
- Create issues for low coverage
Trigger manually:
# Via GitHub UI
Actions Select workflow Run workflow

Quick Reference

./scripts/run-tests.sh --coverage --open
cd supabase
supabase functions deploy ai
xcodebuild clean
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/org.swift.swiftpm
./scripts/run-tests.sh --coverage
open coverage-report.html
I