Skip to content

Commit

Permalink
Use correct simulator for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaSimsic committed Feb 12, 2025
1 parent 5940d84 commit 766b0c1
Showing 1 changed file with 205 additions and 49 deletions.
254 changes: 205 additions & 49 deletions .github/workflows/NativePipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -522,63 +522,219 @@ jobs:
brew tap wix/brew
brew install applesimutils
- name: Check available runtimes
run: xcrun simctl list runtimes
- name: Check avialble device types
run: xcrun simctl list devicetypes
# - name: Create iOS 18.1 simulator for iPhone 16
# run: xcrun simctl create "iPhone 16" com.apple.CoreSimulator.SimDeviceType.iPhone-16 com.apple.CoreSimulator.SimRuntime.iOS-18-1
- name: List supported iOS devices
run: applesimutils --list
- name: Find or Create Simulator
id: find-or-create-simulator
run: |
SIMULATOR_ID=$(xcrun simctl list devices | grep "iPhone 16" | grep -v "unavailable" | grep -v "Shutdown" | awk -F '[()]' '{print $2}' | head -n 1)
if [ -z "$SIMULATOR_ID" ]; then
echo "No available simulator found for iPhone 16. Creating a new one..."
xcrun simctl create "iPhone 16" "com.apple.CoreSimulator.SimDeviceType.iPhone-16" "com.apple.CoreSimulator.SimRuntime.iOS-15-0"
SIMULATOR_ID=$(xcrun simctl list devices | grep "iPhone 16" | grep -v "unavailable" | grep -v "Shutdown" | awk -F '[()]' '{print $2}' | head -n 1)
fi
echo "SIMULATOR_ID=$SIMULATOR_ID" >> $GITHUB_ENV
echo "Simulator ID: $SIMULATOR_ID"
# - name: Boot Simulator
# run: xcrun simctl boot "iPhone 15"
# - name: Wait for Simulator to Boot
# run: |
# while ! xcrun simctl list | grep "Booted"; do
# echo "Waiting for simulator to boot..."
# sleep 5
# done
- name: Boot Simulator
env:
SIMULATOR_ID: ${{ env.SIMULATOR_ID }}
run: xcrun simctl boot $SIMULATOR_ID
- name: Wait for Simulator to Boot
run: |
while ! xcrun simctl list | grep "Booted"; do
echo "Waiting for simulator to boot..."
sleep 5
done
# - name: "Check if iOS app exists in detox/apps"
# run: |
# APP_PATH="detox/apps/NativeTemplate.app"
# if [ ! -d "$APP_PATH" ]; then
# echo "App not found at path: $APP_PATH"
# else
# echo "App found at path: $APP_PATH"
# fi
- name: "Check if iOS app exists in detox/apps"
run: |
APP_PATH="detox/apps/NativeTemplate.app"
if [ ! -d "$APP_PATH" ]; then
echo "App not found at path: $APP_PATH"
else
echo "App found at path: $APP_PATH"
fi
# - name: "Check if iOS app exists in full BINARY_PATH"
# run: |
# BINARY_PATH="/Users/runner/work/native-widgets/native-widgets/detox/apps/NativeTemplate.app"
# echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
# if [ ! -d "$BINARY_PATH" ]; then
# echo "App not found at path: $BINARY_PATH"
# echo "Listing contents of the apps directory:"
# ls -R /Users/runner/work/native-widgets/native-widgets/detox/apps # List contents of the apps directory for debugging
# else
# echo "App found at path: $BINARY_PATH"
# fi
- name: "Check if iOS app exists in full BINARY_PATH"
run: |
BINARY_PATH="/Users/runner/work/native-widgets/native-widgets/detox/apps/NativeTemplate.app"
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
if [ ! -d "$BINARY_PATH" ]; then
echo "App not found at path: $BINARY_PATH"
echo "Listing contents of the apps directory:"
ls -R /Users/runner/work/native-widgets/native-widgets/detox/apps # List contents of the apps directory for debugging
else
echo "App found at path: $BINARY_PATH"
fi
# - name: "List contents of the app bundle"
# run: |
# echo "Listing contents of the app bundle at $BINARY_PATH:"
# ls -R "$BINARY_PATH"
- name: "List contents of the app bundle"
run: |
echo "Listing contents of the app bundle at $BINARY_PATH:"
ls -R "$BINARY_PATH"
# - name: "Install app on simulator"
# run: |
# SIMULATOR_ID=$(xcrun simctl list devices | grep "iPhone 15" | grep "Booted" | awk -F '[()]' '{print $2}')
# if [ -z "$SIMULATOR_ID" ]; then
# echo "No booted simulator found for iPhone 15."
# exit 1
# fi
# echo "Installing app on simulator with ID: $SIMULATOR_ID"
# xcrun simctl install "$SIMULATOR_ID" "$BINARY_PATH"
- name: "Install app on simulator"
run: |
if [ -z "$SIMULATOR_ID" ]; then
echo "No booted simulator found for iPhone 16."
exit 1
fi
echo "Installing app on simulator with ID: $SIMULATOR_ID"
xcrun simctl install "$SIMULATOR_ID" "$BINARY_PATH"
- name: "Verify app installation"
run: |
if ! xcrun simctl get_app_container "$SIMULATOR_ID" com.mendix.native.template; then
echo "App is not installed on the simulator."
exit 1
else
echo "App is installed on the simulator."
fi
- name: "Run tests"
env:
env: ios-tests:
needs: [scope, mendix-version, project, ios-app]
runs-on: macos-15
steps:
- name: "Check out code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
with:
fetch-depth: 0
- name: "Set up node"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version-file: .nvmrc
cache: yarn
- name: "Install dependencies"
run: yarn install --immutable
- name: "Download project MDA file"
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: mda

