-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (125 loc) · 4.5 KB
/
ci.yml
File metadata and controls
153 lines (125 loc) · 4.5 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
# ============================================================================
# CONTINUOUS INTEGRATION PIPELINE
# Runs on every PR and push to develop/main
# ============================================================================
name: Continuous Integration
on:
pull_request:
branches: [develop, main]
push:
branches: [develop, main]
workflow_dispatch:
env:
FLUTTER_VERSION: '3.35.7'
JAVA_VERSION: '17'
jobs:
# ============================================================================
# CODE QUALITY CHECKS
# ============================================================================
code-quality:
name: Code Quality Analysis
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 📦 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🎯 Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: 📊 Get Dependencies
run: flutter pub get
- name: 🔍 Run Flutter Analyzer
run: flutter analyze --no-fatal-infos
- name: 🎨 Check Code Formatting
run: dart format --set-exit-if-changed .
- name: 🔐 Check for Secrets
uses: trufflesecurity/trufflehog@main
with:
path: ./
base: ${{ github.event.repository.default_branch }}
head: HEAD
# ============================================================================
# UNIT & WIDGET TESTS
# ============================================================================
tests:
name: Run Tests
runs-on: ubuntu-latest
needs: code-quality
timeout-minutes: 15
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: 📊 Get Dependencies
run: flutter pub get
- name: 🧪 Run Tests with Coverage
run: flutter test --coverage --reporter expanded
- name: 📈 Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage/lcov.info
fail_ci_if_error: false
verbose: true
- name: 📊 Generate Coverage Report
run: |
flutter pub global activate coverage
flutter pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib
# ============================================================================
# BUILD VERIFICATION (Debug APK)
# ============================================================================
build-verification:
name: Build Verification
runs-on: ubuntu-latest
needs: tests
timeout-minutes: 20
strategy:
matrix:
flavor: [dev, staging, prod]
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: ☕ Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
cache: 'gradle'
- name: 📦 Get Dependencies
run: flutter pub get
- name: 🔨 Run Code Generation
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: 📝 Create Environment File
run: |
mkdir -p assets/config
echo "APP_NAME=Password Manager ${{ matrix.flavor }}" > assets/config/.env.${{ matrix.flavor }}
echo "APP_ENV=${{ matrix.flavor }}" >> assets/config/.env.${{ matrix.flavor }}
echo "API_BASE_URL=${{ secrets[format('{0}_API_BASE_URL', matrix.flavor)] }}" >> assets/config/.env.${{ matrix.flavor }}
- name: 🔨 Build Debug APK
run: |
flutter build apk \
-t lib/main_${{ matrix.flavor }}.dart \
--debug \
--flavor ${{ matrix.flavor }} \
--dart-define=FLAVOR=${{ matrix.flavor }}
- name: 📤 Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: apk-${{ matrix.flavor }}-debug
path: build/app/outputs/flutter-apk/app-${{ matrix.flavor }}-debug.apk
retention-days: 7