|
| 1 | +# EAS Workflows — native build CI |
| 2 | + |
| 3 | +This directory holds [EAS Workflows](https://docs.expo.dev/eas/workflows/get-started/) |
| 4 | +that give us **native build coverage** on pull requests. |
| 5 | + |
| 6 | +## Why this exists |
| 7 | + |
| 8 | +Our existing CI (CircleCI `test_and_build`) only does: |
| 9 | + |
| 10 | +- `yarn lint` |
| 11 | +- `yarn ci:build` — which at the module level is just `tsc` (TypeScript only) |
| 12 | +- `yarn test` — Jest |
| 13 | + |
| 14 | +None of that compiles native code. Every module in `modules/*` ships real |
| 15 | +native sources: |
| 16 | + |
| 17 | +- iOS: `*.swift` + a `*.podspec` |
| 18 | +- Android: `build.gradle` + Kotlin/Java |
| 19 | + |
| 20 | +So a change that breaks the Swift or Kotlin (or breaks the app build) currently |
| 21 | +passes CI green. Building `apps/ExampleApp` on EAS fixes this: the app depends on |
| 22 | +every module, so a green build proves the native code for all of them compiles |
| 23 | +on both platforms. |
| 24 | + |
| 25 | +## What runs |
| 26 | + |
| 27 | +`build-on-pr.yml` runs on every PR targeting `main` and builds the ExampleApp for |
| 28 | +both platforms using the `preview` profile from `eas.json`: |
| 29 | + |
| 30 | +| Platform | Profile result | Credentials needed | |
| 31 | +| --- | --- | --- | |
| 32 | +| Android | APK | none (EAS-managed keystore) | |
| 33 | +| iOS | simulator build | none (simulator builds skip Apple distribution certs) | |
| 34 | + |
| 35 | +These profiles are intentionally credential-free so the job is a pure |
| 36 | +"does it compile" gate. |
| 37 | + |
| 38 | +## One-time setup (required for this to actually run) |
| 39 | + |
| 40 | +EAS Workflows are triggered by Expo, not by GitHub Actions or CircleCI. To enable: |
| 41 | + |
| 42 | +1. **Connect the repo to the Expo project.** In the Expo dashboard for |
| 43 | + `infinitered/react-native-mlkit` (projectId `4faa9328-e941-4395-879c-f558bf07e678`), |
| 44 | + go to **Project settings → GitHub** and link this GitHub repository. |
| 45 | +2. **Confirm billing / build credits.** Each PR triggers two builds (iOS + Android). |
| 46 | + Make sure the Expo account has capacity, or the jobs will queue/fail. |
| 47 | +3. (Optional) If you'd rather trigger from existing CI instead of Expo's GitHub |
| 48 | + integration, you can run `eas workflow:run .eas/workflows/build-on-pr.yml` from a |
| 49 | + job that has `EXPO_TOKEN` set, but the native EAS GitHub integration is simpler. |
| 50 | + |
| 51 | +## Monorepo note |
| 52 | + |
| 53 | +This is a Yarn 3 monorepo. EAS resolves project config (`app.json`/`eas.json`) from |
| 54 | +this directory (`apps/ExampleApp`), which is why the workflow lives here rather than |
| 55 | +at the repo root. EAS installs the full workspace and builds the local `modules/*` |
| 56 | +from source as part of the app build. |
| 57 | + |
| 58 | +## Cost / tuning ideas |
| 59 | + |
| 60 | +- To reduce spend, you could build **Android only** on PRs (Android breakage is the |
| 61 | + most common and Android needs no credentials) and keep iOS for `main` only. |
| 62 | +- Or gate builds behind a label / path filter so they only run when native files or |
| 63 | + `modules/*` change. |
| 64 | + |
| 65 | +## Caching |
| 66 | + |
| 67 | +EAS Build provides built-in caches (JS packages, CocoaPods, Maven/Gradle, and |
| 68 | +native compilation via `ccache`) with no configuration, so these builds are not |
| 69 | +fully cold. |
| 70 | + |
| 71 | +On top of that we set `EAS_USE_CACHE=1` (in the `production` profile in |
| 72 | +`eas.json`, inherited by `preview`) to enable native-compilation caching. It's |
| 73 | +safe even for a build whose job is to catch native breakage, because `ccache` is |
| 74 | +content-addressed — changed source always recompiles, so it can't mask a failure. |
| 75 | + |
| 76 | +We intentionally do **not** add a custom `cache` block (e.g. caching |
| 77 | +`Podfile.lock`). This repo's local Expo modules live in `modules/*`, and changing |
| 78 | +a module's podspec / `build.gradle` / `expo-module.config.json` alters the |
| 79 | +generated native project **without** touching `yarn.lock`. A lockfile-keyed cache |
| 80 | +would go stale and could hide exactly the native breakage this CI exists to catch. |
| 81 | +If build times become a real bottleneck, revisit this with a cache key that also |
| 82 | +invalidates on `modules/*` native config — and never cache the generated `ios/` or |
| 83 | +`android/` directories (CNG regenerates them every build). |
0 commit comments