1+ name : Minification Compatibility Test
2+
3+ on :
4+ push :
5+ branches : [ "master" ]
6+ pull_request :
7+ branches : [ "master" ]
8+ workflow_dispatch :
9+
10+ jobs :
11+ minification_compatibility_test :
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v3
17+
18+ - name : Setup Flutter
19+ uses : subosito/flutter-action@v2
20+ with :
21+ channel : ' stable'
22+ architecture : x64
23+ cache : true
24+
25+ - name : Setup Java
26+ uses : actions/setup-java@v3
27+ with :
28+ distribution : ' temurin'
29+ java-version : ' 17'
30+
31+ - name : Configure Gradle JVM options
32+ run : |
33+ mkdir -p ~/.gradle
34+ cat > ~/.gradle/gradle.properties << 'EOF'
35+ # Increase heap size for CI builds
36+ org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError
37+ org.gradle.daemon=true
38+ org.gradle.parallel=true
39+ org.gradle.configureondemand=true
40+ android.enableJetifier=true
41+ android.useAndroidX=true
42+ EOF
43+
44+ - name : Configure Android build options
45+ run : |
46+ cat >> example/android/gradle.properties << 'EOF'
47+
48+ # Memory optimization for CI
49+ org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m
50+ android.enableJetifier=true
51+ android.useAndroidX=true
52+ EOF
53+
54+ - name : Install dependencies
55+ run : |
56+ flutter pub get
57+ cd example && flutter pub get
58+
59+ - name : Create ProGuard rules for example app
60+ run : |
61+ cat > example/android/app/proguard-rules.pro << 'EOF'
62+ # Example app ProGuard rules for minification testing
63+
64+ # Keep example app classes
65+ -keep class com.optimizely.optimizely_flutter_sdk_example.** { *; }
66+
67+ # Keep Flutter classes
68+ -keep class io.flutter.app.** { *; }
69+ -keep class io.flutter.plugins.GeneratedPluginRegistrant { *; }
70+
71+ # Google Play Core (for Flutter engine)
72+ -keep class com.google.android.play.core.** { *; }
73+ -dontwarn com.google.android.play.core.**
74+
75+ # Jackson JSON
76+ -keep class com.fasterxml.jackson.** { *; }
77+ -dontwarn com.fasterxml.jackson.**
78+
79+ # Ignore missing classes
80+ -dontwarn javax.mail.**
81+ -dontwarn javax.activation.**
82+ EOF
83+
84+ - name : Test with minification ENABLED
85+ run : |
86+ echo "🧪 Testing with minifyEnabled = true"
87+
88+ # Backup original build.gradle
89+ cp example/android/app/build.gradle example/android/app/build.gradle.backup
90+
91+ # Enable minification
92+ sed -i 's/minifyEnabled false/minifyEnabled true/' example/android/app/build.gradle
93+ sed -i 's/shrinkResources false/shrinkResources true/' example/android/app/build.gradle
94+
95+ # Ensure ProGuard rules are applied
96+ if ! grep -q "proguardFiles.*proguard-rules.pro" example/android/app/build.gradle; then
97+ sed -i '/minifyEnabled true/a\ proguardFiles getDefaultProguardFile('\''proguard-android-optimize.txt'\''), '\''proguard-rules.pro'\''' example/android/app/build.gradle
98+ fi
99+
100+ echo "📄 Build configuration with minification:"
101+ grep -A 5 "buildTypes" example/android/app/build.gradle
102+
103+ # Build for single architecture to save memory
104+ cd example
105+ flutter build apk --release --target-platform android-arm64 --split-per-abi
106+
107+ echo "✅ Build successful with minification ENABLED"
108+
109+ - name : Test with minification DISABLED
110+ run : |
111+ echo "🧪 Testing with minifyEnabled = false"
112+
113+ # Restore original
114+ cp example/android/app/build.gradle.backup example/android/app/build.gradle
115+ sed -i 's/minifyEnabled true/minifyEnabled false/' example/android/app/build.gradle
116+ sed -i 's/shrinkResources true/shrinkResources false/' example/android/app/build.gradle
117+
118+ echo "📄 Build configuration without minification:"
119+ grep -A 5 "buildTypes" example/android/app/build.gradle
120+
121+ # Clean and build
122+ cd example
123+ flutter clean
124+ flutter build apk --release --target-platform android-arm64 --split-per-abi
125+
126+ echo "✅ Build successful with minification DISABLED"
127+
128+ - name : Run unit tests
129+ run : flutter test
130+
131+ - name : Verify APK artifacts
132+ run : |
133+ echo "📱 Checking APK files:"
134+ find example/build/app/outputs/apk/ -name "*.apk" -exec ls -la {} \;
135+
136+ - name : Check for ProGuard artifacts
137+ run : |
138+ echo "🔍 Checking for ProGuard/R8 artifacts:"
139+ if [ -f "example/build/app/outputs/mapping/release/mapping.txt" ]; then
140+ echo "✅ ProGuard mapping file found"
141+ echo "📄 Mapping file size: $(wc -l < example/build/app/outputs/mapping/release/mapping.txt) lines"
142+ else
143+ echo "ℹ️ No mapping file found"
144+ fi
145+
146+ - name : Report test results
147+ run : |
148+ echo "🎉 Minification compatibility test completed!"
149+ echo "✅ minifyEnabled = true: PASSED"
150+ echo "✅ minifyEnabled = false: PASSED"
151+ echo "✅ Memory optimizations applied successfully"
152+
153+ - name : Cleanup
154+ if : always()
155+ run : |
156+ if [ -f "example/android/app/build.gradle.backup" ]; then
157+ mv example/android/app/build.gradle.backup example/android/app/build.gradle
158+ echo "✅ Restored original build.gradle"
159+ fi
0 commit comments