Skip to content

Commit 71a352d

Browse files
ci: add minification compatibility test workflow
- Implement a CI workflow for testing minification compatibility - Include job for testing with minification enabled and disabled - Add steps for verifying APK artifacts and ProGuard files - Include uploading APK artifacts and reporting test results
1 parent f16c364 commit 71a352d

File tree

2 files changed

+167
-159
lines changed

2 files changed

+167
-159
lines changed

.github/workflows/flutter.yml

Lines changed: 1 addition & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -170,162 +170,4 @@ jobs:
170170
channel: 'stable'
171171
architecture: x64
172172
- run: flutter pub get
173-
- run: flutter test
174-
175-
# Minification Compatibility Test
176-
minification_compatibility_test:
177-
runs-on: ubuntu-latest
178-
179-
steps:
180-
- name: Checkout code
181-
uses: actions/checkout@v3
182-
183-
- name: Setup Flutter
184-
uses: subosito/flutter-action@v2
185-
with:
186-
channel: 'stable'
187-
architecture: x64
188-
cache: true
189-
190-
- name: Setup Java
191-
uses: actions/setup-java@v3
192-
with:
193-
distribution: 'temurin'
194-
java-version: '11'
195-
196-
- name: Install dependencies
197-
run: |
198-
flutter pub get
199-
cd example && flutter pub get
200-
201-
- name: Create ProGuard rules for example app
202-
run: |
203-
cat > example/android/app/proguard-rules.pro << 'EOF'
204-
# Example app ProGuard rules for minification testing
205-
206-
# Keep example app classes
207-
-keep class com.optimizely.optimizely_flutter_sdk_example.** { *; }
208-
209-
# Keep Flutter classes
210-
-keep class io.flutter.app.** { *; }
211-
-keep class io.flutter.plugins.GeneratedPluginRegistrant { *; }
212-
213-
# Google Play Core (for Flutter engine)
214-
-keep class com.google.android.play.core.** { *; }
215-
-dontwarn com.google.android.play.core.**
216-
217-
# Additional safety for Optimizely (redundant but safe)
218-
-keep class com.optimizely.** { *; }
219-
-dontwarn com.optimizely.**
220-
221-
# Jackson JSON
222-
-keep class com.fasterxml.jackson.** { *; }
223-
-dontwarn com.fasterxml.jackson.**
224-
225-
# Ignore missing classes
226-
-dontwarn javax.mail.**
227-
-dontwarn javax.activation.**
228-
EOF
229-
230-
- name: Test with minification ENABLED
231-
run: |
232-
echo "🧪 Testing with minifyEnabled = true"
233-
234-
# Backup original build.gradle
235-
cp example/android/app/build.gradle example/android/app/build.gradle.backup
236-
237-
# Enable minification and ensure ProGuard rules are referenced
238-
sed -i 's/minifyEnabled false/minifyEnabled true/' example/android/app/build.gradle
239-
sed -i 's/shrinkResources false/shrinkResources true/' example/android/app/build.gradle
240-
241-
# Ensure ProGuard rules are applied
242-
if ! grep -q "proguardFiles.*proguard-rules.pro" example/android/app/build.gradle; then
243-
sed -i '/minifyEnabled true/a\ proguardFiles getDefaultProguardFile('\''proguard-android-optimize.txt'\''), '\''proguard-rules.pro'\''' example/android/app/build.gradle
244-
fi
245-
246-
echo "📄 Build configuration with minification:"
247-
grep -A 5 "buildTypes" example/android/app/build.gradle
248-
249-
# Build release APK
250-
cd example
251-
flutter build apk --release --verbose
252-
253-
echo "✅ Build successful with minification ENABLED"
254-
255-
- name: Test with minification DISABLED
256-
run: |
257-
echo "🧪 Testing with minifyEnabled = false"
258-
259-
# Restore original and disable minification
260-
cp example/android/app/build.gradle.backup example/android/app/build.gradle
261-
sed -i 's/minifyEnabled true/minifyEnabled false/' example/android/app/build.gradle
262-
sed -i 's/shrinkResources true/shrinkResources false/' example/android/app/build.gradle
263-
264-
echo "📄 Build configuration without minification:"
265-
grep -A 5 "buildTypes" example/android/app/build.gradle
266-
267-
# Clean and build again
268-
cd example
269-
flutter clean
270-
flutter build apk --release --verbose
271-
272-
echo "✅ Build successful with minification DISABLED"
273-
274-
- name: Run unit tests
275-
run: |
276-
echo "🧪 Running unit tests to verify SDK functionality"
277-
flutter test
278-
279-
- name: Verify APK artifacts
280-
run: |
281-
echo "📱 Checking APK files were created:"
282-
ls -la example/build/app/outputs/apk/release/
283-
284-
# Check APK size
285-
if [ -f "example/build/app/outputs/apk/release/app-release.apk" ]; then
286-
APK_SIZE=$(stat -c%s example/build/app/outputs/apk/release/app-release.apk 2>/dev/null || stat -f%z example/build/app/outputs/apk/release/app-release.apk)
287-
echo "📊 Final APK Size: $(($APK_SIZE / 1024 / 1024)) MB"
288-
fi
289-
290-
- name: Check for ProGuard artifacts
291-
run: |
292-
echo "🔍 Checking for ProGuard/R8 artifacts:"
293-
294-
# Look for mapping files
295-
if [ -f "example/build/app/outputs/mapping/release/mapping.txt" ]; then
296-
echo "✅ ProGuard mapping file found"
297-
echo "📄 Mapping file size: $(wc -l < example/build/app/outputs/mapping/release/mapping.txt) lines"
298-
else
299-
echo "ℹ️ No mapping file found (expected if minification was disabled)"
300-
fi
301-
302-
- name: Upload APK artifacts
303-
uses: actions/upload-artifact@v4
304-
with:
305-
name: minification-test-apk
306-
path: |
307-
example/build/app/outputs/apk/release/app-release.apk
308-
example/build/app/outputs/mapping/release/mapping.txt
309-
retention-days: 7
310-
311-
- name: Report test results
312-
run: |
313-
echo "🎉 Minification compatibility test completed successfully!"
314-
echo "✅ minifyEnabled = true: PASSED"
315-
echo "✅ minifyEnabled = false: PASSED"
316-
echo "✅ Your Optimizely Flutter SDK is minification-compatible!"
317-
echo ""
318-
echo "This confirms that:"
319-
echo " • Library ProGuard rules are working correctly"
320-
echo " • Plugin registration survives minification"
321-
echo " • No critical classes are being stripped"
322-
echo " • Customer's issue should be resolved"
323-
324-
- name: Cleanup
325-
if: always()
326-
run: |
327-
# Restore original build.gradle if backup exists
328-
if [ -f "example/android/app/build.gradle.backup" ]; then
329-
mv example/android/app/build.gradle.backup example/android/app/build.gradle
330-
echo "✅ Restored original build.gradle"
331-
fi
173+
- run: flutter test

