-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
178 lines (162 loc) · 6.36 KB
/
test-e2e.yml
File metadata and controls
178 lines (162 loc) · 6.36 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
name: E2E test with video recording
on:
workflow_dispatch:
inputs:
ref:
description: Branch or SHA to test
required: false
default: ""
test_filter:
description: "Test class or class/method (e.g. TerminalHomeUITests or TerminalReconnectUITests/testDirectDaemonReconnectShowsProgressAndRecovers)"
required: true
test_timeout:
description: "Per-test timeout in seconds"
required: false
default: "120"
record_video:
description: Record the simulator during tests
required: false
default: true
type: boolean
runner:
description: "Runner OS (macos-26 or macos-15)"
required: false
default: "macos-26"
type: choice
options:
- macos-26
- macos-15
push:
branches:
- task-move-ios-app-into-cmux-repo
jobs:
e2e:
runs-on: ${{ inputs.runner || 'macos-26' }}
timeout-minutes: 45
env:
TEST_REF: ${{ inputs.ref || github.ref }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ inputs.ref || github.ref }}
submodules: recursive
- name: Select Xcode
run: |
set -euo pipefail
if [ -d "/Applications/Xcode.app/Contents/Developer" ]; then
XCODE_DIR="/Applications/Xcode.app/Contents/Developer"
else
XCODE_APP="$(ls -d /Applications/Xcode*.app 2>/dev/null | head -n 1 || true)"
if [ -n "$XCODE_APP" ]; then
XCODE_DIR="$XCODE_APP/Contents/Developer"
else
echo "No Xcode.app found under /Applications" >&2
exit 1
fi
fi
echo "DEVELOPER_DIR=$XCODE_DIR" >> "$GITHUB_ENV"
export DEVELOPER_DIR="$XCODE_DIR"
xcodebuild -version
xcrun simctl list runtimes
- name: Install build tools
run: |
set -euo pipefail
brew install zig xcodegen
- name: Cache Swift packages
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ios/.ci-source-packages
key: ios-spm-${{ inputs.runner || 'macos-26' }}-${{ hashFiles('ios/Package.resolved', 'Package.resolved', 'Packages/CMUXAuthCore/Package.swift') }}
restore-keys: ios-spm-${{ inputs.runner || 'macos-26' }}-
- name: Build and link GhosttyKit.xcframework
run: ./scripts/setup.sh
- name: Generate iOS project
working-directory: ios
run: xcodegen generate
- name: Resolve Swift packages
working-directory: ios
run: |
set -euo pipefail
mkdir -p .ci-source-packages
xcodebuild -project cmux.xcodeproj -scheme cmux \
-clonedSourcePackagesDirPath "$PWD/.ci-source-packages" \
-resolvePackageDependencies
- name: Pick simulator
id: simulator
run: |
set -euo pipefail
SIMULATOR_ID="$(xcrun simctl list devices available | grep 'iPhone 17 Pro (' | head -1 | grep -oE '[A-F0-9-]{36}' || true)"
if [ -z "$SIMULATOR_ID" ]; then
SIMULATOR_ID="$(xcrun simctl list devices available | grep 'iPhone' | head -1 | grep -oE '[A-F0-9-]{36}' || true)"
fi
if [ -z "$SIMULATOR_ID" ]; then
echo "No available iPhone simulator found" >&2
exit 1
fi
echo "id=$SIMULATOR_ID" >> "$GITHUB_OUTPUT"
xcrun simctl boot "$SIMULATOR_ID" || true
xcrun simctl bootstatus "$SIMULATOR_ID" -b
open -a Simulator --args -CurrentDeviceUDID "$SIMULATOR_ID"
- name: Start simulator recording
if: ${{ inputs.record_video }}
run: |
set -euo pipefail
VIDEO_PATH="$RUNNER_TEMP/cmux-ios-e2e.mp4"
xcrun simctl io "${{ steps.simulator.outputs.id }}" recordVideo "$VIDEO_PATH" >/tmp/cmux-ios-record.log 2>&1 &
echo "CMUX_IOS_RECORD_PID=$!" >> "$GITHUB_ENV"
echo "CMUX_IOS_VIDEO_PATH=$VIDEO_PATH" >> "$GITHUB_ENV"
sleep 2
- name: Run iOS UI test
working-directory: ios
env:
TEST_FILTER: ${{ inputs.test_filter }}
TEST_TIMEOUT: ${{ inputs.test_timeout || '120' }}
run: |
set -euo pipefail
DERIVED_DATA="$RUNNER_TEMP/cmux-ios-e2e"
RESULT_BUNDLE="$RUNNER_TEMP/cmux-ios-e2e.xcresult"
rm -rf "$DERIVED_DATA" "$RESULT_BUNDLE"
if [ "${{ github.event_name }}" = "push" ]; then
TEST_FILTERS=("TerminalHomeUITests" "TerminalHostEditorUITests" "TerminalInboxUITests" "TerminalInputUITests" "TerminalReconnectUITests" "AuthPersistenceUITests")
else
TEST_FILTERS=("$TEST_FILTER")
fi
for FILTER in "${TEST_FILTERS[@]}"; do
echo "Running cmuxUITests/$FILTER"
xcodebuild test \
-project cmux.xcodeproj \
-scheme cmux \
-configuration Debug \
-destination "id=${{ steps.simulator.outputs.id }}" \
-derivedDataPath "$DERIVED_DATA" \
-resultBundlePath "$RESULT_BUNDLE" \
-clonedSourcePackagesDirPath "$PWD/.ci-source-packages" \
-disableAutomaticPackageResolution \
-maximum-test-execution-time-allowance "$TEST_TIMEOUT" \
-only-testing:cmuxUITests/"$FILTER"
done
- name: Stop simulator recording
if: ${{ always() && inputs.record_video && env.CMUX_IOS_RECORD_PID != '' }}
run: |
set +e
kill -INT "$CMUX_IOS_RECORD_PID"
wait "$CMUX_IOS_RECORD_PID"
exit 0
- name: Upload xcresult
if: ${{ always() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: cmux-ios-e2e-xcresult
path: ${{ runner.temp }}/cmux-ios-e2e.xcresult
if-no-files-found: warn
- name: Upload simulator recording
if: ${{ always() && inputs.record_video }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: cmux-ios-e2e-video
path: ${{ env.CMUX_IOS_VIDEO_PATH }}
if-no-files-found: warn
- name: Shutdown simulator
if: ${{ always() }}
run: xcrun simctl shutdown "${{ steps.simulator.outputs.id }}" || true