Skip to content

Test 39 of CI

Test 39 of CI #39

name: iOS Simulator Tests
on:
push:
# branches:
# - master
# pull_request:
# branches:
# - master
jobs:
ios-simulator-tests:
# This supports up to iOS 18.5 Simulator + iOS 26.0
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
# https://github.com/actions/runner-images/issues/3239
runs-on: macos-15
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Build the project
run: pnpm run build
- name: List available simulator runtimes (1/2)
run: xcrun simctl list runtimes
- name: Check Version of Xcodebuild
run: xcodebuild -version
# - uses: maxim-lobanov/setup-xcode@v1
# with:
# xcode-version: latest
# - name: Check Version of Xcodebuild
# run: xcodebuild -version
- name: List available simulator runtimes (2/2)
run: xcrun simctl list runtimes
- name: Check Xcode project settings
run: |
cd examples/AlertNotification-example/ios-app/personalized-news-feed
xcodebuild -project personalized-news-feed.xcodeproj -list
xcodebuild -project personalized-news-feed.xcodeproj -showBuildSettings -scheme personalized-news-feed | grep IPHONEOS_DEPLOYMENT_TARGET
# - name: Download iOS Simulator
# run: xcodebuild -downloadPlatform iOS -arch arm64
- name: Start test server
run: |
echo "Starting test server..."
node specs/server/server.mjs > server.log 2>&1 &
echo $! > server.pid
- name: Run End-to-End iOS Simulator Tests
env:
APNS_TOKEN_KEY: ${{ secrets.APNS_TOKEN_KEY }}
run: pnpm run test
- name: Print server logs on failure
if: failure()
run: |
echo "Dumping server logs..."
cat server.log
- name: Retrieve and Print Test Logs on Failure (1/2)
if: failure()
run: |
echo "Test failed. Retrieving logs..."
xcrun xcresulttool get test-results tests --path /Users/runner/work/hapns/hapns/TestSlowness.xcresult --format json | jq .
- name: Retrieve and Print Test Logs on Failure (2/2)
if: failure()
run: |
echo "Test failed. Retrieving logs..."
DERIVED_DATA_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "personalized-news-feed-*" -type d -maxdepth 1)
XC_RESULT_PATH=$(find $DERIVED_DATA_PATH/Logs/Test -name "*.xcresult" -type d -print -quit)
if [ -n "$XC_RESULT_PATH" ]; then
echo "Found test result bundle at: $XC_RESULT_PATH"
xcrun xcresulttool get test-results summary --path "$XC_RESULT_PATH" --format json | jq .
else
echo "Could not find .xcresult bundle."
fi
- name: Verify app entitlements
if: failure()
env:
APNS_TOKEN_KEY: ${{ secrets.APNS_TOKEN_KEY }}
run: |
echo "Verifying app entitlements before test run..."
DERIVED_DATA_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "personalized-news-feed-*" -type d -maxdepth 1)
APP_PATH=$(find $DERIVED_DATA_PATH/Build/Products -name "*.app" -type d -print -quit)
if [ -n "$APP_PATH" ]; then
echo "Found app bundle at: $APP_PATH"
codesign -d --entitlements :- "$APP_PATH"
else
echo "Could not find .app bundle to verify entitlements."
fi
- name: Cleanup
if: always()
run: |
echo "Cleaning up..."
if [ -f server.pid ]; then
echo "Stopping test server..."
kill $(cat server.pid) || true
rm server.pid
fi