Skip to main content

CI Integration

Set up FreezeRay in your CI pipeline to catch schema drift and migration failures before they reach production. This guide covers GitHub Actions, GitLab CI, and general CI/CD principles.

Why CI Integration?

Problem: Developers can accidentally modify frozen schemas locally, commit changes, and push to main before running tests. Solution: CI automatically runs drift and migration tests on every push and pull request, blocking changes that would break production.

What You’ll Need

  • Frozen schemas with fixtures committed to git
  • A test target with drift and migration tests
  • CI/CD platform (GitHub Actions, GitLab CI, Bitrise, etc.)
  • macOS CI runners (required for Xcode builds)

GitHub Actions Setup

Basic Configuration

Create .github/workflows/test.yml:
This runs all tests (including FreezeRay drift and migration tests) on every push and PR.

Targeted FreezeRay Tests

To run only FreezeRay tests (faster feedback):
Use -only-testing to run specific test classes for faster CI feedback.

Parallel Jobs

Run drift and migration tests in parallel:

Caching Dependencies

Speed up builds with caching:

Matrix Testing

Test on multiple simulators:

GitLab CI Setup

Create .gitlab-ci.yml:

Separate Drift and Migration Tests

Bitrise Setup

Create bitrise.yml:
Or use the Bitrise UI to add an “Xcode Test” step with:
  • Scheme: MyApp
  • Destination: platform=iOS Simulator,name=iPhone 15

CircleCI Setup

Create .circleci/config.yml:

Best Practices

1. Fail Fast on Drift

Run drift tests first (they’re faster than migration tests):

2. Run on Every Pull Request

Catch drift before merging:

3. Block Merging on Test Failures

GitHub: Enable “Require status checks to pass before merging” in branch protection rules. GitLab: Set pipeline to “must succeed” in merge request settings.

4. Clear Error Messages

When tests fail, the error is logged in CI:
This tells developers exactly what went wrong and how to fix it.

5. Test Coverage Reports

Generate code coverage for migration tests:

Common CI Issues

Issue 1: Simulator Not Found

Error:
Cause: iPhone 17 simulator not available in CI Xcode version. Fix: List available simulators:
Use a simulator that exists:

Issue 2: Fixtures Not Found

Error:
Cause: Fixtures not committed to git or not included in test bundle. Fix:
  1. Commit fixtures:
  2. Verify fixtures are in git:
  3. Ensure fixtures are in test bundle (Xcode projects):
    • Select test target → Build Phases → Copy Bundle Resources
    • Add FreezeRay/ folder

Issue 3: Build Takes Too Long

Problem: CI builds timeout (>10 minutes). Solutions:
  1. Cache dependencies:
  2. Run only FreezeRay tests:
  3. Use faster macOS runners (GitHub: macos-latest, not macos-11)

Issue 4: Permission Denied Errors

Error:
Cause: CI runner doesn’t have Xcode command line tools set up. Fix:

Issue 5: Test Flakiness

Problem: Tests sometimes pass, sometimes fail. Causes:
  • Race conditions in test setup
  • Simulator state not reset between runs
  • Network-dependent tests
Fix:
  1. Reset simulator state:
  2. Increase test timeout:
  3. Isolate test data:

Advanced Workflows

Pre-Merge Freeze Checks

Ensure no new schema versions are frozen without proper review:

Slack Notifications on Failure

Notify team when drift is detected:

Auto-Comment on PRs

Add a comment to PRs when drift is detected:

Monitoring and Reporting

Track Schema Changes Over Time

Log schema versions in CI:

Generate Migration Report

Create a summary of all migrations:

Example: Full GitHub Actions Workflow

Here’s a complete, production-ready workflow:

Summary

You’ve learned how to:
  • ✅ Set up FreezeRay tests in GitHub Actions, GitLab CI, and other CI platforms
  • ✅ Run drift and migration tests in parallel
  • ✅ Fail fast with drift detection
  • ✅ Handle common CI issues
  • ✅ Add notifications and reporting
CI integration ensures schema changes are caught before they reach production!

Next Steps

First Freeze

Tutorial for freezing your first schema

Testing Migrations

Learn to write custom migration tests

Drift Detection

Understand how drift detection works

freeze command

CLI reference for freezing schemas