forked from juliansteenbakker/flutter_secure_storage
-
Notifications
You must be signed in to change notification settings - Fork 0
624 lines (514 loc) · 17.4 KB
/
ci.yml
File metadata and controls
624 lines (514 loc) · 17.4 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
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
name: CI
on:
push:
branches: [master, develop]
pull_request:
defaults:
run:
shell: bash
env:
PUB_ENVIRONMENT: bot.github
jobs:
analysis:
name: Analysis
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter Version Info
run: flutter doctor -v
- name: Cache Pub Dependencies
uses: actions/cache@v5
with:
path: |
~/.pub-cache
.dart_tool
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-pub-
- name: Install Melos
run: |
flutter pub global activate melos
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Bootstrap Workspace with Melos
run: melos bootstrap
- name: Lint Code
run: melos analyze
formatting:
name: Formatting
needs: analysis
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Cache Pub Dependencies
uses: actions/cache@v5
with:
path: |
~/.pub-cache
.dart_tool
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-pub-
- name: Install Melos
run: |
flutter pub global activate melos
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Bootstrap Workspace with Melos
run: melos bootstrap
- name: Check Code Formatting
run: melos format --output none --set-exit-if-changed
unit_tests:
name: Unit Tests
needs: formatting
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: flutter_secure_storage
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Cache Pub Dependencies
uses: actions/cache@v5
with:
path: |
~/.pub-cache
flutter_secure_storage/.dart_tool
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.os }}-pub-
- name: Install Dependencies
run: flutter pub get
- name: Run Unit Tests with Coverage
run: flutter test --coverage
- name: Upload Coverage Report
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: flutter_secure_storage/coverage/lcov.info
- name: Upload Flutter Coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: flutter_secure_storage/coverage/lcov.info
flags: flutter
name: codecov-flutter
fail_ci_if_error: true
unit_tests_android:
name: Android Unit Tests
needs: formatting
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up JDK 17
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: "17"
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Build Example App (generates native build files)
working-directory: flutter_secure_storage/example
run: flutter build apk --debug
- name: Run Android Unit Tests with Coverage
working-directory: flutter_secure_storage/example/android
run: ./gradlew :flutter_secure_storage:jacocoTestReport
- name: Upload Android Coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: flutter_secure_storage/android/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
flags: android
name: codecov-android
fail_ci_if_error: true
unit_tests_web:
name: Web Unit Tests
needs: formatting
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Dependencies
working-directory: flutter_secure_storage_web
run: flutter pub get
- name: Run Web Unit Tests
working-directory: flutter_secure_storage_web
run: flutter test --platform chrome
unit_tests_windows:
name: Windows Unit Tests
needs: formatting
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Dependencies
working-directory: flutter_secure_storage_windows
run: flutter pub get
- name: Run Windows Unit Tests with Coverage
working-directory: flutter_secure_storage_windows
run: flutter test --coverage
- name: Upload Windows Coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: flutter_secure_storage_windows/coverage/lcov.info
flags: windows
name: codecov-windows
fail_ci_if_error: true
native_tests_windows:
name: Windows Native Tests
needs: formatting
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Melos
shell: pwsh
run: |
flutter pub global activate melos
Add-Content $env:GITHUB_PATH "$env:PUB_CACHE\bin"
- name: Bootstrap Workspace with Melos
shell: pwsh
run: melos bootstrap
- name: Build Windows Example and Native Tests
working-directory: flutter_secure_storage/example
run: flutter build windows --debug
- name: Run Native Windows Tests
working-directory: flutter_secure_storage/example
shell: pwsh
run: |
ctest --test-dir build/windows/x64/plugins/flutter_secure_storage_windows `
--output-on-failure `
-C Debug
integration_tests_windows:
name: Windows Integration Tests
needs: [unit_tests, unit_tests_windows]
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Melos
shell: pwsh
run: |
flutter pub global activate melos
Add-Content $env:GITHUB_PATH "$env:PUB_CACHE\bin"
- name: Bootstrap Workspace with Melos
shell: pwsh
run: melos bootstrap
- name: Build Windows Example App
working-directory: flutter_secure_storage/example
run: flutter build windows --debug
- name: Run Windows Integration Tests
working-directory: flutter_secure_storage/example
run: flutter test integration_test/windows_test.dart -d windows
native_tests_linux:
name: Linux Native Tests
needs: formatting
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Linux Build Dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config \
libgtk-3-dev libblkid-dev liblzma-dev libsecret-1-dev \
gnome-keyring dbus-x11
- name: Install Melos
run: |
flutter pub global activate melos
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Bootstrap Workspace with Melos
run: melos bootstrap
- name: Build Linux Example and Native Tests
working-directory: flutter_secure_storage/example
run: flutter build linux --debug
- name: Start D-Bus Session and Unlock Keyring
run: |
eval $(dbus-launch --sh-syntax)
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> $GITHUB_ENV
echo "DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID" >> $GITHUB_ENV
echo "" | gnome-keyring-daemon --unlock --daemonize --components=secrets
- name: Run Native Linux Tests
working-directory: flutter_secure_storage/example/build/linux/x64/debug/plugins/flutter_secure_storage_linux
run: ctest --output-on-failure
integration_tests_linux:
name: Linux Integration Tests
needs: [unit_tests, native_tests_linux]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Linux Build Dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config \
libgtk-3-dev libblkid-dev liblzma-dev libsecret-1-dev \
gnome-keyring dbus-x11 xvfb
- name: Install Melos
run: |
flutter pub global activate melos
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Bootstrap Workspace with Melos
run: melos bootstrap
- name: Start D-Bus Session and Unlock Keyring
run: |
eval $(dbus-launch --sh-syntax)
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> $GITHUB_ENV
echo "DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID" >> $GITHUB_ENV
echo "" | gnome-keyring-daemon --unlock --daemonize --components=secrets
- name: Run Linux Integration Tests
working-directory: flutter_secure_storage/example
run: xvfb-run flutter test integration_test/linux_test.dart -d linux
integration_tests_android:
name: Android Tests
needs: [unit_tests, unit_tests_android]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
include:
- api-level: 23
target: default
arch: x86
flutter-version: "3.32.x"
- api-level: 24
target: default
arch: x86_64
flutter-version: ""
- api-level: 36
target: google_apis
arch: x86_64
flutter-version: ""
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Free Disk Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
df -h
- name: Set Up JDK 17
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: "17"
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.flutter-version || '' }}
channel: stable
cache: true
- name: Enable KVM
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
# - name: Cache Gradle
# uses: gradle/actions/setup-gradle@v5
- name: Cache AVD
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}
- name: Create AVD Snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run Integration Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: flutter test integration_test
working-directory: flutter_secure_storage/example
integration_tests_web:
name: Web Integration Tests
needs: [unit_tests, unit_tests_web]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Setup ChromeDriver
uses: nanasess/setup-chromedriver@v2
- name: Start ChromeDriver
run: chromedriver --port=4444 &
- name: Install Dependencies
working-directory: flutter_secure_storage/example
run: flutter pub get
- name: Run Web Integration Tests
working-directory: flutter_secure_storage/example
run: |
flutter drive \
--driver=test_driver/app_test_test.dart \
--target=integration_test/web_test.dart \
-d web-server
typecheck_swift_ios:
name: Swift iOS Typecheck
runs-on: macos-latest
timeout-minutes: 5
needs: [unit_tests, unit_tests_android]
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Typecheck Swift against iOS 12 minimum
run: |
swiftc -typecheck \
-target arm64-apple-ios12.0 \
-sdk "$(xcrun --sdk iphoneos --show-sdk-path)" \
flutter_secure_storage_darwin/darwin/flutter_secure_storage_darwin/Sources/flutter_secure_storage_darwin/FlutterSecureStorage.swift
- name: Typecheck Swift against latest iOS SDK
run: |
SDK_PATH="$(xcrun --sdk iphoneos --show-sdk-path)"
SDK_VERSION="$(xcrun --sdk iphoneos --show-sdk-version)"
swiftc -typecheck \
-target "arm64-apple-ios${SDK_VERSION}" \
-sdk "$SDK_PATH" \
flutter_secure_storage_darwin/darwin/flutter_secure_storage_darwin/Sources/flutter_secure_storage_darwin/FlutterSecureStorage.swift
native_tests_darwin:
name: Darwin Native Tests
runs-on: macos-latest
timeout-minutes: 20
needs: formatting
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Melos
run: flutter pub global activate melos
- name: Bootstrap Melos
run: melos bootstrap
- name: Configure macOS Project
working-directory: flutter_secure_storage/example
run: flutter build macos --config-only --no-pub
- name: Run Darwin Native Tests
working-directory: flutter_secure_storage/example/macos
run: |
xcodebuild test \
-workspace Runner.xcworkspace \
-scheme Runner \
-destination 'platform=macOS' \
-only-testing RunnerTests \
CODE_SIGNING_ALLOWED=NO
integration_tests_ios:
name: iOS Tests
runs-on: macos-latest
timeout-minutes: 30
needs: [typecheck_swift_ios]
env:
SIM_OS: iOS
SIM_OS_VERSION: "26.2"
SIM_DEVICE: "iPhone 17"
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Set Up Simulator
id: simulator
uses: futureware-tech/simulator-action@v5
with:
os: ${{ env.SIM_OS }}
os_version: ${{ env.SIM_OS_VERSION }}
model: ${{ env.SIM_DEVICE }}
erase_before_boot: true
wait_for_boot: true
boot_timeout_seconds: 300
boot_retries: 3
- name: Install Dependencies
working-directory: flutter_secure_storage/example
run: flutter pub get
- name: Run Integration Tests
uses: nick-fields/retry@v4
env:
DEVICE_ID: ${{ steps.simulator.outputs.udid }}
with:
timeout_minutes: 5
max_attempts: 3
command: cd flutter_secure_storage/example && flutter test integration_test/app_test.dart -d "$DEVICE_ID" --verbose --dart-define=IS_SIMULATOR=true