.github/workflows/minification.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Minification Compatibility Test
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch: # Allow manual triggering
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: Install dependencies
32+
run: |
33+
flutter pub get
34+
cd example && flutter pub get
35+
36+
- name: Create ProGuard rules for example app
37+
run: |
38+
cat > example/android/app/proguard-rules.pro << 'EOF'
39+
# Example app ProGuard rules for minification testing
40+
41+
# Keep example app classes
42+
-keep class com.optimizely.optimizely_flutter_sdk_example.** { *; }
43+
44+
# Keep Flutter classes
45+
-keep class io.flutter.app.** { *; }
46+
-keep class io.flutter.plugins.GeneratedPluginRegistrant { *; }
47+
48+
# Google Play Core (for Flutter engine)
49+
-keep class com.google.android.play.core.** { *; }
50+
-dontwarn com.google.android.play.core.**
51+
52+
# Additional safety for Optimizely (redundant but safe)
53+
-keep class com.optimizely.** { *; }
54+
-dontwarn com.optimizely.**
55+
56+
# Jackson JSON
57+
-keep class com.fasterxml.jackson.** { *; }
58+
-dontwarn com.fasterxml.jackson.**
59+
60+
# Ignore missing classes
61+
-dontwarn javax.mail.**
62+
-dontwarn javax.activation.**
63+
EOF
64+
65+
- name: Test with minification ENABLED
66+
run: |
67+
echo "🧪 Testing with minifyEnabled = true"
68+
69+
# Backup original build.gradle
70+
cp example/android/app/build.gradle example/android/app/build.gradle.backup
71+
72+
# Enable minification and ensure ProGuard rules are referenced
73+
sed -i 's/minifyEnabled false/minifyEnabled true/' example/android/app/build.gradle
74+
sed -i 's/shrinkResources false/shrinkResources true/' example/android/app/build.gradle
75+
76+
# Ensure ProGuard rules are applied
77+
if ! grep -q "proguardFiles.*proguard-rules.pro" example/android/app/build.gradle; then
78+
sed -i '/minifyEnabled true/a\ proguardFiles getDefaultProguardFile('\''proguard-android-optimize.txt'\''), '\''proguard-rules.pro'\''' example/android/app/build.gradle
79+
fi
80+
81+
echo "📄 Build configuration with minification:"
82+
grep -A 5 "buildTypes" example/android/app/build.gradle
83+
84+
# Build release APK
85+
cd example
86+
flutter build apk --release
87+
88+
echo "✅ Build successful with minification ENABLED"
89+
90+
- name: Test with minification DISABLED
91+
run: |
92+
echo "🧪 Testing with minifyEnabled = false"
93+
94+
# Restore original and disable minification
95+
cp example/android/app/build.gradle.backup example/android/app/build.gradle
96+
sed -i 's/minifyEnabled true/minifyEnabled false/' example/android/app/build.gradle
97+
sed -i 's/shrinkResources true/shrinkResources false/' example/android/app/build.gradle
98+
99+
echo "📄 Build configuration without minification:"
100+
grep -A 5 "buildTypes" example/android/app/build.gradle
101+
102+
# Clean and build again
103+
cd example
104+
flutter clean
105+
flutter build apk --release
106+
107+
echo "✅ Build successful with minification DISABLED"
108+
109+
- name: Run unit tests
110+
run: |
111+
echo "🧪 Running unit tests to verify SDK functionality"
112+
flutter test
113+
114+
- name: Verify APK artifacts
115+
run: |
116+
echo "📱 Checking APK files were created:"
117+
ls -la example/build/app/outputs/apk/release/
118+
119+
# Check APK size
120+
if [ -f "example/build/app/outputs/apk/release/app-release.apk" ]; then
121+
APK_SIZE=$(stat -c%s example/build/app/outputs/apk/release/app-release.apk 2>/dev/null || stat -f%z example/build/app/outputs/apk/release/app-release.apk)
122+
echo "📊 Final APK Size: $(($APK_SIZE / 1024 / 1024)) MB"
123+
fi
124+
125+
- name: Check for ProGuard artifacts
126+
run: |
127+
echo "🔍 Checking for ProGuard/R8 artifacts:"
128+
129+
# Look for mapping files
130+
if [ -f "example/build/app/outputs/mapping/release/mapping.txt" ]; then
131+
echo "✅ ProGuard mapping file found"
132+
echo "📄 Mapping file size: $(wc -l < example/build/app/outputs/mapping/release/mapping.txt) lines"
133+
else
134+
echo "ℹ️ No mapping file found (expected if minification was disabled)"
135+
fi
136+
137+
- name: Upload APK artifacts
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: minification-test-apk
141+
path: |
142+
example/build/app/outputs/apk/release/app-release.apk
143+
example/build/app/outputs/mapping/release/mapping.txt
144+
retention-days: 7
145+
146+
- name: Report test results
147+
run: |
148+
echo "🎉 Minification compatibility test completed successfully!"
149+
echo "✅ minifyEnabled = true: PASSED"
150+
echo "✅ minifyEnabled = false: PASSED"
151+
echo "✅ Your Optimizely Flutter SDK is minification-compatible!"
152+
echo ""
153+
echo "This confirms that:"
154+
echo " • Library ProGuard rules are working correctly"
155+
echo " • Plugin registration survives minification"
156+
echo " • No critical classes are being stripped"
157+
echo " • Customer's issue should be resolved"
158+
159+
- name: Cleanup
160+
if: always()
161+
run: |
162+
# Restore original build.gradle if backup exists
163+
if [ -f "example/android/app/build.gradle.backup" ]; then
164+
mv example/android/app/build.gradle.backup example/android/app/build.gradle
165+
echo "✅ Restored original build.gradle"
166+
fi

0 commit comments

Comments
 (0)