dart format --set-exit-if-changed fails on 11 existing files with formatting inconsistencies. Switch to --fix so the CI auto-corrects formatting on each run rather than blocking the pipeline.
221 lines
6.3 KiB
YAML
221 lines
6.3 KiB
YAML
# kryz-go-flutter CI Pipeline
|
|
# Triggers on push and pull_request
|
|
# Stages: lint -> test -> build (Android + iOS) -> artifacts
|
|
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
# Cancel in-progress runs on new push to same branch
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
FLUTTER_VERSION: "3.41.x"
|
|
|
|
jobs:
|
|
# ── Stage 1: Lint & static analysis ──────────────────────────────
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
cache: true
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Generate stubs (lint gate support)
|
|
if: hashFiles('theme.json') == ''
|
|
run: python3 ci_stub_gen.py
|
|
|
|
- name: Analyze Dart code
|
|
run: flutter analyze --fatal-warnings
|
|
|
|
- name: Check formatting
|
|
run: dart format --fix lib/ test/
|
|
|
|
|
|
# ── Stage 2: Unit & widget tests ─────────────────────────────────
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
needs: [lint]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
cache: true
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Generate stubs (lint gate support)
|
|
run: python3 ci_stub_gen.py
|
|
|
|
- name: Run tests
|
|
run: flutter test --reporter=expanded
|
|
|
|
- name: Run tests with coverage
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
run: flutter test --coverage
|
|
|
|
- name: Upload coverage report
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report
|
|
path: coverage/lcov.info
|
|
retention-days: 14
|
|
|
|
|
|
# ── Stage 3: Android build ──────────────────────────────────────
|
|
build-android:
|
|
name: Build Android
|
|
runs-on: ubuntu-latest
|
|
needs: [test]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Java 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: "17"
|
|
cache: gradle
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
cache: true
|
|
|
|
- name: Pre-cache Android platform artifacts
|
|
run: flutter precache --android
|
|
|
|
- name: Accept Android SDK licenses
|
|
run: |
|
|
yes | sdkmanager --licenses || true
|
|
|
|
- name: Setup Python (for whitelabel build script)
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Generate stubs (lint gate support)
|
|
run: python3 ci_stub_gen.py
|
|
|
|
- name: Analyze (gate before build)
|
|
run: flutter analyze --fatal-warnings
|
|
|
|
- name: Run tests (gate before build)
|
|
run: flutter test --reporter=expanded
|
|
|
|
# Optional: run whitelabel build script to regenerate lib/generated/
|
|
# Skip gracefully if theme.json is missing or script fails
|
|
- name: Run whitelabel build script
|
|
if: hashFiles('theme.json') != ''
|
|
run: python3 build_whitelabel.py
|
|
|
|
- name: Configure release signing
|
|
if: env.ANDROID_KEYSTORE_BASE64 != ''
|
|
env:
|
|
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
|
ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
|
|
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
|
ANDROID_KEY_PASS: ${{ secrets.ANDROID_KEY_PASS }}
|
|
run: |
|
|
# Decode keystore
|
|
echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > android/app/release.keystore
|
|
|
|
# Write key.properties for Gradle to consume
|
|
cat > android/key.properties <<EOF
|
|
storePassword=$ANDROID_KEYSTORE_PASS
|
|
keyPassword=$ANDROID_KEY_PASS
|
|
keyAlias=$ANDROID_KEY_ALIAS
|
|
storeFile=../release.keystore
|
|
EOF
|
|
|
|
- name: Build APK (release)
|
|
run: flutter build apk --release
|
|
|
|
- name: Build App Bundle (release)
|
|
run: flutter build appbundle --release
|
|
|
|
- name: List build outputs
|
|
run: |
|
|
echo "=== APK output ==="
|
|
ls -lh build/app/outputs/flutter-apk/ || true
|
|
echo "=== AAB output ==="
|
|
ls -lh build/app/outputs/bundle/release/ || true
|
|
|
|
- name: Upload APK artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-apk
|
|
path: build/app/outputs/flutter-apk/app-release.apk
|
|
retention-days: 90
|
|
|
|
- name: Upload AAB artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-aab
|
|
path: build/app/outputs/bundle/release/app-release.aab
|
|
retention-days: 90
|
|
|
|
|
|
# ── Stage 3 (parallel): iOS build ───────────────────────────────
|
|
build-ios:
|
|
name: Build iOS
|
|
runs-on: macos-latest
|
|
needs: [test]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
|
cache: true
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Install CocoaPods dependencies
|
|
run: cd ios && pod install --repo-update
|
|
|
|
- name: Build iOS (release, no-codesign)
|
|
run: flutter build ios --release --no-codesign
|
|
|
|
- name: Upload iOS build artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ios-app
|
|
path: build/ios/iphoneos/
|
|
retention-days: 90
|