1+ name : Build and Run iOS Navigation Tests - Self Hosted
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+
8+ jobs :
9+ software_navigation_tests_self_hosted :
10+ runs-on : [self-hosted, macOS]
11+ # env:
12+ # PLATFORM_VERSION: "18.5"
13+ # DEVICE_NAME: "iPhone 16"
14+ # APP_PATH: "./MyTestApp.app"
15+
16+ steps :
17+ - name : 🧾 Checkout repo
18+ uses : actions/checkout@v4
19+
20+ # - name: 🔧 Set up Node.js
21+ # uses: actions/setup-node@v4
22+ # with:
23+ # node-version: '20'
24+
25+ # - name: 🔧 Set up .NET
26+ # uses: actions/setup-dotnet@v4
27+ # with:
28+ # dotnet-version: '9.0.x'
29+
30+ # - name: 📦 Install Appium + XCUITest driver
31+ # run: |
32+ # npm install -g appium
33+ # appium driver install xcuitest
34+
35+ # - name: 🧹 Clean DerivedData and WDA cache
36+ # run: |
37+ # rm -rf ~/Library/Developer/Xcode/DerivedData
38+ # rm -rf ~/.appium/node_modules/appium-webdriveragent/Build
39+
40+ # - name: 📱 Create iOS Simulator (if needed)
41+ # run: |
42+ # SIMULATOR_NAME="ci-sim-$RANDOM"
43+ # xcrun simctl create "$SIMULATOR_NAME" "$DEVICE_NAME" "com.apple.CoreSimulator.SimRuntime.iOS-${PLATFORM_VERSION//./-}"
44+ # echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV
45+
46+ # - name: 🚀 Boot simulator
47+ # run: |
48+ # xcrun simctl boot "iPhone 16"
49+ # SIMULATOR_ID=$(xcrun simctl list | grep 'Booted' | awk -F '[()]' '{print $2}')
50+ # echo "SIMULATOR_ID=$SIMULATOR_ID"
51+ # echo "SIMULATOR_ID=$SIMULATOR_ID" >> $GITHUB_ENV
52+
53+ # # Open the simulator UI so Appium doesn’t force-restart it later
54+ # open -Fn /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
55+
56+ # # Wait a bit to ensure the UI is up
57+ # sleep 5
58+ - name : 🚀 Boot simulator
59+ run : |
60+ SIMULATOR_NAME="iPhone 16"
61+
62+ # Check if the simulator is already booted
63+ BOOTED_ID=$(xcrun simctl list devices | grep "$SIMULATOR_NAME" | grep 'Booted' | awk -F '[()]' '{print $2}')
64+
65+ if [ -n "$BOOTED_ID" ]; then
66+ echo "Simulator '$SIMULATOR_NAME' is already booted with ID: $BOOTED_ID"
67+ SIMULATOR_ID="$BOOTED_ID"
68+ else
69+ echo "Booting simulator '$SIMULATOR_NAME'..."
70+ SIMULATOR_ID=$(xcrun simctl list devices | grep "$SIMULATOR_NAME" | head -n 1 | awk -F '[()]' '{print $2}' | xargs)
71+ xcrun simctl boot "$SIMULATOR_ID"
72+ fi
73+
74+ echo "SIMULATOR_ID=$SIMULATOR_ID"
75+ echo "SIMULATOR_ID=$SIMULATOR_ID" >> $GITHUB_ENV
76+
77+
78+ # - name: List available simulators
79+ # run: |
80+ # xcrun simctl list | grep $SIMULATOR_ID
81+
82+ # - name: Build, verify, and deploy WebDriverAgent
83+ # run: |
84+ # set -euo pipefail
85+
86+ # # Set up vars
87+ # WDA_DIR="/tmp/WebDriverAgent"
88+ # DERIVED_DATA="/Users/runner/Library/Developer/Xcode/DerivedData/WebDriverAgent"
89+ # #SIMULATOR_UDID="${{ env.UDID }}"
90+ # echo "Using simulator $SIMULATOR_ID"
91+
92+ # # Clone WDA
93+ # echo "Cloning WebDriverAgent..."
94+ # git clone https://github.com/appium/WebDriverAgent.git "$WDA_DIR"
95+
96+ # # Build WDA using xcodebuild without signing (safe for CI)
97+ # echo "Building WebDriverAgentRunner..."
98+ # xcodebuild -project "$WDA_DIR/WebDriverAgent.xcodeproj" \
99+ # -scheme WebDriverAgentRunner \
100+ # -destination "id=$SIMULATOR_ID" \
101+ # -derivedDataPath "/Users/runner/Library/Developer/Xcode/DerivedData/WebDriverAgent" \
102+ # CODE_SIGNING_ALLOWED=NO \
103+ # build-for-testing
104+
105+ # # Verify build output
106+ # echo "Looking for WDA build output..."
107+ # WDA_APP=$(find "$DERIVED_DATA" -type d -name "WebDriverAgentRunner-Runner.app" | head -n 1)
108+ # if [ -z "$WDA_APP" ]; then
109+ # echo "::error ::Failed to locate built WebDriverAgentRunner-Runner.app"
110+ # exit 1
111+ # fi
112+ # echo "Found built WDA app at: $WDA_APP"
113+
114+ # # Launch WDA via xcodebuild test-without-building (required for XCTest runners)
115+ # echo "Launching WebDriverAgent test runner on simulator..."
116+ # xcodebuild test-without-building \
117+ # -project "$WDA_DIR/WebDriverAgent.xcodeproj" \
118+ # -scheme WebDriverAgentRunner \
119+ # -destination "id=$SIMULATOR_ID" \
120+ # -derivedDataPath "$DERIVED_DATA" \
121+ # IPHONEOS_DEPLOYMENT_TARGET=18.0 \
122+ # GCC_TREAT_WARNINGS_AS_ERRORS=0 \
123+ # COMPILER_INDEX_STORE_ENABLE=NO \
124+ # > /tmp/wda-launch.log 2>&1 &
125+
126+ # # Wait for WDA to be ready
127+ # echo "Waiting for WDA to be available on http://127.0.0.1:8100/status..."
128+
129+ # for i in {1..30}; do
130+ # if curl --silent --fail http://127.0.0.1:8100/status | grep -q "state"; then
131+ # echo "✅ WDA is up and running."
132+ # exit 0
133+ # fi
134+ # echo "Waiting... ($i)"
135+ # sleep 2
136+ # done
137+
138+ # echo "::error::WDA failed to start within timeout."
139+ # exit 1
140+
141+ # echo "✅ WDA built, verified, installed, and launched successfully."
142+
143+ - name : 🧪 Start Appium Server
144+ run : |
145+ nohup appium --log appium.log &
146+
147+ # - name: Install MAUI Workloads
148+ # run: |
149+ # dotnet workload install ios --ignore-failed-sources
150+ # dotnet workload install maui --ignore-failed-sources
151+
152+ - name : Restore MAUI App for iOS
153+ 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
154+
155+ # - name: Select Xcode 16.4
156+ # run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
157+
158+ # - name: Confirm Xcode version
159+ # run: xcodebuild -version
160+
161+ # - name: Accept Xcode license
162+ # run: sudo xcodebuild -license accept
163+
164+ - name : Build Code
165+ # run: dotnet build TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -f net9.0-ios -c Release --no-restore
166+ # run: dotnet build TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -c Release -f net9.0-ios -r iossimulator-arm64 /p:EnableAssemblyILStripping=false /p:EnableSymbolStrip=false /p:LinkMode=None
167+ run : dotnet build TransactionProcessor.Mobile/TransactionProcessor.Mobile.csproj -c Release -f net9.0-ios -r iossimulator-arm64 # /p:LinkMode=SdkOnly /p:EnableAssemblyILStripping=true /p:EnableSymbolStrip=true /p:Codesign=false /p:DebugSymbols=false /p:UseInterpreter=true
168+
169+ # - name: List all files with full path
170+ # run: |
171+ # find /Users/runner/work/TransactionMobile/TransactionMobile/TransactionProcessor.Mobile/bin -type f
172+
173+ - name : Run iOS Navigation Tests
174+ run : |
175+ #dotnet build TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj -c Debug --no-restore
176+ dotnet test TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj --filter "Category=iOSPRTest" --no-restore
177+ # dotnet tool install --global NUnit.ConsoleRunner.NetCore
178+ # nunit3-console TransactionProcessor.Mobile.UiTests/bin/Release/net9.0/TransactionProcessor.Mobile.UiTests.dll --where "(cat == PRNavTest && cat == iOS)"
179+
180+ # - name: Run iOS Navigation Tests
181+ # run: |
182+ # # Install NUnit Console Runner tool
183+ # dotnet tool install --global NUnit.ConsoleRunner.NetCore
184+
185+ # # Ensure the tool path is available in this step
186+ # export PATH="$PATH:$HOME/.dotnet/tools"
187+
188+ # # Optional: clean + build test project if not already built
189+ # dotnet build TransactionProcessor.Mobile.UiTests/TransactionProcessor.Mobile.UiTests.csproj -c Release --no-restore
190+
191+ # # Run the tests filtered by categories
192+ # nunit TransactionProcessor.Mobile.UiTests/bin/Release/net9.0/TransactionProcessor.Mobile.UiTests.dll --where "cat == PRNavTest && cat == iOS" --labels=All --result=TestResult-iOS.xml
193+
194+ - name : Upload Appium Logs on Failure
195+ if : failure()
196+ uses : actions/upload-artifact@v4
197+ with :
198+ name : ios-software_navigation_tests_appium
199+ path : appium.log
200+
201+ # - name: Upload NUnit Test Results
202+ # uses: actions/upload-artifact@v4
203+ # with:
204+ # name: iOS-Test-Results
205+ # path: TestResult-iOS.xml
206+
207+
0 commit comments