-
Notifications
You must be signed in to change notification settings - Fork 853
402 lines (378 loc) · 16.1 KB
/
test.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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
name: test
on:
workflow_dispatch:
inputs:
flutter_version:
description: 'Flutter Version'
required: false
default: 'any'
type: choice
options:
- 'any'
- '3.24.x'
- '3.22.x'
flutter_channel:
description: 'Flutter Channel'
required: false
default: 'stable'
type: choice
options:
- 'stable'
- 'beta'
- 'dev'
- 'master'
fatal_warnings:
description: 'Treat warnings as fatal'
required: false
default: true
type: boolean
enable_android:
description: 'Test Android'
required: false
default: true
type: boolean
enable_web:
description: 'Test Web'
required: false
default: true
type: boolean
enable_ios:
description: 'Test IOS'
required: false
default: true
type: boolean
enable_windows:
description: 'Test Windows'
required: false
default: true
type: boolean
enable_linux:
description: 'Test Linux'
required: false
default: true
type: boolean
enable_macos:
description: 'Test MacOS'
required: false
default: true
type: boolean
workflow_call:
inputs:
flutter_version:
required: false
default: '3.24.5'
type: string
flutter_channel:
required: false
default: 'stable'
type: string
fatal_warnings:
required: false
default: true
type: boolean
enable_android:
required: false
default: true
type: boolean
enable_web:
required: false
default: true
type: boolean
enable_ios:
required: false
default: true
type: boolean
enable_windows:
required: false
default: true
type: boolean
enable_linux:
required: false
default: true
type: boolean
enable_macos:
required: false
default: true
type: boolean
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
# Full git history needed for `super-linter`
fetch-depth: 0
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- run: melos format --set-exit-if-changed
- run: melos analyze ${{ inputs.fatal_warnings && '--fatal-infos' || '--no-fatal-warnings' }}
- run: melos run test
- name: Lint Code Base
uses: super-linter/super-linter/slim@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
VALIDATE_KOTLIN_ANDROID: true
VALIDATE_CLANG_FORMAT: true
- name: Lint Swift
# TODO: check if swift-format can be integrated in super-linter, as soon as Alpine is supported
# https://github.com/apple/swift-docker/issues/231
# https://github.com/super-linter/super-linter/pull/4568
run: |
docker run --rm --workdir=/work --volume=$PWD:/work mtgto/swift-format:5.8 \
lint --parallel --strict --recursive packages/audioplayers_darwin
web:
runs-on: ubuntu-latest
timeout-minutes: 30
if: inputs.enable_web
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- uses: nanasess/setup-chromedriver@v2
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
chromedriver --port=4444 &
( cd server; dart run bin/server.dart ) &
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/platform_test.dart \
-d web-server \
--web-browser-flag="--autoplay-policy=no-user-gesture-required" \
--web-browser-flag="--disable-web-security" \
--dart-define USE_LOCAL_SERVER=true
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/lib_test.dart \
-d web-server \
--web-browser-flag="--autoplay-policy=no-user-gesture-required" \
--web-browser-flag="--disable-web-security" \
--dart-define USE_LOCAL_SERVER=true
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d web-server \
--web-browser-flag="--autoplay-policy=no-user-gesture-required" \
--web-browser-flag="--disable-web-security" \
--dart-define USE_LOCAL_SERVER=true
android:
runs-on: ubuntu-latest
timeout-minutes: 90
if: inputs.enable_android
steps:
- uses: actions/checkout@v4
- name: Enable KVM group perms
# see: https://github.com/actions/runner-images/discussions/7191
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- uses: actions/setup-java@v4
with:
# AGP8 needs JDK 17
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- name: Download Android emulator image
run: |
export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
echo "y" | $ANDROID_TOOLS/sdkmanager --install "system-images;android-30;aosp_atd;x86"
echo "no" | $ANDROID_TOOLS/avdmanager create avd --force --name emu --device "Nexus 5X" -k 'system-images;android-30;aosp_atd;x86'
$ANDROID_HOME/emulator/emulator -list-avds
- name: Start Android emulator
timeout-minutes: 10
run: |
export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
echo "Starting emulator"
$ANDROID_TOOLS/sdkmanager "platform-tools" "platforms;android-30"
nohup $ANDROID_HOME/emulator/emulator -avd emu -no-audio -no-snapshot -no-window &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
$ANDROID_HOME/platform-tools/adb devices
echo "Emulator started"
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
# Need to execute lib and app tests one by one, see: https://github.com/flutter/flutter/issues/101031
run: |
( cd server; dart run bin/server.dart ) &
flutter test integration_test/platform_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test integration_test/app_test.dart --dart-define USE_LOCAL_SERVER=true
- name: Run Android unit tests
working-directory: ./packages/audioplayers/example/android
run: ./gradlew test
ios-16:
# Run lib tests only to ensure compatibility with iOS 16.
runs-on: macos-13
timeout-minutes: 60
if: inputs.enable_ios
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: |
sudo xcode-select -switch /Applications/Xcode_14.3.1.app/Contents/Developer
UDID=$(xcrun simctl create test-se-16-4 com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation com.apple.CoreSimulator.SimRuntime.iOS-16-4)
xcrun simctl list devices
echo "Using simulator $UDID"
xcrun simctl boot "${UDID:?No Simulator with this name iPhone found}"
sudo xcode-select -switch /Applications/Xcode_15.2.app/Contents/Developer
( cd server; dart run bin/server.dart ) &
flutter test -d $UDID integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
ios-17:
runs-on: macos-14
timeout-minutes: 60
if: inputs.enable_ios
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@main
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
# Need to execute lib and app tests one by one, see: https://github.com/flutter/flutter/issues/101031
run: |
UDID=$(xcrun simctl create test-se-17-2 com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation com.apple.CoreSimulator.SimRuntime.iOS-17-2)
xcrun simctl list devices
echo "Using simulator $UDID"
xcrun simctl boot "${UDID:?No Simulator with this name iPhone found}"
( cd server; dart run bin/server.dart ) &
flutter test -d $UDID integration_test/platform_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d $UDID integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d $UDID integration_test/app_test.dart --dart-define USE_LOCAL_SERVER=true
macos-13:
# TODO: Run lib tests only to ensure compatibility with macOS 13, once tests for macOS 14 succeed.
runs-on: macos-13
timeout-minutes: 30
if: inputs.enable_macos
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@main
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
# Need to execute lib and app tests one by one, see: https://github.com/flutter/flutter/issues/101031
run: |
( cd server; dart run bin/server.dart ) &
flutter test -d macos integration_test/platform_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d macos integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
# TODO: Integration tests on macOS 13 currently time out.
# flutter test -d macos integration_test/app_test.dart --dart-define USE_LOCAL_SERVER=true
macos-14:
runs-on: macos-14
timeout-minutes: 30
if: false # TODO: Tests on macOS 14 currently fail.
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
# Need to execute lib and app tests one by one, see: https://github.com/flutter/flutter/issues/101031
run: |
( cd server; dart run bin/server.dart ) &
flutter test -d macos integration_test/platform_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d macos integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d macos integration_test/app_test.dart --dart-define USE_LOCAL_SERVER=true
windows:
runs-on: windows-latest
timeout-minutes: 30
if: inputs.enable_windows
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- name: Start audio server
run: net start audiosrv
- name: Download virtual audio device
# Download has to be done before setting the system date time.
timeout-minutes: 1
run: |
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/4.0/Scream4.0.zip -OutFile Scream.zip
Expand-Archive -Path Scream.zip -DestinationPath Scream
- name: Disable time sync with Hyper-V & setting system date time (#1573)
# TODO(gustl22): Remove workaround of setting the time when virtual audio device certificate is valid again (#1573)
run: |
Set-Service -Name vmictimesync -Status stopped -StartupType disabled
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Parameters -Name 'Type' -Value 'NoSync'
net stop w32time; Set-Date (Get-Date "2023-07-04 12:00:00")
- name: Install virtual audio device
timeout-minutes: 1
run: |
Import-Certificate -FilePath Scream\Install\driver\x64\Scream.cat -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
- name: Resetting system date time (#1573)
run: |
Set-Service -Name vmictimesync -Status running -StartupType automatic
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Parameters -Name 'Type' -Value 'NTP'
net start w32time; w32tm /resync /force; $currentDate = Get-Date; Write-Host "Current System Date: $currentDate";
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
shell: bash # Needed in order to fail fast, see: https://github.com/actions/runner-images/issues/6668
# Need to execute lib and app tests one by one, see: https://github.com/flutter/flutter/issues/101031
run: |
( cd server; dart run bin/server.dart ) &
flutter test -d windows integration_test/platform_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d windows integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d windows integration_test/app_test.dart --dart-define USE_LOCAL_SERVER=true
linux:
runs-on: ubuntu-latest
timeout-minutes: 30
if: inputs.enable_linux
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: ${{ inputs.flutter_channel }}
- uses: bluefireteam/melos-action@v3
- name: Install Flutter requirements for Linux
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
- name: Install GStreamer
# Install libunwind-dev, see https://github.com/actions/runner-images/issues/6399#issuecomment-1285011525
run: |
sudo apt install -y libunwind-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
# Need to execute lib and app tests one by one, see: https://github.com/flutter/flutter/issues/101031
# TODO(gustl22): Linux tests are flaky with LIVE_MODE=false
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
( cd server; LIVE_MODE=true dart run bin/server.dart ) &
flutter test -d linux integration_test/platform_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d linux integration_test/lib_test.dart --dart-define USE_LOCAL_SERVER=true
flutter test -d linux integration_test/app_test.dart --dart-define USE_LOCAL_SERVER=true