Skip to content

Add iOS Navigation Tests workflow to GitHub Actions#213

Merged
StuartFerguson merged 73 commits intomainfrom
task/#209_ios_navigation_tests_after_net9_upgrade
Jul 2, 2025
Merged

Add iOS Navigation Tests workflow to GitHub Actions#213
StuartFerguson merged 73 commits intomainfrom
task/#209_ios_navigation_tests_after_net9_upgrade

Conversation

@StuartFerguson
Copy link
Copy Markdown
Member

This commit introduces a new GitHub Actions workflow named "Build and Run iOS Navigation Tests" in the ios_navigation_tests.yml file. The workflow is triggered on pull requests to the main branch and runs on macOS 14. It sets up the environment for testing an iOS application by installing Node.js, .NET, Appium, and necessary workloads. The workflow also creates and boots an iOS simulator, restores the MAUI app, builds the code, and executes the iOS navigation tests. Additionally, it uploads Appium logs in case of test failures.

closes #209

This commit introduces a new GitHub Actions workflow named "Build and Run iOS Navigation Tests" in the `ios_navigation_tests.yml` file. The workflow is triggered on pull requests to the `main` branch and runs on macOS 14. It sets up the environment for testing an iOS application by installing Node.js, .NET, Appium, and necessary workloads. The workflow also creates and boots an iOS simulator, restores the MAUI app, builds the code, and executes the iOS navigation tests. Additionally, it uploads Appium logs in case of test failures.
Comment thread .github/workflows/ios_navigation_tests.yml Fixed
Updated the `software_navigation_tests` job in the
`ios_navigation_tests.yml` file to use `macos-15`
instead of `macos-14`, enhancing the testing environment
to leverage new features and improvements in macOS 15.
Comment thread .github/workflows/ios_navigation_tests.yml Fixed
Updated `ios_navigation_tests.yml` and `AppiumDriver.cs`
to change the platform version to "18.0" and device name
to "iPhone 16" for improved testing compatibility.
Comment thread .github/workflows/ios_navigation_tests.yml Fixed
Enhance the `ios_navigation_tests.yml` by adding steps to select, confirm, and accept the Xcode license. This ensures the correct Xcode version is used before building the code and running iOS navigation tests.
Modified `ios_navigation_tests.yml` to comment out the `dotnet build` step and replace it with a `dotnet publish` command configured for the iOS simulator. The test execution step remains unchanged.
Comment thread .github/workflows/ios_navigation_tests.yml Fixed
Comment thread .github/workflows/ios_navigation_tests.yml Fixed
Comment on lines +10 to +189
runs-on: macos-15
env:
PLATFORM_VERSION: "18.5"
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: 📱 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

# Open the simulator UI so Appium doesn’t force-restart it later
open -Fn /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

# Wait a bit to ensure the UI is up
sleep 5


- name: List available simulators
run: |
xcrun simctl list | grep $SIMULATOR_ID

#- name: Build, verify, and deploy WebDriverAgent
# run: |
# set -euo pipefail

# # Set up vars
# WDA_DIR="/tmp/WebDriverAgent"
# DERIVED_DATA="/Users/runner/Library/Developer/Xcode/DerivedData/WebDriverAgent"
# #SIMULATOR_UDID="${{ env.UDID }}"
# echo "Using simulator $SIMULATOR_ID"

# # 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_ID" \
# -derivedDataPath "/Users/runner/Library/Developer/Xcode/DerivedData/WebDriverAgent" \
# 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"

# # Launch WDA via xcodebuild test-without-building (required for XCTest runners)
# echo "Launching WebDriverAgent test runner on simulator..."
# xcodebuild test-without-building \
# -project "$WDA_DIR/WebDriverAgent.xcodeproj" \
# -scheme WebDriverAgentRunner \
# -destination "id=$SIMULATOR_ID" \
# -derivedDataPath "$DERIVED_DATA" \
# IPHONEOS_DEPLOYMENT_TARGET=18.0 \
# GCC_TREAT_WARNINGS_AS_ERRORS=0 \
# COMPILER_INDEX_STORE_ENABLE=NO \
# > /tmp/wda-launch.log 2>&1 &

# # Wait for WDA to be ready
# echo "Waiting for WDA to be available on http://127.0.0.1:8100/status..."

# for i in {1..30}; do
# if curl --silent --fail http://127.0.0.1:8100/status | grep -q "state"; then
# echo "✅ WDA is up and running."
# exit 0
# fi
# echo "Waiting... ($i)"
# sleep 2
# done

# echo "::error::WDA failed to start within timeout."
# exit 1

# echo "✅ WDA built, verified, installed, and launched successfully."

- name: 🧪 Start Appium Server
run: |
nohup appium --log appium.log &

- 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-arm64 /p:EnableAssemblyILStripping=false /p:EnableSymbolStrip=false /p:LinkMode=None
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

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


No newline at end of file

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 10 months ago

To fix the issue, add a permissions block to the workflow file to explicitly limit the permissions of the GITHUB_TOKEN. Since the workflow primarily reads repository contents and does not perform write operations, the permissions can be set to contents: read. This ensures the workflow has only the minimum access required to complete its tasks.

The permissions block should be added at the root level of the workflow file, so it applies to all jobs unless overridden by a job-specific permissions block.


Suggested changeset 1
.github/workflows/ios_navigation_tests.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ios_navigation_tests.yml b/.github/workflows/ios_navigation_tests.yml
--- a/.github/workflows/ios_navigation_tests.yml
+++ b/.github/workflows/ios_navigation_tests.yml
@@ -7,2 +7,5 @@
 
+permissions:
+  contents: read
+
 jobs:
EOF
@@ -7,2 +7,5 @@

permissions:
contents: read

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
@StuartFerguson StuartFerguson merged commit 827e6d0 into main Jul 2, 2025
14 checks passed
@github-actions github-actions Bot deleted the task/#209_ios_navigation_tests_after_net9_upgrade branch September 1, 2025 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS Navigation Tests after Net 9 Upgrade

2 participants