-
Notifications
You must be signed in to change notification settings - Fork 324
82 lines (80 loc) · 3.2 KB
/
unit-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
name: Unit Tests
on:
workflow_call:
inputs:
ios-version:
required: true
type: string
macos-runner:
required: true
type: string
jobs:
unit-tests:
name: "${{ matrix.run-config['name'] }} on ${{ inputs.macos-runner }}"
runs-on: ${{ inputs.macos-runner }}
strategy:
matrix:
run-config:
- {
name: "macOS",
condition: true,
clean-destination: "generic/platform=macOS",
test-destination: "platform=macOS,arch=arm64",
}
- {
name: "iOS",
condition: true,
clean-destination: "generic/platform=iOS",
test-destination: "platform=iOS Simulator,OS=${{ inputs.ios-version }},name=iPhone 16",
}
- {
name: "watchOS",
condition: "${{ inputs.macos-runner == 'macos-15' }}",
clean-destination: "generic/platform=watchOS",
test-destination: "platform=watchOS Simulator,OS=11.1,name=Apple Watch Ultra 2 (49mm)",
}
- {
name: "visionOS",
condition: "${{ inputs.macos-runner == 'macos-15' }}",
clean-destination: "generic/platform=visionOS",
test-destination: "platform=visionOS Simulator,name=Apple Vision Pro",
}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Setup environment
run: make setup
- name: Setup Cache
id: model-cache
uses: actions/cache@v4
with:
path: Models
key: ${{ runner.os }}-models
- name: Download Models
if: steps.model-cache.outputs.cache-hit != 'true'
run: make download-model MODEL=tiny
- name: Install and discover destinations
run: |
if [[ "${{ matrix.run-config['name'] }}" != "macOS" ]]; then
xcodebuild -downloadPlatform ${{ matrix.run-config['name'] }}
fi
echo "Destinations for testing:"
xcodebuild test-without-building -only-testing WhisperKitTests/UnitTests -scheme whisperkit-Package -showdestinations
- name: Boot Simulator and Wait
if: ${{ matrix.run-config['name'] != 'macOS' }} && ${{ inputs.macos-runner == 'macos-15' }}
# Slower runners require some time to fully boot the simulator
# Parse the simulator name from the destination string, boot it, and wait
run: |
simulator_name=$(echo '${{ matrix.run-config['test-destination'] }}' | sed -n 's/.*name=\([^,]*\).*/\1/p')
xcrun simctl boot "$simulator_name" || true
sleep 15
xcrun simctl list devices
- name: Build and Test - ${{ matrix.run-config['name'] }}
if: ${{ matrix.run-config['condition'] == true }}
run: |
set -o pipefail
xcodebuild clean build-for-testing -scheme whisperkit-Package -destination '${{ matrix.run-config['clean-destination'] }}' | xcpretty
xcodebuild test -only-testing WhisperKitTests/UnitTests -scheme whisperkit-Package -destination '${{ matrix.run-config['test-destination'] }}'