-
-
Notifications
You must be signed in to change notification settings - Fork 0
338 lines (283 loc) · 10.3 KB
/
ci.yml
File metadata and controls
338 lines (283 loc) · 10.3 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
markdown:
runs-on: ubuntu-latest
name: Markdown Lint
steps:
- uses: actions/checkout@v4
- name: Lint Markdown files
uses: DavidAnson/markdownlint-cli2-action@v19
with:
globs: |
*.md
.github/**/*.md
config: ".markdownlint.yaml"
quality:
runs-on: ubuntu-latest
name: Lint, Format & Test
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-
- name: Install Melos
run: dart pub global activate melos
- name: Bootstrap
run: melos bootstrap
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
- name: Analyze
run: melos run analyze
- name: Check auto-fixable issues
run: |
OUTPUT=$(dart fix --dry-run . 2>&1)
echo "$OUTPUT"
echo "$OUTPUT" | grep -q "Nothing to fix!" || { echo "::error::Auto-fixable issues found. Run 'dart fix --apply' and commit."; exit 1; }
- name: Verify generated code (Drift)
run: |
cd core && dart run build_runner build --delete-conflicting-outputs
git diff --exit-code . || { echo "::error::Generated code is out of date. Run 'dart run build_runner build --delete-conflicting-outputs' in core/ and commit."; exit 1; }
- name: Verify generated localizations
run: |
cd app && flutter gen-l10n
git diff --exit-code lib/l10n/ || { echo "::error::Generated l10n files are out of date. Run 'flutter gen-l10n' in app/ and commit."; exit 1; }
- name: Check outdated dependencies
run: melos run outdated
continue-on-error: true
- name: Run tests
run: melos run test:coverage
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-reports
path: |
core/coverage/lcov.info
listener/coverage/lcov.info
app/coverage/lcov.info
retention-days: 1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: always()
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: core/coverage/lcov.info,listener/coverage/lcov.info,app/coverage/lcov.info
flags: core,listener,app
fail_ci_if_error: false
release-readiness:
runs-on: ubuntu-latest
name: Release Readiness
steps:
- uses: actions/checkout@v4
- name: Validate pubspec structure
run: |
errors=0
for pkg in app core listener; do
if [ ! -f "$pkg/pubspec.yaml" ]; then
echo "::error::Missing $pkg/pubspec.yaml"
errors=$((errors + 1))
continue
fi
version=$(grep '^version:' "$pkg/pubspec.yaml" | head -1 | awk '{print $2}')
name=$(grep '^name:' "$pkg/pubspec.yaml" | head -1 | awk '{print $2}')
if [ -z "$version" ]; then
echo "::error::Missing version field in $pkg/pubspec.yaml"
errors=$((errors + 1))
fi
if [ -z "$name" ]; then
echo "::error::Missing name field in $pkg/pubspec.yaml"
errors=$((errors + 1))
fi
echo "✓ $pkg: name=$name version=$version"
done
[ $errors -eq 0 ] || exit 1
- name: Validate release workflow references
run: |
errors=0
for wf in release-win.yml release-mac.yml release-linux.yml; do
if [ ! -f ".github/workflows/$wf" ]; then
echo "::error::Missing .github/workflows/$wf (referenced by release.yml)"
errors=$((errors + 1))
else
echo "✓ .github/workflows/$wf"
fi
done
[ $errors -eq 0 ] || exit 1
- name: Validate project structure
run: |
errors=0
for dir in app/lib app/windows app/macos app/linux app/assets; do
if [ ! -d "$dir" ]; then
echo "::error::Missing required directory: $dir"
errors=$((errors + 1))
else
echo "✓ $dir/"
fi
done
for file in app/l10n.yaml app/pubspec.yaml core/pubspec.yaml listener/pubspec.yaml; do
if [ ! -f "$file" ]; then
echo "::error::Missing required file: $file"
errors=$((errors + 1))
else
echo "✓ $file"
fi
done
[ $errors -eq 0 ] || exit 1
- name: Simulate release version extraction
run: |
test_tags=("v2.1.0" "v2.0.0-beta.1" "v3.0.0" "v1.0.0-rc.1")
for tag in "${test_tags[@]}"; do
ref="refs/tags/$tag"
if [[ "$ref" =~ refs/tags/v(.+) ]]; then
VERSION="${BASH_REMATCH[1]}"
# Validate version format (semver)
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Tag $tag produces invalid version: $VERSION"
exit 1
fi
echo "✓ $tag → $VERSION"
else
echo "::error::Tag $tag would fail version extraction in release.yml"
exit 1
fi
done
build:
needs: quality
runs-on: windows-latest
name: Build Verification (Windows)
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-
- name: Install Melos
run: dart pub global activate melos
- name: Get dependencies
run: melos bootstrap
- name: Build Windows release
run: cd app; flutter build windows --release
build-linux:
needs: quality
runs-on: ubuntu-22.04
name: Build Verification (Linux)
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-
- name: Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
desktop-file-utils \
libayatana-appindicator3-dev \
libfuse2 \
libgtk-3-dev \
libkeybinder-3.0-dev \
liblzma-dev \
libx11-dev \
libxtst-dev \
lld-14 \
ninja-build \
patchelf \
pkg-config
- name: Verify Linux toolchain preflight
run: |
set -euo pipefail
test -x /usr/lib/llvm-14/bin/ld.lld || test -x /usr/bin/ld.lld-14 || test -x /usr/bin/ld.lld
pkg-config --modversion gtk+-3.0
pkg-config --modversion keybinder-3.0
pkg-config --modversion ayatana-appindicator3-0.1
pkg-config --modversion x11
pkg-config --modversion xtst
- name: Install Melos
run: dart pub global activate melos
- name: Get dependencies
run: melos bootstrap
- name: Build Linux release
run: cd app && flutter build linux --release
build-macos:
needs: quality
runs-on: macos-latest
name: Build Verification (macOS)
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-
- name: Install Melos
run: dart pub global activate melos
- name: Get dependencies
run: melos bootstrap
- name: Build macOS release
run: cd app && flutter build macos --release
sonarcloud:
name: SonarCloud
needs: quality
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: coverage-reports
path: .
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }}
-Dsonar.organization=${{ vars.SONAR_ORGANIZATION }}
-Dsonar.sources=core/lib,listener/lib,app/lib
-Dsonar.tests=core/test,listener/test,app/test
-Dsonar.dart.lcov.reportPaths=core/coverage/lcov.info,listener/coverage/lcov.info,app/coverage/lcov.info
-Dsonar.exclusions=**/generated/**,**/*.g.dart,**/*.freezed.dart,**/l10n/**,**/core.dart
-Dsonar.coverage.exclusions=**/main.dart,**/shell/**,**/services/auto_update_service.dart,**/windows_clipboard_listener.dart,**/l10n/**,**/*.g.dart,**/*.freezed.dart,**/core.dart,**/screens/settings_screen.dart
-Dsonar.qualitygate.wait=true
-Dsonar.qualitygate.timeout=300