> ## Documentation Index
> Fetch the complete documentation index at: https://e2e.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Expo Workflows

> Expo Build で Expo アプリをビルドし、Expo のワークフローで iOS と Android のテストを実行します。

export const setupPrompt = `この Expo アプリをビルドし、iOS と Android で e2e テストを実行する Expo ワークフローを追加してください。ドキュメント: \`https://e2e.com/docs/ci/eas-workflows.md\` と \`https://e2e.com/docs/ci.md\`

1. 両方のページを読んでください。
2. \`eas.json\` に \`e2e\` ビルドプロファイルを追加してください。
3. \`.eas/workflows/e2e.yml\` を追加し、このプロジェクトのターゲットと Node のバージョンに合わせてください。
4. モデルのキーを Expo のシークレット環境変数に追加するよう私に依頼し、各テストジョブの \`environment:\` をそれに合わせてください。
5. 私がワークフローを開始したらジョブのログを読み、両方のジョブが成功するまでエラーを修正してください。`;

Expo のワークフローでは、`build` ジョブがシミュレーター用の `.app` または `.apk` を作成します。
次にカスタムジョブがビルドをダウンロードし、デバイスを起動してスイートを実行します。
各ジョブは [モバイルのジョブ](https://e2e.com/docs/ja/ci#mobile-jobs) のルールに従います。

<Note>
このページは CI サービスの Expo Workflows について説明しています。
Expo がホストするシミュレーターやエミュレーターでテストするには、[Expo Simulators](https://e2e.com/docs/ja/integrations/eas) を参照してください。
</Note>

<SetupPrompt>

<Prompt description={setupPrompt} children={setupPrompt} actions={["copy", "cursor"]} />

</SetupPrompt>

## ビルドプロファイル

認証情報が不要なビルドプロファイルを追加します。

```json title="eas.json"
{
  "build": {
    "e2e": {
      "withoutCredentials": true,
      "ios": { "simulator": true },
      "android": { "buildType": "apk" }
    }
  }
}
```

## ワークフロー

Android ジョブには、`nested-virtualization` の Linux ランナーが必要です。
エミュレーターを動かせる Expo のマシンはこれだけです。以下のようにカスタムジョブを使ってください。
組み込みの `maestro` ジョブは Maestro のフロー用で、e2e は実行しません。

```yaml title=".eas/workflows/e2e.yml" expandable
name: e2e

on:
  pull_request:
    branches: ['*']
  push:
    branches: [main]

defaults:
  tools:
    node: '24'

jobs:
  build_ios:
    type: build
    params:
      platform: ios
      profile: e2e

  build_android:
    type: build
    params:
      platform: android
      profile: e2e

  e2e_ios:
    needs: [build_ios]
    runs_on: macos-medium
    environment: preview
    env:
      CI: '1'
    steps:
      - uses: eas/checkout
      - uses: eas/install_node_modules
      - uses: eas/download_build
        id: download_build
        with:
          build_id: ${{ needs.build_ios.outputs.build_id }}
          extensions: [app]
      - name: Boot a simulator and install the app
        run: |
          UDID=$(xcrun simctl create e2e "iPhone 17" com.apple.CoreSimulator.SimRuntime.iOS-26-5)
          xcrun simctl bootstatus "$UDID" -b
          xcrun simctl install "$UDID" "${{ steps.download_build.outputs.artifact_path }}"
      - name: Run e2e
        run: npx e2e run --target ios --reporter list,junit
      - uses: eas/upload_artifact
        if: ${{ always() }}
        with:
          type: other
          name: e2e-ios
          path: .e2e

  e2e_android:
    needs: [build_android]
    runs_on: linux-medium-nested-virtualization
    environment: preview
    env:
      CI: '1'
    steps:
      - uses: eas/checkout
      - uses: eas/install_node_modules
      - uses: eas/download_build
        id: download_build
        with:
          build_id: ${{ needs.build_android.outputs.build_id }}
          extensions: [apk]
      - uses: eas/start_android_emulator
        with:
          system_image_package: system-images;android-35;google_apis;x86_64
      - name: Install the app
        run: adb install -r "${{ steps.download_build.outputs.artifact_path }}"
      - name: Run e2e
        run: npx e2e run --target android --reporter list,junit
      - uses: eas/upload_artifact
        if: ${{ always() }}
        with:
          type: other
          name: e2e-android
          path: .e2e
```

`CI` を設定しないランナーでも、`CI: '1'` で [CI のデフォルト](https://e2e.com/docs/ja/ci#what-ci-changes) を有効にできます。
`eas/start_android_emulator` は Expo Build の関数です。
Workflows の構文ページではなく、[カスタムビルド](https://docs.expo.dev/custom-builds/schema/) に記載されています。
指定したシステムイメージを `sdkmanager` でダウンロードします。

## モデルのキー

`AI_GATEWAY_API_KEY` などのモデルのキーは、
[Expo の環境変数](https://docs.expo.dev/eas/environment-variables/) に secret の公開範囲で保存します。
カスタムジョブはデフォルトで `production` を読むため、各ジョブに `environment:` を設定してください。

その環境を読むジョブは、信頼できないプルリクエストを実行するものも含め、キーにアクセスできます。
[モデルの認証情報](https://e2e.com/docs/ja/ci#model-credentials) を参照してください。

## ビルドの回数を減らす

`fingerprint` ジョブと `get-build`、`repack` を組み合わせると、前回のネイティブビルドを再利用し、
JavaScript だけをバンドルできます。
[agent-device の Expo Workflows テンプレート](https://github.com/callstackincubator/eas-agent-device/blob/main/.eas/workflows/agent-qa-mobile.yml)
では、両プラットフォームでこの方式を使っています。

## 次のステップ

<CardGroup cols={2}>
  <Card title="継続的インテグレーション" icon="rotate" href="/ci">
    CI のデフォルト、シャーディング、再実行、終了コードを確認します。
  </Card>
  <Card title="Expo Simulators" icon="/images/integrations/expo.svg" href="/integrations/eas">
    Mac や Android SDK なしで、Expo のホスト型デバイスでスイートを実行します。
  </Card>
</CardGroup>
