-
Notifications
You must be signed in to change notification settings - Fork 0
264 lines (224 loc) · 8.09 KB
/
ci.yml
File metadata and controls
264 lines (224 loc) · 8.09 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
name: CI
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
push:
branches:
- '**'
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: Run with debug logging
required: false
default: false
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
FLUTTER_CHANNEL: stable
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Install dependencies
run: flutter pub get
- name: Check formatting
id: format_check
run: |
echo "## Format" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if dart format --set-exit-if-changed --output=none . 2>&1 | tee format_output.txt; then
echo "Formatting is valid." >> "$GITHUB_STEP_SUMMARY"
echo "format_status=success" >> "$GITHUB_OUTPUT"
else
echo "Formatting issues were found." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
dart format --set-exit-if-changed . 2>&1 | grep -E "^Changed|^Would change" >> "$GITHUB_STEP_SUMMARY" || true
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "format_status=failure" >> "$GITHUB_OUTPUT"
exit 1
fi
analyze:
name: Analyze
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Install dependencies
run: flutter pub get
- name: Run analyzer
id: analyze
run: |
echo "## Analyze" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if flutter analyze --no-fatal-infos 2>&1 | tee analyze_output.txt; then
echo "No analysis issues found." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
cat analyze_output.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "analyze_status=success" >> "$GITHUB_OUTPUT"
else
echo "Analysis issues were found." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
cat analyze_output.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "analyze_status=failure" >> "$GITHUB_OUTPUT"
exit 1
fi
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Install dependencies
run: flutter pub get
- name: Create test environment file
run: echo "# Test environment" > .env
- name: Run tests
id: test
run: |
echo "## Test" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if flutter test --coverage 2>&1 | tee test_output.txt; then
echo "Tests passed." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
tail -20 test_output.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "test_status=success" >> "$GITHUB_OUTPUT"
else
echo "Tests failed." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
cat test_output.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "test_status=failure" >> "$GITHUB_OUTPUT"
exit 1
fi
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/lcov.info
retention-days: 7
if-no-files-found: ignore
build:
name: Build
runs-on: ubuntu-latest
needs: [format, analyze, test]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
cache: gradle
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Install dependencies
run: flutter pub get
- name: Create build environment file
run: echo "# Build environment" > .env
- name: Build debug APK
id: build
run: |
echo "## Build" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if flutter build apk --debug 2>&1 | tee build_output.txt; then
echo "Debug APK build succeeded." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
APK_PATH="build/app/outputs/flutter-apk/app-debug.apk"
if [ -f "$APK_PATH" ]; then
APK_SIZE=$(du -h "$APK_PATH" | cut -f1)
echo "| Property | Value |" >> "$GITHUB_STEP_SUMMARY"
echo "| --- | --- |" >> "$GITHUB_STEP_SUMMARY"
echo "| APK Size | $APK_SIZE |" >> "$GITHUB_STEP_SUMMARY"
echo "| Build Type | Debug |" >> "$GITHUB_STEP_SUMMARY"
fi
echo "build_status=success" >> "$GITHUB_OUTPUT"
else
echo "Build failed." >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
tail -50 build_output.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "build_status=failure" >> "$GITHUB_OUTPUT"
exit 1
fi
status:
name: Status
runs-on: ubuntu-latest
needs: [format, analyze, test, build]
if: always()
steps:
- name: Summarize pipeline status
run: |
echo "## CI Summary" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Check | Result |" >> "$GITHUB_STEP_SUMMARY"
echo "| --- | --- |" >> "$GITHUB_STEP_SUMMARY"
if [ "${{ needs.format.result }}" = "success" ]; then
echo "| Format | Passed |" >> "$GITHUB_STEP_SUMMARY"
else
echo "| Format | Failed |" >> "$GITHUB_STEP_SUMMARY"
fi
if [ "${{ needs.analyze.result }}" = "success" ]; then
echo "| Analyze | Passed |" >> "$GITHUB_STEP_SUMMARY"
else
echo "| Analyze | Failed |" >> "$GITHUB_STEP_SUMMARY"
fi
if [ "${{ needs.test.result }}" = "success" ]; then
echo "| Test | Passed |" >> "$GITHUB_STEP_SUMMARY"
else
echo "| Test | Failed |" >> "$GITHUB_STEP_SUMMARY"
fi
if [ "${{ needs.build.result }}" = "success" ]; then
echo "| Build | Passed |" >> "$GITHUB_STEP_SUMMARY"
else
echo "| Build | Failed |" >> "$GITHUB_STEP_SUMMARY"
fi
if [ "${{ needs.format.result }}" = "success" ] && \
[ "${{ needs.analyze.result }}" = "success" ] && \
[ "${{ needs.test.result }}" = "success" ] && \
[ "${{ needs.build.result }}" = "success" ]; then
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "All CI checks passed." >> "$GITHUB_STEP_SUMMARY"
else
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "One or more CI checks failed." >> "$GITHUB_STEP_SUMMARY"
exit 1
fi