-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (123 loc) · 5.84 KB
/
analyze.yml
File metadata and controls
140 lines (123 loc) · 5.84 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
name: Pre-flight Checks
# ─────────────────────────────────────────────────────────────────────────────
# Pipeline 1 — Pre-flight (target: < 2 min)
#
# Runs on every push / PR as the fast gate that must pass before any heavy
# job is allowed to start. Three responsibilities:
#
# 1. dart format — code style, fails on any formatting diff
# 2. flutter analyze --fatal-infos — zero errors/warnings/infos enforced
# 3. Changed-path detection — outputs which packages were touched so that
# downstream jobs (test.yml) know what to test
#
# Optimisations vs the old setup:
# • Single runner (ubuntu-22.04), single Flutter version — no duplication
# • Skips ALL checks when only *.md / doc/ / .github/ files changed
# • pub-cache restored from cache before `flutter pub get`
# ─────────────────────────────────────────────────────────────────────────────
env:
FLUTTER_VERSION: "3.41.5"
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
preflight:
name: Format · Analyze · Path-filter
runs-on: ubuntu-22.04
outputs:
# Which packages (or groups) have changed — consumed by test.yml
changed_core: ${{ steps.filter.outputs.core }}
changed_html: ${{ steps.filter.outputs.html }}
changed_markdown: ${{ steps.filter.outputs.markdown }}
changed_highlight: ${{ steps.filter.outputs.highlight }}
changed_clipboard: ${{ steps.filter.outputs.clipboard }}
changed_devtools: ${{ steps.filter.outputs.devtools }}
changed_root: ${{ steps.filter.outputs.root }}
changed_any_dart: ${{ steps.filter.outputs.any_dart }}
steps:
- name: Checkout
uses: actions/checkout@v4
# ── Detect changed paths ────────────────────────────────────────────────
- name: Detect changed paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
core:
- 'packages/hyper_render_core/**'
html:
- 'packages/hyper_render_html/**'
markdown:
- 'packages/hyper_render_markdown/**'
highlight:
- 'packages/hyper_render_highlight/**'
clipboard:
- 'packages/hyper_render_clipboard/**'
devtools:
- 'packages/hyper_render_devtools/**'
root:
- 'lib/**'
- 'test/**'
- 'pubspec.yaml'
- 'pubspec.lock'
any_dart:
- '**/*.dart'
- '**/pubspec.yaml'
- '**/pubspec.lock'
- '**/analysis_options.yaml'
# ── Skip everything if only docs / CI config changed ───────────────────
- name: Skip if docs-only change
if: steps.filter.outputs.any_dart == 'false'
run: |
echo "✓ Only non-Dart files changed — skipping format & analyze"
echo " (golden.yml and benchmark.yml handle their own triggers)"
# ── Flutter setup (only when Dart files changed) ────────────────────────
- name: Setup Flutter
if: steps.filter.outputs.any_dart == 'true'
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Restore pub cache
if: steps.filter.outputs.any_dart == 'true'
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
if: steps.filter.outputs.any_dart == 'true'
run: flutter pub get
# ── dart format ─────────────────────────────────────────────────────────
- name: dart format (fail on diff)
if: steps.filter.outputs.any_dart == 'true'
run: dart format --set-exit-if-changed .
# ── flutter analyze ─────────────────────────────────────────────────────
- name: flutter analyze --fatal-infos
if: steps.filter.outputs.any_dart == 'true'
run: |
flutter analyze --no-pub --fatal-infos 2>&1 | tee analyze_report.txt
EXIT=${PIPESTATUS[0]}
ERRORS=$(grep -c "error •" analyze_report.txt 2>/dev/null || true)
WARNS=$(grep -c "warning •" analyze_report.txt 2>/dev/null || true)
INFOS=$(grep -c "info •" analyze_report.txt 2>/dev/null || true)
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Static Analysis Results"
echo " Errors: $ERRORS"
echo " Warnings: $WARNS"
echo " Infos: $INFOS"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit $EXIT
- name: Upload analyze report
if: always() && steps.filter.outputs.any_dart == 'true'
uses: actions/upload-artifact@v4
with:
name: analyze-report-${{ github.run_number }}
path: analyze_report.txt
retention-days: 7