Repository navigation
200 lines (188 loc) · 6.86 KB
/
Copy pathtest.yml
File metadata and controls
200 lines (188 loc) · 6.86 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
name: test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
changes:
runs-on: ubuntu-latest
outputs:
docs: ${{ steps.filter.outputs.docs }}
android: ${{ steps.filter.outputs.android }}
ios: ${{ steps.filter.outputs.ios }}
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/check-changes
id: filter
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version-file: .fvmrc
cache: true
- uses: bluefireteam/melos-action@v3
- name: Test
run: |
cd workmanager
flutter test
native_ios_tests:
needs: changes
if: needs.changes.outputs.ios == 'true'
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- uses: bluefireteam/melos-action@v3
- name: Setup iOS build environment
run: |
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
xcrun --sdk iphoneos --show-sdk-version
- name: Clean and prepare Flutter
run: |
cd example
flutter clean
flutter pub get
- name: Build iOS App
run: cd example && flutter build ios --debug --no-codesign --verbose
- name: Resolve latest iOS simulator
id: sim
uses: ./.github/actions/resolve-ios-simulator
- name: Run native iOS tests
run: cd example/ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator -destination "platform=iOS Simulator,id=${{ steps.sim.outputs.udid }}" test
native_android_tests:
needs: changes
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version-file: .fvmrc
cache: true
- uses: bluefireteam/melos-action@v3
- name: Build Android App
run: cd example && flutter build apk --debug
- name: Run native Android tests
run: cd example/android && ./gradlew :workmanager_android:test
drive_ios:
needs: changes
if: needs.changes.outputs.ios == 'true'
runs-on: macos-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Resolve latest iOS simulator
id: sim
uses: ./.github/actions/resolve-ios-simulator
- uses: futureware-tech/simulator-action@v3
with:
model: '${{ steps.sim.outputs.model }}'
- uses: bluefireteam/melos-action@v3
# Run flutter integrate tests
- name: Run Flutter integration tests
timeout-minutes: 35
run: |
# `flutter test` on iOS simulators intermittently stalls before the
# Dart VM service becomes available (flutter/flutter#153433). Retry a
# few times with a per-attempt timeout; cached builds make retries fast.
cd example
for attempt in 1 2 3; do
echo "=== drive_ios attempt $attempt ==="
if perl -e 'alarm shift; exec @ARGV' 480 flutter test integration_test/workmanager_integration_test.dart -d "${{ steps.sim.outputs.udid }}" > /tmp/flutter_test_$attempt.log 2>&1; then
echo "drive_ios passed on attempt $attempt"
exit 0
fi
echo "drive_ios attempt $attempt failed (exit $?)"
xcrun simctl terminate "${{ steps.sim.outputs.udid }}" dev.fluttercommunity.workmanagerExample 2>/dev/null || true
done
echo "All attempts failed; dumping last attempt log:"
tail -100 /tmp/flutter_test_3.log
exit 1
- name: Dump simulator logs
if: failure()
run: |
echo "=== Last 100 lines of flutter test log ==="
tail -100 /tmp/flutter_test_3.log || true
echo "=== Runner app logs (last 10m) ==="
xcrun simctl spawn "${{ steps.sim.outputs.udid }}" log show --last 10m --predicate 'process == "Runner"' --style compact 2>/dev/null | tail -80 || true
drive_android:
needs: changes
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
#creates a build matrix for your jobs
strategy:
#set of different configurations of the virtual environment.
matrix:
api-level: [35]
# api-level: [21, 29]
target: [default]
steps:
- uses: actions/checkout@v7
- 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/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- uses: bluefireteam/melos-action@v3
# Gradle cache for better performance
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
# AVD cache to speed up emulator startup
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.target }}-${{ runner.os }}
# Generate AVD snapshot for caching if not already cached
- name: Create AVD and generate 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: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "Generated AVD snapshot"
# Run actual tests using cached AVD
- name: Run Flutter integration tests
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
disk-size: 6000M
heap-size: 600M
script: |
cd example && flutter test integration_test/workmanager_integration_test.dart