- name: "Clean detox framework cache"
run: npx detox clean-framework-cache
- name: "Build detox framework cache"
run: npx detox build-framework-cache

- name: "Start runtime"
uses: ./.github/actions/start-runtime
with:
mda-file: automation.mda
mendix-version: ${{ needs.mendix-version.outputs.mendix_version }}
- name: "Download iOS app"
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: ios-app
path: ios-app
- name: "Move iOS app to correct location"
run: |
mkdir -p detox/apps
find ios-app -type d -iname "*.app" -exec cp -R {} detox/apps/ \;
- name: Install Detox Dependencies
run: |
brew tap wix/brew
brew install applesimutils
- name: Find or Create Simulator
id: find-or-create-simulator
run: |
SIMULATOR_ID=$(xcrun simctl list devices | grep "iPhone 16" | grep -v "unavailable" | grep -v "Shutdown" | awk -F '[()]' '{print $2}' | head -n 1)
if [ -z "$SIMULATOR_ID" ]; then
echo "No available simulator found for iPhone 16. Creating a new one..."
xcrun simctl create "iPhone 16" "com.apple.CoreSimulator.SimDeviceType.iPhone-16" "com.apple.CoreSimulator.SimRuntime.iOS-15-0"
SIMULATOR_ID=$(xcrun simctl list devices | grep "iPhone 16" | grep -v "unavailable" | grep -v "Shutdown" | awk -F '[()]' '{print $2}' | head -n 1)
fi
echo "SIMULATOR_ID=$SIMULATOR_ID" >> $GITHUB_ENV
echo "Simulator ID: $SIMULATOR_ID"
- name: Boot Simulator
env:
SIMULATOR_ID: ${{ env.SIMULATOR_ID }}
run: xcrun simctl boot $SIMULATOR_ID
- name: Wait for Simulator to Boot
run: |
while ! xcrun simctl list | grep "Booted"; do
echo "Waiting for simulator to boot..."
sleep 5
done
- name: "Check if iOS app exists in detox/apps"
run: |
APP_PATH="detox/apps/NativeTemplate.app"
if [ ! -d "$APP_PATH" ]; then
echo "App not found at path: $APP_PATH"
else
echo "App found at path: $APP_PATH"
fi
- name: "Check if iOS app exists in full BINARY_PATH"
run: |
BINARY_PATH="/Users/runner/work/native-widgets/native-widgets/detox/apps/NativeTemplate.app"
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
if [ ! -d "$BINARY_PATH" ]; then
echo "App not found at path: $BINARY_PATH"
echo "Listing contents of the apps directory:"
ls -R /Users/runner/work/native-widgets/native-widgets/detox/apps # List contents of the apps directory for debugging
else
echo "App found at path: $BINARY_PATH"
fi
- name: "List contents of the app bundle"
run: |
echo "Listing contents of the app bundle at $BINARY_PATH:"
ls -R "$BINARY_PATH"
- name: "Install app on simulator"
env:
SIMULATOR_ID: ${{ env.SIMULATOR_ID }}
run: |
if [ -z "$SIMULATOR_ID" ]; then
echo "No booted simulator found for iPhone 16."
exit 1
fi
echo "Installing app on simulator with ID: $SIMULATOR_ID"
xcrun simctl install "$SIMULATOR_ID" "$BINARY_PATH"
- name: "Verify app installation"
env:
SIMULATOR_ID: ${{ env.SIMULATOR_ID }}
run: |
if ! xcrun simctl get_app_container "$SIMULATOR_ID" com.mendix.native.template; then
echo "App is not installed on the simulator."
exit 1
else
echo "App is installed on the simulator."
fi
- name: "Run tests"
env:
DETOX_LOGLEVEL: trace
SIMULATOR_ID: ${{ env.SIMULATOR_ID }}
run: yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test:e2e:ios
- name: "Archive runtime logs"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always()
with:
name: ios-runtime-logs
path: log/*.log
if-no-files-found: ignore
- name: "Archive test screenshot diff results"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: failure()
with:
name: ios-screenshot-results
path: |
${{ github.workspace }}/packages/**/e2e/images/diffs/**/*.png
${{ github.workspace }}/packages/**/e2e/images/actual/**/*.png
if-no-files-found: ignore
- name: "Archive artifacts"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always()
with:
name: ios-artifacts
path: packages/pluggableWidgets/**/artifacts/
if-no-files-found: ignore
DETOX_LOGLEVEL: trace
SIMULATOR_ID: ${{ env.SIMULATOR_ID }}
run: yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test:e2e:ios
- name: "Archive runtime logs"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
Expand Down

0 comments on commit 766b0c1

Please sign in to comment.