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

> Codemagic पर iOS और Android टेस्ट चलाएँ, iOS के लिए Mac mini पर और Android के लिए Linux इंस्टेंस पर।

export const setupPrompt = `Codemagic वर्कफ़्लो जोड़ें जो iOS और Android पर इस प्रोजेक्ट के e2e टेस्ट चलाएँ। डॉक्स: \`https://e2e.com/docs/ci/codemagic.md\` और \`https://e2e.com/docs/ci.md\`

1. दोनों पेज पढ़ें।
2. वर्कफ़्लो \`codemagic.yaml\` में जोड़ें। प्रोजेक्ट पाथ, scheme और Node वर्ज़न इस प्रोजेक्ट के हिसाब से ढालें।
3. मुझसे मॉडल key को \`e2e\` एनवायरनमेंट वेरिएबल ग्रुप में जोड़ने को कहें, सीक्रेट मार्क करके।
4. मेरे बिल्ड शुरू करने के बाद बिल्ड का लॉग पढ़ें, और दोनों वर्कफ़्लो पास होने तक एरर ठीक करते रहें।`;

यह सेटअप iOS टेस्ट Mac mini इंस्टेंस पर और Android टेस्ट Linux इंस्टेंस पर चलाता है,
दोनों के लिए एक-एक वर्कफ़्लो। यह [मोबाइल जॉब](https://e2e.com/docs/hi/ci#mobile-jobs) वाले नियम मानता
है।

<SetupPrompt>

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

</SetupPrompt>

## वर्कफ़्लो

Ubuntu इमेज में `emulator` (API 34), `emulator-35` और `emulator-36` नाम के AVD
हैं। Linux इंस्टेंस के लिए बिलिंग चालू होनी चाहिए। `test_report` `junit.xml` को
बिल्ड के Tests टैब पर भेजता है।

```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/**
```

## मॉडल key

मॉडल key को `e2e` एनवायरनमेंट वेरिएबल ग्रुप में रखें, और उसे सीक्रेट मार्क करें।
जो भी बिल्ड यह ग्रुप पढ़ता है, उसमें चलने वाला कोड key पढ़ सकता है, उस पुल
रिक्वेस्ट का कोड भी जिस पर आप भरोसा नहीं करते। इस ग्रुप के साथ पुल रिक्वेस्ट
बिल्ड सिर्फ़ उन कॉन्ट्रिब्यूटर के लिए ट्रिगर करें जिन पर आप भरोसा करते हैं।
[मॉडल क्रेडेंशियल](https://e2e.com/docs/hi/ci#model-credentials) देखें।

## आगे

<CardGroup cols={2}>
  <Card title="कंटीन्यूअस इंटीग्रेशन" icon="rotate" href="/ci">
    CI के डिफ़ॉल्ट, शार्डिंग, दोबारा रन और एग्ज़िट कोड।
  </Card>
  <Card title="होस्टेड डिवाइस" icon="cloud" href="/mobile#hosted-devices">
    किसी सर्विस से डिवाइस लीज़ पर लें। तब रनर कोई डिवाइस बूट नहीं करता।
  </Card>
</CardGroup>
