v1.1.431 #93
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: iOS Native Tests | |
env: | |
# Specify an iOS version to test on. | |
# Examples: "17", "18", "18-2", or leave it blank, which means any available version. | |
simulator_ios_version: 18 | |
# Name of the simulator device to use. | |
# Note that if you also specified an iOS version, the simulator device must be available for that version. To see available devices and their iOS versions, run `xcrun simctl list devices available --json | jq -r '[.devices | to_entries[] | select(.key | contains("SimRuntime.iOS")) | .key as $runtime | .value[] | { runtime: $runtime, name: .name, udid: .udid }]'`. | |
# Examples: "iPhone 15 Pro", "iPhone 16 Pro Max". | |
simulator_device_name: iPhone 16 Pro | |
on: | |
push: | |
pull_request: | |
jobs: | |
build-ios-test-container-dev: | |
name: Build iOS RN Test App (Dev) | |
uses: ./.github/workflows/build-ios-test-container-app.yml | |
secrets: inherit | |
permissions: | |
contents: read | |
pull-requests: read | |
with: | |
configuration: Debug | |
build-ios-test-container-prod: | |
name: Build iOS RN Test App (Prod) | |
uses: ./.github/workflows/build-ios-test-container-app.yml | |
secrets: inherit | |
permissions: | |
contents: read | |
pull-requests: read | |
with: | |
configuration: Release | |
test-ios-native-dev: | |
name: Native iOS Tests (Dev) | |
needs: | |
- build-ios-test-container-dev | |
runs-on: macos-14 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install | |
uses: ./.github/actions/install | |
- name: Download Built Test Container App | |
uses: actions/cache/restore@v4 | |
with: | |
fail-on-cache-miss: true | |
key: ${{ needs.build-ios-test-container-dev.outputs.built-app-cache-key }} | |
path: ${{ needs.build-ios-test-container-dev.outputs.built-app-path }} | |
- name: Get Simulator UDID | |
id: get-simulator-udid | |
env: | |
SIMULATOR_IOS_VERSION: ${{ env.simulator_ios_version }} | |
SIMULATOR_DEVICE_NAME: ${{ env.simulator_device_name }} | |
run: | | |
AVAILABLE_SIMULATORS=$(xcrun simctl list devices available --json | jq -r '[.devices | to_entries[] | select(.key | contains("SimRuntime.iOS")) | .key as $runtime | .value[] | { runtime: $runtime, name: .name, udid: .udid }]') | |
echo "Available simulators: $AVAILABLE_SIMULATORS" | |
SELECTED_SIMULATOR=$(echo $AVAILABLE_SIMULATORS | jq -r "[.[] | select(.runtime | contains(\"$SIMULATOR_IOS_VERSION\")) | select(.name | \"$SIMULATOR_DEVICE_NAME\")] | first") | |
if [ -z "$SELECTED_SIMULATOR" ] || [ "$SELECTED_SIMULATOR" = "null" ]; then | |
echo "Error: No simulator found for iOS version $SIMULATOR_IOS_VERSION and device name $SIMULATOR_DEVICE_NAME" | |
exit 1 | |
fi | |
echo "Selected simulator: $SELECTED_SIMULATOR" | |
SIMULATOR_UDID=$(echo $SELECTED_SIMULATOR | jq -r .udid) | |
if [ -z "$SIMULATOR_UDID" ] || [ "$SIMULATOR_UDID" = "null" ]; then | |
echo "Error: Could not get simulator UDID" | |
exit 1 | |
fi | |
echo "Simulator UDID: $SIMULATOR_UDID" | |
echo "simulator_udid=$SIMULATOR_UDID" >> $GITHUB_OUTPUT | |
- name: Boot Simulator | |
env: | |
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }} | |
run: xcrun simctl boot $SIMULATOR_UDID | |
- name: Get NPM Global Root Path | |
id: get-npm-global-root-path | |
run: | | |
NPM_GLOBAL_ROOT_PATH=$(npm root -g) | |
echo "NPM global root path: $NPM_GLOBAL_ROOT_PATH" | |
echo "path=$NPM_GLOBAL_ROOT_PATH" >> $GITHUB_OUTPUT | |
- uses: actions/cache/restore@v4 | |
with: | |
path: ${{ steps.get-npm-global-root-path.outputs.path }} | |
key: ${{ runner.os }}-npm-appium | |
- name: Install and Run Appium Server | |
run: | | |
npm install -g appium | |
appium driver install xcuitest | |
appium > /tmp/appium.log & | |
sleep 3 | |
- uses: actions/cache/save@v4 | |
with: | |
path: ${{ steps.get-npm-global-root-path.outputs.path }} | |
key: ${{ runner.os }}-npm-appium | |
- name: Test | |
env: | |
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }} | |
TEST_CONTAINER_PATH: ${{ github.workspace }}/${{ needs.build-ios-test-container-dev.outputs.built-app-path }} | |
run: | | |
yarn test-ios | |
- name: Upload Appium Logs | |
uses: actions/[email protected] | |
if: ${{ always() }} | |
continue-on-error: true | |
with: | |
name: appium.log | |
path: | | |
/tmp/appium.log |