-
Notifications
You must be signed in to change notification settings - Fork 0
266 lines (225 loc) · 8.39 KB
/
ci.yml
File metadata and controls
266 lines (225 loc) · 8.39 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Verify the library compiles and analyzes on the minimum supported Flutter.
# Dev dependencies (lints, test helpers) may require a newer SDK, so this
# job resolves only production dependencies and runs analysis without tests.
compat-check:
name: Compatibility Check (Flutter 3.38.0)
runs-on: macos-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
# Pinned to commit SHA for supply chain security — update hash when upgrading.
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
flutter-version: '3.38.0'
cache: true
- name: Resolve dependencies
run: flutter pub get
- name: Analyze library code
run: dart analyze --fatal-infos lib
- name: Run unit tests (excluding golden tests)
run: flutter test --exclude-tags=golden
build:
name: Build & Unit Tests
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
# Pinned to commit SHA for supply chain security — update hash when upgrading.
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
flutter-version: '3.41.2'
cache: true
- name: Install dependencies
run: flutter pub get
- name: Check formatting
run: |
dart format --language-version=latest .
if [ -n "$(git diff --name-only)" ]; then
echo "::error::The following files need formatting:"
git diff --name-only
echo ""
git diff
exit 1
fi
- name: Analyze
run: dart analyze --fatal-infos
- name: Run unit tests with coverage
run: flutter test --coverage
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/lcov.info
test-ios:
name: Integration Tests (iOS Simulator)
needs: [compat-check, build]
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
# Pinned to commit SHA for supply chain security — update hash when upgrading.
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
flutter-version: '3.41.2'
cache: true
- name: Install dependencies
run: flutter pub get
working-directory: example
- name: Boot iOS simulator
run: |
DEVICE_ID=$(xcrun simctl list devices available -j | \
python3 -c "
import json, sys
data = json.load(sys.stdin)
for runtime, devices in data['devices'].items():
if 'iOS' in runtime:
for d in devices:
if 'iPhone' in d['name'] and d['isAvailable']:
print(d['udid'])
sys.exit(0)
sys.exit(1)
")
echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV
xcrun simctl boot "$DEVICE_ID" 2>/dev/null || true
# Wait for simulator to be fully ready
xcrun simctl bootstatus "$DEVICE_ID" -b
# Verify the simulator is visible to Flutter
flutter devices
- name: Pre-build for iOS simulator
run: flutter build ios --simulator --target=integration_test/run_all_test.dart
working-directory: example
- name: Run integration tests on iOS
run: |
flutter test integration_test/run_all_test.dart \
--timeout 20m \
--ignore-timeouts \
--dart-define=MIXPANEL_TOKEN="${{ secrets.MIXPANEL_TOKEN }}" \
-d "$DEVICE_ID"
working-directory: example
test-android:
name: Integration Tests (Android API ${{ matrix.api-level }})
needs: [compat-check, build]
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- api-level: 24
target: default
arch: x86_64
profile: Nexus 6
name: "Android 7.0 (Nougat)"
- api-level: 34
target: google_apis
arch: x86_64
profile: pixel_6
name: "Android 14 (Latest)"
steps:
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/share/swift
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo apt-get clean
- 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
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
# Pinned to commit SHA for supply chain security — update hash when upgrading.
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
flutter-version: '3.41.2'
cache: true
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Install dependencies
run: flutter pub get
working-directory: example
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.profile }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@5d6e86df22ab11632167a1a6b0c9ab0dc3469586 # v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
profile: ${{ matrix.profile }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -accel on
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run integration tests on Android
uses: reactivecircus/android-emulator-runner@5d6e86df22ab11632167a1a6b0c9ab0dc3469586 # v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
profile: ${{ matrix.profile }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -accel on
disable-animations: true
working-directory: example
script: |
flutter devices
flutter build apk --target=integration_test/run_all_test.dart
flutter test integration_test/run_all_test.dart --timeout 20m --ignore-timeouts --dart-define=MIXPANEL_TOKEN="${{ secrets.MIXPANEL_TOKEN }}"
test-macos:
name: Integration Tests (macOS Desktop)
needs: [compat-check, build]
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
# Pinned to commit SHA for supply chain security — update hash when upgrading.
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
flutter-version: '3.41.2'
cache: true
- name: Install dependencies
run: flutter pub get
working-directory: example
- name: Pre-build for macOS
run: flutter build macos --target=integration_test/run_all_test.dart
working-directory: example
- name: Run integration tests on macOS
run: |
flutter test integration_test/run_all_test.dart \
--timeout 20m \
--ignore-timeouts \
--dart-define=MIXPANEL_TOKEN="${{ secrets.MIXPANEL_TOKEN }}" \
-d macos
working-directory: example