-
Notifications
You must be signed in to change notification settings - Fork 427
204 lines (202 loc) · 7.75 KB
/
Copy pathreusable-ui-test-workflow.yaml
File metadata and controls
204 lines (202 loc) · 7.75 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
on:
workflow_call:
inputs:
is_pr:
type: boolean
default: false
ios:
default: "^26"
required: false
type: string
xcode:
default: "^26"
required: false
type: string
macos:
default: macos-latest
required: false
type: string
pr_test:
description: "Test identifier to run for PR (e.g. 'AuthFlowTesterUITests/LegacyLoginTests/testMethod'). Empty = run all tests."
default: ""
required: false
type: string
test_suite:
description: "Test suite to run (e.g. 'AuthFlowTesterUITests/BeaconLoginTests'). Empty = run all tests. Used with matrix for parallel nightly runs."
default: ""
required: false
type: string
destination:
description: "xcodebuild -destination (e.g. 'platform=iOS Simulator,name=iPhone 17,OS=26.0'). Empty = use default for iOS 26."
default: ""
required: false
type: string
short_timeout:
description: "UI test short timeout in seconds (env UI_TEST_SHORT_TIMEOUT). Empty = use code default (1)."
default: ""
required: false
type: string
long_timeout:
description: "UI test long timeout in seconds (env UI_TEST_LONG_TIMEOUT). Empty = use code default (3)."
default: ""
required: false
type: string
secrets:
UI_TEST_CONFIG:
required: true
CODECOV_TOKEN:
required: true
permissions:
contents: read
pull-requests: write
jobs:
test-ui:
runs-on: ${{ inputs.macos }}
steps:
- name: Set result suffix for matrix runs
id: result_suffix
env:
TEST_SUITE: ${{ inputs.test_suite }}
run: |
if [ -n "$TEST_SUITE" ]; then
printf 'suffix=%s\n' "${TEST_SUITE//\//-}" >> "$GITHUB_OUTPUT"
else
printf 'suffix=%s\n' "all" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
if: ${{ inputs.is_pr }}
with:
persist-credentials: false
fetch-depth: 100
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
if: ${{ !inputs.is_pr }}
with:
persist-credentials: false
ref: ${{ github.head_ref }}
- name: Install Dependencies
env:
UI_TEST_CONFIG: ${{ secrets.UI_TEST_CONFIG }}
run: |
./install.sh
echo "$UI_TEST_CONFIG" > ./shared/test/ui_test_config.json
# Select Xcode only (mxcl action does not support -retry-tests-on-failure)
- uses: mxcl/xcodebuild@d3ee9b419c1be9a988086c58fe0988f32d99cfc5 # v3.6.0
with:
xcode: ${{ inputs.xcode }}
platform: iOS
platform-version: ${{ inputs.ios }}
action: none
- name: Resolve simulator destination
id: resolve_destination
env:
DESTINATION_INPUT: ${{ inputs.destination }}
IOS: ${{ inputs.ios }}
run: |
if [ -n "$DESTINATION_INPUT" ]; then
printf 'destination=%s\n' "$DESTINATION_INPUT" >> "$GITHUB_OUTPUT"
else
# Extract major iOS version from input (e.g. ^26 -> 26, 26.0 -> 26)
IOS_VERSION="$IOS"
IOS_MAJOR=$(echo "$IOS_VERSION" | sed 's/^\^//' | cut -d. -f1)
SIM_UDID=$(xcrun simctl list devices available -j | python3 -c '
import sys, json
major = sys.argv[1]
d = json.load(sys.stdin)
runtime_prefix = "iOS-" + major + "-"
for runtime_key, devices in d.get("devices", {}).items():
if runtime_prefix not in runtime_key:
continue
for dev in devices:
if dev.get("isAvailable", True) and "iPhone" in dev.get("name", ""):
print(dev["udid"])
sys.exit(0)
sys.exit(1)
' "$IOS_MAJOR")
if [ -z "$SIM_UDID" ]; then
echo "::error::No available iPhone simulator found for iOS $IOS_MAJOR"
exit 1
fi
printf 'destination=platform=iOS Simulator,id=%s\n' "$SIM_UDID" >> "$GITHUB_OUTPUT"
fi
- name: Run UI tests
id: xcodebuild
env:
CODE_COVERAGE: YES
DESTINATION: ${{ steps.resolve_destination.outputs.destination }}
PR_TEST: ${{ inputs.pr_test }}
TEST_SUITE: ${{ inputs.test_suite }}
# Xcode 15.3+ only forwards env vars prefixed with TEST_RUNNER_ to the test runner (prefix is stripped).
TEST_RUNNER_UI_TEST_SHORT_TIMEOUT: ${{ inputs.short_timeout }}
TEST_RUNNER_UI_TEST_LONG_TIMEOUT: ${{ inputs.long_timeout }}
run: |
ONLY_TESTING_ARGS=()
if [ -n "$PR_TEST" ]; then
ONLY_TESTING_ARGS+=(-only-testing "$PR_TEST")
elif [ -n "$TEST_SUITE" ]; then
ONLY_TESTING_ARGS+=(-only-testing "$TEST_SUITE")
fi
set -o pipefail
xcodebuild test \
-workspace SalesforceMobileSDK.xcworkspace \
-scheme AuthFlowTester \
-testPlan AuthFlowTester \
"${ONLY_TESTING_ARGS[@]}" \
-destination "$DESTINATION" \
-resultBundlePath test \
-enableCodeCoverage YES \
| xcbeautify
- name: Archive xcodebuild logs on build failure
if: failure() && steps.xcodebuild.outcome == 'failure'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: xcodebuild-logs-authflowtester-ui-ios${{ inputs.ios }}-${{ steps.result_suffix.outputs.suffix }}
path: |
~/Library/Developer/Xcode/DerivedData/**/Logs/Build/*.xcactivitylog
if-no-files-found: ignore
retention-days: 14
- name: Verify xcresult bundle exists
if: success() || failure()
run: |
if [ ! -d "test.xcresult" ]; then
echo "::error::test.xcresult bundle was not created"
exit 1
fi
echo "xcresult bundle exists and contains:"
ls -lh test.xcresult/
- name: Parse test results
if: success() || failure()
env:
IOS: ${{ inputs.ios }}
SUFFIX: ${{ steps.result_suffix.outputs.suffix }}
run: |
brew install xcresultparser
xcresultparser -o junit test.xcresult > "test-results-authflowtester-ui-ios${IOS}-${SUFFIX}.xml"
- name: Test Report
uses: mikepenz/action-junit-report@3585e9575db828022551b4231f165eb59a0e74e3 # v5.6.2
if: success() || failure()
with:
check_name: AuthFlowTester UI Test Results ${{ steps.result_suffix.outputs.suffix }}
job_name: AuthFlowTester UI Test Results ${{ steps.result_suffix.outputs.suffix }}
require_tests: true
include_empty_in_summary: false
simplified_summary: true
detailed_summary: true
comment: true
job_summary: true
report_paths: 'test-results-authflowtester-ui-ios${{ inputs.ios }}-${{ steps.result_suffix.outputs.suffix }}.xml'
check_retries: false
group_suite: true
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
if: success() || failure()
with:
flags: AuthFlowTesterUI
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload xcresult bundle
if: success() || failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: xcresult-authflowtester-ui-ios${{ inputs.ios }}-${{ steps.result_suffix.outputs.suffix }}
path: test.xcresult/
retention-days: 30