> ## 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.

# Codemagic

> Jalankan tes end-to-end e2e di Codemagic, dengan iOS di Mac mini dan Android di instance Linux.

export const setupPrompt = `Tambahkan workflow Codemagic yang menjalankan tes e2e proyek ini di iOS dan Android. Dokumentasi: \`https://e2e.com/docs/ci/codemagic.md\` dan \`https://e2e.com/docs/ci.md\`

1. Baca kedua halaman.
2. Tambahkan workflow ke \`codemagic.yaml\`. Sesuaikan jalur proyek, scheme, dan versi Node dengan proyek ini.
3. Minta saya menambahkan kunci model ke grup variabel environment \`e2e\`, ditandai sebagai secret.
4. Setelah saya memulai build, baca log build dan perbaiki error sampai kedua workflow berhasil.`;

Penyiapan ini menjalankan iOS di instance Mac mini dan Android di instance
Linux, masing-masing satu workflow, mengikuti aturan di
[Job mobile](https://e2e.com/docs/id/ci#mobile-jobs).

<SetupPrompt>

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

</SetupPrompt>

## Workflow

Image Ubuntu memiliki AVD bernama `emulator` (API 34), `emulator-35`, dan
`emulator-36`. Instance Linux memerlukan penagihan yang aktif. `test_report`
mengirim `junit.xml` ke tab Tests pada build.

```yaml title="codemagic.yaml" expandable
workflows:
  e2e-ios:
    name: e2e iOS
    instance_type: mac_mini_m2
    max_build_duration: 60
    environment:
      groups:
        - e2e
      node: 24
      xcode: latest
    triggering:
      events:
        - push
        - pull_request
    scripts:
      - name: Install dependencies
        script: npm ci
      - name: Install pods
        script: cd ios && pod install
      - name: Build for the simulator
        script: |
          xcodebuild -workspace ios/MyApp.xcworkspace -scheme MyApp \
            -configuration Release -sdk iphonesimulator \
            -destination 'generic/platform=iOS Simulator' \
            -derivedDataPath ios/build
      - name: Boot a simulator and install the app
        script: |
          UDID=$(xcrun simctl create e2e "iPhone 17" com.apple.CoreSimulator.SimRuntime.iOS-26-5)
          xcrun simctl bootstatus "$UDID" -b
          xcrun simctl install "$UDID" ios/build/Build/Products/Release-iphonesimulator/MyApp.app
      - name: Run e2e
        script: npx e2e run --target ios --reporter list,junit
        test_report: .e2e/junit.xml
    artifacts:
      - .e2e/report.json
      - .e2e/junit.xml
      - .e2e/results/**

  e2e-android:
    name: e2e Android
    instance_type: linux_x2
    max_build_duration: 60
    environment:
      groups:
        - e2e
      node: 24
    triggering:
      events:
        - push
        - pull_request
    scripts:
      - name: Install dependencies
        script: npm ci
      - name: Build the APK
        script: cd android && ./gradlew :app:assembleRelease
      - name: Boot the emulator and install the app
        script: |
          emulator -avd emulator-35 -no-window -no-audio -no-boot-anim > /dev/null 2>&1 &
          adb wait-for-device
          until [ "$(adb shell getprop sys.boot_completed | tr -d '\r')" = "1" ]; do sleep 2; done
          adb install -r android/app/build/outputs/apk/release/app-release.apk
      - name: Run e2e
        script: npx e2e run --target android --reporter list,junit
        test_report: .e2e/junit.xml
    artifacts:
      - .e2e/report.json
      - .e2e/junit.xml
      - .e2e/results/**
```

## Kunci model

Letakkan kunci model di grup variabel environment `e2e`, ditandai sebagai
secret. Setiap build yang membaca grup itu dapat membaca kuncinya, termasuk
kode pull request yang tidak tepercaya. Picu build pull request dengan grup ini
hanya untuk kontributor yang Anda percayai. Lihat
[Kredensial model](https://e2e.com/docs/id/ci#model-credentials).

## Selanjutnya

<CardGroup cols={2}>
  <Card title="Integrasi berkelanjutan" icon="rotate" href="/ci">
    Bawaan CI, sharding, eksekusi ulang, dan exit code.
  </Card>
  <Card title="Perangkat cloud" icon="cloud" href="/mobile#hosted-devices">
    Sewa perangkat dari sebuah layanan. Dengan begitu runner tidak menjalankan perangkat apa pun.
  </Card>
</CardGroup>
