Continuous integration

Once you've integrated Ruby Native you'll want to verify that the native side is correct before a build goes out.

You can now check it yourself, in your own CI pipeline, on every commit, with ruby_native check.

#Validating your integration

ruby_native check reads every view in your app and reports native integration problems. It lists signals the app will not recognize, signals rendered more than once where only the first counts, and signals that need a newer version of Ruby Native than your Gemfile has.

# .github/workflows/ci.yml
- name: Check Ruby Native signals
  run: bundle exec ruby_native check

It exits 1 when it finds an error and 0 otherwise, so a broken integration fails the build like any other test. See Debugging for what each problem means.

check requires the herb gem, which Rails 8.2 and later already include through Action View. On earlier versions, add gem "herb" to your Gemfile.

It scans app/views for .html.erb templates. Point it somewhere else, or at more than one place, with --paths:

bundle exec ruby_native check --paths=app/views,app/components

Signals rendered from Phlex, from an Inertia page, or from a template that is not ERB are outside what it can read. The Ruby Native app still reports those at runtime while you are testing, which Debugging covers.

#Catching feature drift

The gem in your Gemfile says what your views may emit. But the builds in the app stores declare what your app can render. Those can start to drift when you update the gem without deploying.

Add your Ruby Native API token to compare your views against the most recent build for each platform. This reports anything your users' app is too old to understand.

It is recommended to run this on your default branch rather than on every pull request. It is a question about what is shipped, not about the change in front of you.

- name: Check against the deployed build
  run: bundle exec ruby_native check --deployed
  env:
    RUBY_NATIVE_TOKEN: ${{ secrets.RUBY_NATIVE_TOKEN }}

#Rebuilding when the gem changes

Once your views are validated, the same workflow can trigger the native build with --if-needed.

- name: Deploy to Ruby Native
  run: bundle exec ruby_native deploy --if-needed
  env:
    RUBY_NATIVE_TOKEN: ${{ secrets.RUBY_NATIVE_TOKEN }}

deploy builds every platform you have configured, and --if-needed compares your gem version against the last successful build for each one, skipping only when they are all current. Now, every Rails deploy ensures the mobile apps are up to date.

#A complete workflow

Generate an API token by running ruby_native login locally and copying it from ~/.ruby_native/credentials, then store it as a repository secret.

Copy this workflow to your Rails repository to check and release new app versions on every Rails deploy.

# .github/workflows/ci.yml
name: CI

on:
  pull_request:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true

      - run: bin/rails test

      - name: Check Ruby Native signals
        run: bundle exec ruby_native check

      - name: Check against the deployed build
        if: github.ref == 'refs/heads/main'
        run: bundle exec ruby_native check --deployed
        env:
          RUBY_NATIVE_TOKEN: ${{ secrets.RUBY_NATIVE_TOKEN }}

      - name: Deploy to Ruby Native
        if: github.ref == 'refs/heads/main'
        run: bundle exec ruby_native deploy --if-needed
        env:
          RUBY_NATIVE_TOKEN: ${{ secrets.RUBY_NATIVE_TOKEN }}