-
-
Notifications
You must be signed in to change notification settings - Fork 19
261 lines (246 loc) · 8.54 KB
/
tests.yaml
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
# Heavily inspired by https://github.com/cfug/dio/blob/main/.github/workflows/tests.yml
name: Test and Code Coverage
on:
push:
branches:
- main
tags:
- "v*.*.*"
paths-ignore:
- "**.md"
pull_request:
branches:
- main
paths-ignore:
- "**.md"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -leo pipefail {0}
jobs:
unit_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [min, stable, beta]
env:
TEST_PRESET: all
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/flutter_base
with:
channel: ${{ matrix.sdk == 'min' && 'stable' || matrix.sdk }}
flutter-version: ${{ matrix.sdk == 'min' && '3.22.0' || '' }}
- run: |
echo TARGET_DART_SDK=${{ matrix.sdk }} >> $GITHUB_ENV
- name: "[Verify step] ✨ Format"
if: ${{ matrix.sdk == 'stable' }}
run: melos run format
- name: "[Verify step] 🕵️ Analyze packages"
if: ${{ matrix.sdk == 'stable' }}
run: melos run analyze
# - name: '[Verify step] 🕵️ Run Pana'
# if: ${{ matrix.sdk == 'stable' }}
# run: |
# flutter pub global activate pana
# melos run pana
- name: "[Verify step] Test Dart packages [VM]"
run: melos run test:vm
- name: "[Verify step] Test Dart packages [Chrome]"
run: melos run test:web:chrome
- name: "[Verify step] Test Dart packages [Firefox]"
run: melos run test:web:firefox
- name: Remove dart_test.yaml Files
run: melos run remove_dart_test_yaml
- name: "[Verify step] Test Flutter packages"
run: melos run test:flutter
- name: "[Coverage] Format & print test coverage"
if: ${{ matrix.sdk == 'stable' }}
run: melos run coverage:combine
- name: Upload Unit Test Coverage Report
uses: actions/upload-artifact@v4
if: ${{ matrix.sdk == 'stable' }}
with:
name: unit-tests-coverage
path: coverage/lcov.info
# Upload
# - name: Report to Codecov
# uses: codecov/codecov-action@v4
# if: ${{ matrix.sdk == 'stable' }}
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# file: coverage/lcov.info
# fail_ci_if_error: false
# integration tests
android:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [29]
defaults:
run:
working-directory: packages/oidc/example
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/integration_test_base
- 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@v3
- name: AVD cache
uses: actions/cache@v4
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 }}
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 Android Emulator and Integration Tests
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: packages/oidc/example
api-level: ${{ matrix.api-level }}
script: melos run integration_test:android
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: android-coverage.info
path: packages/oidc/example/android-coverage.info
ios:
runs-on: macos-latest
defaults:
run:
working-directory: packages/oidc/example
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/integration_test_base
with:
channel: master
flutter-version: ""
- name: Start Simulator
# Start an iPhone simulator
run: |
UDID=$(xcrun xctrace list devices | grep "^iPhone" | awk '{gsub(/[()]/,""); print $NF}' | head -n 1)
echo $UDID
xcrun simctl boot "${UDID:?No Simulator with this name found}"
- name: Integration Tests
run: melos run integration_test:ios
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: ios-coverage.info
path: packages/oidc/example/ios-coverage.info
web:
strategy:
fail-fast: false
matrix:
working-directory: ["packages/oidc/example"]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/integration_test_base
# for reference: https://github.com/firebase/flutterfire/blob/d41e30a808b47458d7ebd402862bcd55d8563ccb/.github/workflows/e2e_tests.yaml#L281-L289
- name: Run Web Integration Tests
working-directory: ${{ matrix.working-directory }}
run: |
# first we run chromedriver on port 4444 and Xvfb
export DISPLAY=:99
chromedriver --port=4444 --trace-buffer-size=100000 &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
# then we start flutter drive
flutter drive --driver=./test_driver/integration_test.dart --target=./integration_test/app_test.dart -d chrome --dart-define=CI=true | tee output.log
# We have to check the output for failed tests matching the string "[E]"
output=$(<output.log)
if [[ "$output" =~ \[E\] ]]; then
# You will see "All tests passed." in the logs even when tests failed.
echo "All tests did not pass. Please check the logs for more information."
exit 1
fi
shell: bash
# web has no test coverage for now
# - name: Upload Coverage Report
# uses: actions/upload-artifact@v4
# with:
# name: web-coverage
# path: packages/oidc/example/coverage/web-coverage.info
macos:
runs-on: macos-13
defaults:
run:
working-directory: packages/oidc/example
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/integration_test_base
- name: Integration Tests
run: melos run integration_test:macos
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: macos-coverage.info
path: packages/oidc/example/macos-coverage.info
linux:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/oidc/example
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/integration_test_base
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev liblzma-dev
- name: Integration Tests
run: melos run integration_test:linux
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: linux-coverage.info
path: packages/oidc/example/linux-coverage.info
windows:
runs-on: windows-latest
defaults:
run:
working-directory: packages/oidc/example
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Environment
uses: ./.github/actions/integration_test_base
- name: Integration Tests
run: dart run melos run integration_test:windows
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: windows-coverage.info
path: packages/oidc/example/windows-coverage.info