Skip to content

Add iOS Navigation Tests workflow to GitHub Actions #204

Add iOS Navigation Tests workflow to GitHub Actions

Add iOS Navigation Tests workflow to GitHub Actions #204

name: Build and Run iOS Navigation Tests
on:
pull_request:
branches:
- main
jobs:
software_navigation_tests:
runs-on: macos-15
env:
PLATFORM_VERSION: "18.0"
DEVICE_NAME: "iPhone 16"
APP_PATH: "./MyTestApp.app"
steps:
- name: 🧾 Checkout repo
uses: actions/checkout@v4
- name: 🔧 Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 🔧 Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: 📦 Install Appium + XCUITest driver
run: |
npm install -g appium
appium driver install xcuitest
- name: 🧹 Clean DerivedData and WDA cache
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/.appium/node_modules/appium-webdriveragent/Build
- name: 🧪 Start Appium Server
run: |
nohup appium --log appium.log &
- name: 📱 Create iOS Simulator (if needed)
run: |
SIMULATOR_NAME="ci-sim-$RANDOM"
xcrun simctl create "$SIMULATOR_NAME" "$DEVICE_NAME" "com.apple.CoreSimulator.SimRuntime.iOS-${PLATFORM_VERSION//./-}"
echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV
- name: 🚀 Boot simulator
run: |
xcrun simctl boot "$SIMULATOR_NAME"
SIMULATOR_ID=$(xcrun simctl list | grep 'Booted' | awk -F '[()]' '{print $2}')
echo "SIMULATOR_ID=$SIMULATOR_ID"
echo "SIMULATOR_ID=$SIMULATOR_ID" >> $GITHUB_ENV
- name: Build, verify, and deploy WebDriverAgent
run: |
set -euo pipefail
# Set up vars
WDA_DIR="/tmp/WebDriverAgent"
DERIVED_DATA="$HOME/Library/Developer/Xcode/DerivedData"
SIMULATOR_UDID="${{ env.UDID }}"
echo "Using simulator $SIMULATOR_UDID"
# Clone WDA
echo "Cloning WebDriverAgent..."
git clone https://github.com/appium/WebDriverAgent.git "$WDA_DIR"
# Build WDA using xcodebuild without signing (safe for CI)
echo "Building WebDriverAgentRunner..."
xcodebuild -project "$WDA_DIR/WebDriverAgent.xcodeproj" \
-scheme WebDriverAgentRunner \
-destination "id=$SIMULATOR_UDID" \
CODE_SIGNING_ALLOWED=NO \
build-for-testing
# Verify build output
echo "Looking for WDA build output..."
WDA_APP=$(find "$DERIVED_DATA" -type d -name "WebDriverAgentRunner-Runner.app" | head -n 1)
if [ -z "$WDA_APP" ]; then
echo "::error ::Failed to locate built WebDriverAgentRunner-Runner.app"
exit 1
fi
echo "Found built WDA app at: $WDA_APP"
# Install app to simulator
echo "Installing WDA app to simulator $SIMULATOR_UDID..."
xcrun simctl install "$SIMULATOR_UDID" "$WDA_APP"
# Launch WDA manually to ensure it's functional
echo "Launching WDA app on simulator..."
LAUNCH_OUTPUT=$(xcrun simctl launch "$SIMULATOR_UDID" com.facebook.WebDriverAgentRunner.xctrunner || true)
if echo "$LAUNCH_OUTPUT" | grep -q "error"; then
echo "::error ::Failed to launch WebDriverAgent on simulator. Output:"
echo "$LAUNCH_OUTPUT"
exit 1
fi
echo "✅ WDA built, verified, installed, and launched successfully."
- name: Install MAUI Workloads
run: |
dotnet workload install ios --ignore-failed-sources
dotnet workload install maui --ignore-failed-sources
- name: Restore MAUI App for iOS
run: dotnet restore TransactionProcessor.Mobile.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json
- name: Select Xcode 16.4
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
- name: Confirm Xcode version
run: xcodebuild -version
- name: Accept Xcode license
run: sudo xcodebuild -license accept
- name: Build Code
#run: dotnet build TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -f net9.0-ios -c Release --no-restore
run: dotnet build TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -c Release -f net9.0-ios -r iossimulator-x64 /p:EnableAssemblyILStripping=false /p:EnableSymbolStrip=false /p:LinkMode=None
#- name: Build TestCategoryLister
# run: |
# dotnet build TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj -c Debug --no-restore
# dotnet build TestCategoryLister/TestCategoryLister.csproj -c Release
#- name: Run CategoryListerTool on UI Tests
# run: |
# dotnet TestCategoryLister/bin/Release/net9.0/TestCategoryLister.dll TransactionProcessor.Mobile.UiTests/bin/Debug/net9.0/TransactionProcessor.Mobile.UiTests.dll
- name: List all files with full path
run: |
find /Users/runner/work/TransactionMobile/TransactionMobile/TransactionProcessor.Mobile/bin -type f
- name: Run iOS Navigation Tests
run: |
#dotnet build TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj -c Debug --no-restore
dotnet test TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj --filter "Category=PRNavTest" --no-restore
# dotnet tool install --global NUnit.ConsoleRunner.NetCore
# nunit3-console TransactionProcessor.Mobile.UiTests/bin/Release/net9.0/TransactionProcessor.Mobile.UiTests.dll --where "(cat == PRNavTest && cat == iOS)"
# - name: Run iOS Navigation Tests
# run: |
# # Install NUnit Console Runner tool
# dotnet tool install --global NUnit.ConsoleRunner.NetCore
# # Ensure the tool path is available in this step
# export PATH="$PATH:$HOME/.dotnet/tools"
# # Optional: clean + build test project if not already built
# dotnet build TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj -c Release --no-restore
# # Run the tests filtered by categories
# nunit TransactionProcessor.Mobile.UiTests/bin/Release/net9.0/TransactionProcessor.Mobile.UiTests.dll --where "cat == PRNavTest && cat == iOS" --labels=All --result=TestResult-iOS.xml
- name: Upload Appium Logs on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: ios-software_navigation_tests_appium
path: appium.log
# - name: Upload NUnit Test Results
# uses: actions/upload-artifact@v4
# with:
# name: iOS-Test-Results
# path: TestResult-iOS.xml