-
Notifications
You must be signed in to change notification settings - Fork 6
307 lines (281 loc) · 10.6 KB
/
embrace.yaml
File metadata and controls
307 lines (281 loc) · 10.6 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
name: embrace
env:
ANDROID_API_LEVEL: 34
on:
pull_request:
paths:
- ".github/workflows/embrace.yaml"
- "embrace/**"
- "embrace_android/**"
- "embrace_ios/**"
- "embrace_platform_interface/**"
- "embrace_dio/**"
push:
branches:
- master
paths:
- ".github/workflows/embrace.yaml"
- "embrace/**"
- "embrace_android/**"
- "embrace_ios/**"
- "embrace_platform_interface/**"
- "embrace_dio/**"
permissions:
contents: read
jobs:
# Build with minimum supported Flutter/Dart versions
build_minimum:
uses: ./.github/workflows/flutter_ci.yaml
with:
flutter_channel: stable
flutter_version: '3.38.5'
working_directory: embrace
# Run tests on minimum supported version
test_minimum:
runs-on: ubuntu-latest
defaults:
run:
working-directory: embrace
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
flutter-version: '3.38.5'
- name: Flutter Doctor
run: flutter doctor -v
- name: Tests for minimum version
run: flutter test
# Run tests on latest stable Flutter/Dart
test_release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: embrace
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
flutter-version: '3.38.5'
cache: true
- name: Flutter Doctor
run: flutter doctor -v
- name: Tests for release mode
run: flutter test --dart-define=dart.vm.product=true test_release/
android:
name: Android (Flutter emulator, Ubuntu + KVM)
runs-on: ubuntu-latest
timeout-minutes: 45
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 60
defaults:
run:
working-directory: embrace/example
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
tool-cache: false
android: false
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
# Enable hardware accel for the x86_64 emulator
- name: Enable KVM group perms
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: Setup Java 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
- name: Setup Flutter (stable)
uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
with:
channel: stable
cache: true
flutter-version: '3.38.5'
- name: Flutter pub get
run: flutter pub get
- name: Accept Android SDK licenses
run: yes | "${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" --licenses || true
- name: Write Embrace config (from secrets)
working-directory: embrace/example
run: |
mkdir -p android/app/src/main
cat > android/app/src/main/embrace-config.json <<'JSON'
{
"app_id": "${{ secrets.FLUTTER_TEST_ANDROID_APP_ID }}",
"api_token": "${{ secrets.FLUTTER_TEST_ANDROID_API_TOKEN }}",
"ndk_enabled": true,
"sdk_config": { "app_framework": "flutter" }
}
JSON
# Cache the AVD (x86_64 + API 34); change API here if needed
- name: AVD cache
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ runner.os }}-${{ runner.arch }}-api${{ env.ANDROID_API_LEVEL }}
# Prime the cache by creating the snapshot (do NOT disable snapshots)
- name: Create AVD + snapshot (cache prime)
if: ${{ steps.avd-cache.outputs.cache-hit != 'true' }}
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
target: default
arch: x86_64
profile: pixel_5
force-avd-creation: false
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run Flutter integration tests
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
with:
api-level: ${{ env.ANDROID_API_LEVEL }}
target: default
arch: x86_64
profile: pixel_5
cores: 4
emulator-options: -no-window -no-boot-anim -no-audio -no-metrics
working-directory: embrace/example
script: |
set -eu
adb devices || true
flutter --version
flutter devices || true
flutter test -d emulator-5554 integration_test/app_test.dart
adb logcat -d > emulator_logcat.log 2>&1 || true
- name: Upload APK + logs (even if tests fail)
if: always()
uses: actions/upload-artifact@v6
with:
name: android-apk-and-logs
path: |
embrace/example/build/app/outputs/flutter-apk/*.apk
embrace/example/build/app/outputs/apk/**/*.apk
embrace/example/emulator_logcat.log
- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: android-emulator-flutter-results
path: |
**/build/reports/**
**/test-results/**
emulator_logcat.log
if-no-files-found: ignore
ios:
runs-on: macos-15
defaults:
run:
working-directory: embrace/example
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
- name: Flutter Pub Get
run: flutter pub get
- name: Configure App ID and API Token
run: |
sed -i .bak 's/YOUR_API_KEY/${{ secrets.FLUTTER_TEST_IOS_APP_ID }}/' ios/Embrace-Info.plist
sed -i .bak 's/YOUR_API_KEY/${{ secrets.FLUTTER_TEST_IOS_APP_ID }}/' ios/Runner.xcodeproj/project.pbxproj
sed -i .bak 's/YOUR_API_TOKEN/${{ secrets.FLUTTER_TEST_IOS_API_TOKEN }}/' ios/Embrace-Info.plist
sed -i .bak 's/YOUR_API_TOKEN/${{ secrets.FLUTTER_TEST_IOS_API_TOKEN }}/' ios/Runner.xcodeproj/project.pbxproj
- name: Flutter Doctor (sanity check)
run: flutter doctor -v
- name: Create & Boot iOS Simulator (prefer iOS 17.x)
id: boot-sim
shell: bash
run: |
set -euo pipefail
xcrun simctl shutdown all || true
xcrun simctl erase all || true
# Prefer iOS 17.*, fall back to newest available
RUNTIME=$(xcrun simctl list runtimes -j \
| jq -r '.runtimes[] | select(.platform=="iOS" and .isAvailable==true and (.version|startswith("17."))) | .identifier' \
| sort -V | tail -n1)
if [[ -z "${RUNTIME:-}" ]]; then
RUNTIME=$(xcrun simctl list runtimes -j \
| jq -r '.runtimes[] | select(.platform=="iOS" and .isAvailable==true) | .identifier' \
| sort -V | tail -n1)
fi
DEVICE_TYPE="com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro"
UDID=$(xcrun simctl create "CI iPhone" "$DEVICE_TYPE" "$RUNTIME")
echo "udid=$UDID" >> "$GITHUB_OUTPUT"
xcrun simctl boot "$UDID"
xcrun simctl bootstatus "$UDID" -b
xcrun simctl status_bar "$UDID" override --time 9:41 || true
xcrun simctl list devices | grep "$UDID"
- name: Stream Simulator Logs
run: |
xcrun simctl spawn "${STEPS_BOOT_SIM_OUTPUTS_UDID}" log stream --style syslog \
--predicate 'process == "Runner"' > simlog.txt 2>&1 &
echo $! > log.pid
env:
STEPS_BOOT_SIM_OUTPUTS_UDID: ${{ steps.boot-sim.outputs.udid }}
- name: Run iOS integration test (flutter drive)
env:
SIM_UDID: ${{ steps.boot-sim.outputs.udid }}
run: |
flutter devices
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d "$SIM_UDID"
- name: Kill log stream & tail
if: always()
run: |
kill $(cat log.pid) || true
tail -n 400 simlog.txt || true
- name: Shutdown simulator
if: always()
run: xcrun simctl shutdown all || true
pana:
defaults:
run:
working-directory: embrace
runs-on: ubuntu-latest
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: 🖋 Override Embrace packages with local versions
run: |
sed -i 'pubspec.yaml' -e 's/embrace_platform_interface:.*/embrace_platform_interface:\n path: ..\/embrace_platform_interface/'
sed -i 'pubspec.yaml' -e 's/embrace_android:.*/embrace_android:\n path: ..\/embrace_android/'
sed -i 'pubspec.yaml' -e 's/embrace_ios:.*/embrace_ios:\n path: ..\/embrace_ios/'
sed -i '../embrace_ios/pubspec.yaml' -e 's/embrace_platform_interface:.*/embrace_platform_interface:\n path: ..\/embrace_platform_interface/'
sed -i '../embrace_android/pubspec.yaml' -e 's/embrace_platform_interface:.*/embrace_platform_interface:\n path: ..\/embrace_platform_interface/'
- name: 🐦 Setup Flutter
uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
with:
channel: stable
cache: true
- name: ⬇️ Pub Get
run: flutter pub get
- name: 📦 Install Pana
run: flutter pub global activate pana
- name: 📊 Verify Pana Score
run: |
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
echo "Score: $PANA_SCORE"
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=${SCORE_ARR[0]}
if (( SCORE < 140 )); then echo "The minimum score of 140 was not met!"; exit 1; fi