-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (145 loc) · 6.32 KB
/
ios-simulator-tests.yml
File metadata and controls
176 lines (145 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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-xlarge
steps:
# - 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: Check if required ports are open
uses: nrukavkov/open-ports-check-action@v1
with:
port: 5223
host: "api.sandbox.push.apple.com"
# - name: Create and Boot iOS Simulator
# id: create-simulator
# run: |
# SIMULATOR_NAME="hapns-test-iphone"
# DEVICE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro"
# RUNTIME="com.apple.CoreSimulator.SimRuntime.iOS-18-5"
# echo "🛠️ Creating simulator: $SIMULATOR_NAME"
# UDID=$(xcrun simctl create "$SIMULATOR_NAME" "$DEVICE_TYPE" "$RUNTIME")
# echo "✅ Simulator created (uuid: '$UDID')"
# echo "🛠️ Booting simulator: $SIMULATOR_NAME ($UDID)"
# xcrun simctl boot "$UDID"
# echo "✅ Simulator booted."
# echo "udid=$UDID" >> $GITHUB_OUTPUT
# echo "simulator-name=$SIMULATOR_NAME" >> $GITHUB_OUTPUT
# - name: Set Simulator Language and Locale
# run: |
# UDID="${{ steps.create-simulator.outputs.udid }}"
# LANGUAGE="en"
# LOCALE="en_US"
# echo "🛠️ Setting simulator language to '$LANGUAGE' and locale to '$LOCALE'..."
# xcrun simctl spawn "$UDID" defaults write "Apple Global Domain" AppleLanguages -array "$LANGUAGE"
# xcrun simctl spawn "$UDID" defaults write "Apple Global Domain" AppleLocale -string "$LOCALE"
# xcrun simctl spawn "$UDID" launchctl stop com.apple.SpringBoard
# echo "✅ Simulator language set."
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Build iOS App
# run: |
# UDID="${{ steps.create-simulator.outputs.udid }}"
# PROJECT_PATH="examples/AlertNotification-example/ios-app/personalized-news-feed/personalized-news-feed.xcodeproj"
# SCHEME="personalized-news-feed"
# echo "🛠️ Building scheme '$SCHEME' for simulator..."
# xcodebuild clean build-for-testing \
# -project "$PROJECT_PATH" \
# -scheme "$SCHEME" \
# -sdk iphonesimulator \
# -destination platform="iOS Simulator,id=$UDID" \
# -configuration Debug \
# -verbose
# echo "🎉 Build completed successfully."
# - 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: 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