-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (92 loc) · 3.81 KB
/
coverage.yml
File metadata and controls
107 lines (92 loc) · 3.81 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
name: Coverage
# ─────────────────────────────────────────────────────────────────────────────
# Pipeline 2 (continuation) — Coverage report
#
# Runs only on push to main (not on PRs) to keep PR feedback fast.
# Skipped entirely when no Dart files changed (docs-only push).
#
# Pinned to the same runner + Flutter version as Pipeline 1 & 2 so that
# coverage numbers are produced in a reproducible environment.
# ─────────────────────────────────────────────────────────────────────────────
env:
FLUTTER_VERSION: "3.41.5"
on:
push:
branches: [main]
jobs:
# ── Detect changed paths ───────────────────────────────────────────────────
path-filter:
name: Detect Changed Packages
runs-on: ubuntu-22.04
outputs:
changed_any_dart: ${{ steps.filter.outputs.any_dart }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
any_dart:
- '**/*.dart'
- '**/pubspec.yaml'
- '**/pubspec.lock'
- '**/analysis_options.yaml'
# ── Coverage report ────────────────────────────────────────────────────────
coverage:
name: Generate Coverage
runs-on: ubuntu-22.04
needs: path-filter
if: needs.path-filter.outputs.changed_any_dart == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Restore pub cache
uses: actions/cache@v4
with:
path: |
~/.pub-cache
${{ env.PUB_CACHE }}
key: pub-ubuntu-${{ hashFiles('**/pubspec.lock') }}
restore-keys: pub-ubuntu-
- name: flutter pub get
run: flutter pub get
- name: Run tests with coverage
# Exclude test/golden/ — visual snapshot tests don't add coverage signal
# and fail on Linux because reference PNGs were generated on macOS.
# Golden correctness is enforced by the dedicated golden.yml workflow.
run: |
readarray -d '' TEST_FILES < <(
find test -name '*_test.dart' -not -path 'test/golden/*' -print0
)
flutter test --no-pub --coverage "${TEST_FILES[@]}"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage/lcov.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Check coverage threshold
run: |
sudo apt-get install -y --no-install-recommends lcov
total=$(lcov --summary coverage/lcov.info 2>&1 | grep "lines" | awk '{print $2}' | cut -d'%' -f1)
echo "Coverage: $total%"
if (( $(echo "$total < 50" | bc -l) )); then
echo "❌ Coverage below 50% threshold: $total%"
exit 1
else
echo "✅ Coverage meets threshold: $total%"
fi
- name: Generate HTML report
run: genhtml coverage/lcov.info -o coverage/html
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ github.run_number }}
path: coverage/html
retention-days: 30