forked from simonbs/Runestone
-
Notifications
You must be signed in to change notification settings - Fork 3
157 lines (157 loc) · 6.66 KB
/
ui_tests.yml
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
# ---
# This workflow is disabled because multi-stage input, which is used when writing text
# in languages like Korean and Chinese, is broken in the iOS 16 and iOS 17 simulators.
# However, it still works on the device. Multi-stage text input does work in the
# iOS 15 simulator, which is used in this workflow.
#
# The iOS 15 simulators are not installed on GitHub's macOS 13 and macOS 14 runners,
# but they are installed in GitHub's macOS 12 runners. However, the iOS 15 simulators
# are only available in Xcode 13.4.1 on those runners, and Xcode 14.3.1 cannot be used
# to build this project as the tree-sitter dependency uses Swift tools version 5.8,
# which is not supported by Xcode 13.4.1. In fact, the most recent version installed on
# the macOS 12 runners is Xcode 14.3, which does not support Swift tools version 5.8 either.
# ---
name: UI Tests
on:
workflow_dispatch: {}
pull_request:
branches:
- main
paths:
- '.github/workflows/ui_tests.yml'
- 'Sources/**'
- '!Sources/Runestone/Documentation.docc/**'
- 'UITests/HostUITests/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app/Contents/Developer
jobs:
run_korean_tests:
name: Run Korean tests
runs-on: macos-13
env:
SIMULATOR_NAME: UI Test (Korean)
SCHEME: Host
PROJECT_PATH: UITests/UITests.xcodeproj
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Disable "Use the Same Keyboard Language as macOS"
run: defaults write com.apple.iphonesimulator EnableKeyboardSync -bool NO
- name: Create Simulator
run: xcrun simctl create "${SIMULATOR_NAME}" "iPhone 13" "iOS15.5"
- name: Find Simulator UDID
run: |
TMP_SIMULATOR_UDID=`xcrun simctl list --json devices | jq -r ".devices | flatten | .[] | select(.name == \"${SIMULATOR_NAME}\").udid"`
echo "SIMULATOR_UDID=$(echo $TMP_SIMULATOR_UDID)" >> $GITHUB_ENV
- name: Modify .GlobalPreferences.plist
run: >
find ~/Library/Developer/CoreSimulator/Devices/$SIMULATOR_UDID -type d -maxdepth 0\
-exec /usr/libexec/PlistBuddy\
-c "Add :AppleKeyboardsExpanded integer 1"\
-c "Delete :AppleLanguages"\
-c "Add :AppleLanguages array"\
-c "Add :AppleLanguages:0 string en-US"\
-c "Delete :AppleKeyboards"\
-c "Add :AppleKeyboards array"\
-c "Add :AppleKeyboards:0 string ko_KR@Sw=Korean;hw=Automatic"\
{}/data/Library/Preferences/.GlobalPreferences.plist \;
- name: Disable "Connect Hardware Keyboard" in the simulator.
run: >
find ~/Library/Preferences/com.apple.iphonesimulator.plist\
-exec /usr/libexec/PlistBuddy\
-c "Add :DevicePreferences dict"\
-c "Add :DevicePreferences:${SIMULATOR_UDID} dict"\
-c "Add :DevicePreferences:${SIMULATOR_UDID}:ConnectHardwareKeyboard bool false"\
{} \;
- name: Build
run: >
xcodebuild build-for-testing\
-project $PROJECT_PATH\
-scheme $SCHEME\
-sdk iphonesimulator\
-destination "platform=iOS Simulator,id=${SIMULATOR_UDID}"
- name: Run Tests
run: >
xcodebuild test-without-building\
-only-testing:HostUITests/KoreanInputTests\
-project $PROJECT_PATH\
-scheme $SCHEME\
-sdk iphonesimulator\
-destination "platform=iOS Simulator,id=${SIMULATOR_UDID}"
- name: Remove Simulator Preferences
run: >
find ~/Library/Preferences/com.apple.iphonesimulator.plist\
-exec /usr/libexec/PlistBuddy\
-c "Delete :DevicePreferences:${SIMULATOR_UDID}"\
{} \;
- name: Delete Simulator
if: always()
run: xcrun simctl delete $SIMULATOR_UDID
run_chinese_tests:
name: Run Chinese tests
runs-on: macos-13
env:
SIMULATOR_NAME: UI Test (Chinese)
SCHEME: Host
PROJECT_PATH: UITests/UITests.xcodeproj
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Disable "Use the Same Keyboard Language as macOS"
run: defaults write com.apple.iphonesimulator EnableKeyboardSync -bool NO
- name: Create Simulator
run: xcrun simctl create "${SIMULATOR_NAME}" "iPhone 13" "iOS15.5"
- name: Find Simulator UDID
run: |
TMP_SIMULATOR_UDID=`xcrun simctl list --json devices | jq -r ".devices | flatten | .[] | select(.name == \"${SIMULATOR_NAME}\").udid"`
echo "SIMULATOR_UDID=$(echo $TMP_SIMULATOR_UDID)" >> $GITHUB_ENV
- name: Modify .GlobalPreferences.plist
run: >
find ~/Library/Developer/CoreSimulator/Devices/$SIMULATOR_UDID -type d -maxdepth 0\
-exec /usr/libexec/PlistBuddy\
-c "Add :AppleKeyboardsExpanded integer 1"\
-c "Delete :AppleLanguages"\
-c "Add :AppleLanguages array"\
-c "Add :AppleLanguages:0 string en-US"\
-c "Delete :AppleKeyboards"\
-c "Add :AppleKeyboards array"\
-c "Add :AppleKeyboards:0 string zh_Hant-Sucheng@sw=Sucheng;hw=Automatic"\
{}/data/Library/Preferences/.GlobalPreferences.plist \;
- name: Disable "Connect Hardware Keyboard" in the simulator.
run: >
find ~/Library/Preferences/com.apple.iphonesimulator.plist\
-exec /usr/libexec/PlistBuddy\
-c "Add :DevicePreferences dict"\
-c "Add :DevicePreferences:${SIMULATOR_UDID} dict"\
-c "Add :DevicePreferences:${SIMULATOR_UDID}:ConnectHardwareKeyboard bool false"\
{} \;
- name: Build
run: >
xcodebuild build-for-testing -project\
$PROJECT_PATH -scheme $SCHEME\
-sdk iphonesimulator\
-destination "platform=iOS Simulator,id=${SIMULATOR_UDID}"
- name: Run Tests
run: >
xcodebuild test-without-building\
-only-testing:HostUITests/ChineseInputTests\
-project $PROJECT_PATH\
-scheme $SCHEME\
-sdk iphonesimulator\
-destination "platform=iOS Simulator,id=${SIMULATOR_UDID}"
- name: Remove Simulator Preferences
run: >
find ~/Library/Preferences/com.apple.iphonesimulator.plist\
-exec /usr/libexec/PlistBuddy\
-c "Delete :DevicePreferences:${SIMULATOR_UDID}"\
{} \;
- name: Delete Simulator
if: always()
run: xcrun simctl delete $SIMULATOR_UDID