-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (87 loc) · 2.98 KB
/
Copy pathci.yml
File metadata and controls
100 lines (87 loc) · 2.98 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
name: CI
on:
push:
branches: [main]
pull_request:
# Cancel superseded runs for the same ref.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# Resolves the Flutter version from .fvmrc once and exposes it to the build
# jobs, so the toolchain is driven by fvm — never hardcoded in the workflow.
analyze-and-test:
name: Format · Analyze · Test
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
flutter-version: ${{ steps.fvm.outputs.FLUTTER_VERSION }}
flutter-channel: ${{ steps.fvm.outputs.FLUTTER_CHANNEL }}
steps:
- uses: actions/checkout@v7
- id: fvm
name: Read Flutter version from .fvmrc
uses: kuhnroyal/flutter-fvm-config-action@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm.outputs.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed lib test
- name: Analyze
run: flutter analyze
- name: Test
run: flutter test
build-example:
name: Build example APK
needs: analyze-and-test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.analyze-and-test.outputs.flutter-version }}
channel: ${{ needs.analyze-and-test.outputs.flutter-channel }}
cache: true
- run: flutter pub get
working-directory: example
- run: flutter build apk --debug
working-directory: example
pana:
name: pana score gate
needs: analyze-and-test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.analyze-and-test.outputs.flutter-version }}
channel: ${{ needs.analyze-and-test.outputs.flutter-channel }}
cache: true
- run: flutter pub get
- name: Run pana
run: dart pub global activate pana && dart pub global run pana --no-warning --json . > pana.json
- name: Enforce score threshold
# Baseline gate. Raise toward the 150/160 target as the package matures.
env:
THRESHOLD: "120"
run: |
python3 - <<'PY'
import json, os, sys
data = json.load(open("pana.json"))
granted = data["scores"]["grantedPoints"]
maximum = data["scores"]["maxPoints"]
threshold = int(os.environ["THRESHOLD"])
print(f"pana score: {granted}/{maximum} (threshold {threshold})")
if granted < threshold:
print(f"::error::pana score {granted} is below the threshold of {threshold}")
sys.exit(1)
PY