-
Notifications
You must be signed in to change notification settings - Fork 4
172 lines (138 loc) · 6.04 KB
/
minification.yml
File metadata and controls
172 lines (138 loc) · 6.04 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Minification Compatibility Test
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
minification_compatibility_test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
cache: true
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Configure Gradle JVM options
run: |
mkdir -p ~/.gradle
cat > ~/.gradle/gradle.properties << 'EOF'
# Increase heap size for CI builds
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
android.enableJetifier=true
android.useAndroidX=true
EOF
- name: Configure Android build options
run: |
cat >> example/android/gradle.properties << 'EOF'
# Memory optimization for CI
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m
android.enableJetifier=true
android.useAndroidX=true
EOF
- name: Install dependencies
run: |
flutter pub get
cd example && flutter pub get
- name: Create ProGuard rules for example app
run: |
cat > example/android/app/proguard-rules.pro << 'EOF'
# Example app ProGuard rules for minification testing
# Keep example app classes
-keep class com.optimizely.optimizely_flutter_sdk_example.** { *; }
# Keep Flutter classes
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugins.GeneratedPluginRegistrant { *; }
# Google Play Core (for Flutter engine)
-keep class com.google.android.play.core.** { *; }
-dontwarn com.google.android.play.core.**
# Additional safety for Optimizely
-keep class com.optimizely.** { *; }
-dontwarn com.optimizely.**
# Jackson JSON
-keep class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.**
# Ignore missing classes
-dontwarn javax.mail.**
-dontwarn javax.activation.**
EOF
- name: Test with minification ENABLED
run: |
echo "🧪 Testing with minifyEnabled = true"
# Backup original build.gradle
cp example/android/app/build.gradle example/android/app/build.gradle.backup
# Enable minification
sed -i 's/minifyEnabled false/minifyEnabled true/' example/android/app/build.gradle
sed -i 's/shrinkResources false/shrinkResources true/' example/android/app/build.gradle
# Ensure ProGuard rules are applied
if ! grep -q "proguardFiles.*proguard-rules.pro" example/android/app/build.gradle; then
sed -i '/minifyEnabled true/a\ proguardFiles getDefaultProguardFile('\''proguard-android-optimize.txt'\''), '\''proguard-rules.pro'\''' example/android/app/build.gradle
fi
echo "📄 Build configuration with minification:"
grep -A 5 "buildTypes" example/android/app/build.gradle
# Build for single architecture to save memory
cd example
flutter build apk --release --target-platform android-arm64 --split-per-abi
echo "✅ Build successful with minification ENABLED"
- name: Test with minification DISABLED
run: |
echo "🧪 Testing with minifyEnabled = false"
# Restore original
cp example/android/app/build.gradle.backup example/android/app/build.gradle
sed -i 's/minifyEnabled true/minifyEnabled false/' example/android/app/build.gradle
sed -i 's/shrinkResources true/shrinkResources false/' example/android/app/build.gradle
echo "📄 Build configuration without minification:"
grep -A 5 "buildTypes" example/android/app/build.gradle
# Clean and build
cd example
flutter clean
flutter build apk --release --target-platform android-arm64 --split-per-abi
echo "✅ Build successful with minification DISABLED"
- name: Run unit tests
run: flutter test
- name: Verify APK artifacts
run: |
echo "📱 Checking APK files:"
find example/build/app/outputs/apk/ -name "*.apk" -exec ls -la {} \;
- name: Check for ProGuard artifacts
run: |
echo "🔍 Checking for ProGuard/R8 artifacts:"
if [ -f "example/build/app/outputs/mapping/release/mapping.txt" ]; then
echo "✅ ProGuard mapping file found"
echo "📄 Mapping file size: $(wc -l < example/build/app/outputs/mapping/release/mapping.txt) lines"
else
echo "ℹ️ No mapping file found"
fi
- name: Upload APK artifacts
uses: actions/upload-artifact@v4
with:
name: minification-test-apk
path: |
example/build/app/outputs/apk/release/*.apk
example/build/app/outputs/mapping/release/mapping.txt
retention-days: 7
- name: Report test results
run: |
echo "🎉 Minification compatibility test completed!"
echo "✅ minifyEnabled = true: PASSED"
echo "✅ minifyEnabled = false: PASSED"
echo "✅ Memory optimizations applied successfully"
- name: Cleanup
if: always()
run: |
if [ -f "example/android/app/build.gradle.backup" ]; then
mv example/android/app/build.gradle.backup example/android/app/build.gradle
echo "✅ Restored original build.gradle"
fi