forked from juliansteenbakker/flutter_secure_storage
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (133 loc) · 4.44 KB
/
code-integration.yml
File metadata and controls
147 lines (133 loc) · 4.44 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
name: 📱 Code Integration
on:
push:
branches: [master, develop]
pull_request:
env:
PUB_ENVIRONMENT: bot.github
defaults:
run:
shell: bash
jobs:
# Android Integration Tests
integration_tests_android:
name: 🤖 Android Tests
runs-on: ubuntu-latest
strategy:
matrix:
include:
- api-level: 24
target: default
- api-level: 36
target: google_apis
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
- uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: "17"
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Melos
run: flutter pub global activate melos
- 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: Gradle cache
# uses: gradle/actions/setup-gradle@v5
- name: AVD cache
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
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 test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
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
# iOS Integration Tests
integration_tests_ios:
name: 🍏 iOS Tests
runs-on: macos-latest
timeout-minutes: 30
needs: integration_tests_android
env:
SIM_OS: iOS
SIM_OS_VERSION: "18.5"
SIM_DEVICE: "iPhone 16"
steps:
- uses: actions/checkout@v6
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Melos
run: flutter pub global activate melos
- name: Reset Simulator State
run: |
xcrun simctl shutdown all || true
xcrun simctl erase all || true
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService || true
sudo killall -9 Simulator || true
sleep 2
- uses: futureware-tech/simulator-action@v4
with:
os: ${{ env.SIM_OS }}
os_version: ${{ env.SIM_OS_VERSION }}
model: ${{ env.SIM_DEVICE }}
erase_before_boot: true
wait_for_boot: true
- name: Wait for Boot
run: |
DEVICE_ID=$(xcrun simctl list devices | grep "${SIM_DEVICE}" | grep Booted | awk -F '[()]' '{print $2}')
for i in {1..30}; do
booted=$(xcrun simctl list devices | grep "$DEVICE_ID" | grep -c Booted || true)
if [ "$booted" = "1" ]; then
echo "Simulator booted: $DEVICE_ID"
exit 0
fi
echo "Waiting for boot… ($i/30)"
sleep 2
done
echo "Simulator boot timeout"
exit 1
- run: flutter pub get
working-directory: flutter_secure_storage/example
- name: Execute Integration Tests
working-directory: flutter_secure_storage/example
run: |
DEVICE_ID=$(xcrun simctl list devices | grep "${SIM_DEVICE}" | grep Booted | awk -F '[()]' '{print $2}')
flutter drive \
--target=integration_test/app_test.dart \
-d "$DEVICE_ID"