-
-
Notifications
You must be signed in to change notification settings - Fork 278
Add ci workflow for app size analysis #3368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ef39693
8425109
83b9a61
e3a5a47
b7ef080
9872f07
ac4fd03
9b0ab2f
806dd0b
1b45278
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| name: Size Analysis | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| SENTRY_ORG: sentry-sdks | ||
| SENTRY_PROJECT: sentry-flutter | ||
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
|
|
||
| jobs: | ||
| android: | ||
| name: Android | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| defaults: | ||
| run: | ||
| working-directory: packages/flutter/example | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'adopt' | ||
| java-version: '17' | ||
|
|
||
| - name: Read configured Flutter SDK version | ||
| id: conf | ||
| run: | | ||
| version=$(grep "version" ../../../metrics/flutter.properties | cut -d'=' -f2 | xargs) | ||
| echo "flutter=$version" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Install Flutter v${{ steps.conf.outputs.flutter }} | ||
| uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # [email protected] | ||
| with: | ||
| flutter-version: ${{ steps.conf.outputs.flutter }} | ||
|
|
||
| - name: Install Sentry CLI | ||
| if: env.SENTRY_AUTH_TOKEN != '' | ||
| run: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.58.2 sh | ||
|
|
||
| - name: Determine build version | ||
| run: | | ||
| version_line=$(grep '^version:' pubspec.yaml | awk '{print $2}') | ||
| # Remove any + suffix first (for pubspec.yaml versions like 1.2.3+4) | ||
| version=${version_line%%+*} | ||
|
|
||
| # Parse version: x.y.z-suffix.n → build_name=x.y.z, build_number=n | ||
| # Supports: x.y.z, x.y.z-alpha.n, x.y.z-beta.n, x.y.z-rc.n, etc. | ||
| # Note: build_name is x.y.z only (plist/Android compatibility) | ||
| if [[ $version =~ ^([0-9]+\.[0-9]+\.[0-9]+)-[a-zA-Z]+\.([0-9]+)$ ]]; then | ||
| build_name="${BASH_REMATCH[1]}" | ||
| build_number="${BASH_REMATCH[2]}" | ||
| elif [[ $version =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then | ||
| build_name="${BASH_REMATCH[1]}" | ||
| build_number=1 | ||
| else | ||
| build_name="$version" | ||
| build_number=1 | ||
| fi | ||
|
|
||
| echo "SIZE_VERSION=$build_name" >> "$GITHUB_ENV" | ||
| echo "SIZE_BUILD=$build_number" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Get merge base SHA | ||
| id: merge-base | ||
| if: env.SENTRY_AUTH_TOKEN != '' | ||
| run: | | ||
| if [ "${{ github.event_name }}" == "pull_request" ]; then | ||
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
| else | ||
| BASE_SHA=$(git merge-base HEAD origin/main || echo "${{ github.event.before }}") | ||
| fi | ||
| echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build Android Appbundle | ||
| run: | | ||
| flutter pub get | ||
| flutter build appbundle --release \ | ||
| --build-name "$SIZE_VERSION" \ | ||
| --build-number "$SIZE_BUILD" | ||
|
|
||
| - name: Upload Android Bundle to Sentry Size Analysis | ||
| if: env.SENTRY_AUTH_TOKEN != '' | ||
| run: | | ||
| UPLOAD_ARGS=( | ||
| "build/app/outputs/bundle/release/app-release.aab" | ||
| "--org" "${{ env.SENTRY_ORG }}" | ||
| "--project" "${{ env.SENTRY_PROJECT }}" | ||
| "--build-configuration" "Release" | ||
| "--head-sha" "${{ github.event.pull_request.head.sha || github.sha }}" | ||
| "--head-repo-name" "${{ github.repository }}" | ||
| "--head-ref" "${{ github.head_ref || github.ref_name }}" | ||
| "--base-ref" "${{ github.base_ref || 'main' }}" | ||
| ) | ||
|
|
||
| if [ -n "${{ steps.merge-base.outputs.sha }}" ]; then | ||
| UPLOAD_ARGS+=("--base-sha" "${{ steps.merge-base.outputs.sha }}") | ||
| fi | ||
|
|
||
| if [ -n "${{ github.event.pull_request.number }}" ]; then | ||
| UPLOAD_ARGS+=("--pr-number" "${{ github.event.pull_request.number }}") | ||
| fi | ||
|
|
||
| sentry-cli build upload "${UPLOAD_ARGS[@]}" | ||
|
|
||
| ios: | ||
| name: iOS | ||
| runs-on: macos-15 | ||
| timeout-minutes: 45 | ||
| defaults: | ||
| run: | ||
| working-directory: packages/flutter/example | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Read configured Flutter SDK version | ||
| id: conf | ||
| run: | | ||
| version=$(grep "version" ../../../metrics/flutter.properties | cut -d'=' -f2 | xargs) | ||
| echo "flutter=$version" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Install Flutter v${{ steps.conf.outputs.flutter }} | ||
| uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # [email protected] | ||
| with: | ||
| flutter-version: ${{ steps.conf.outputs.flutter }} | ||
|
|
||
| - name: Install Sentry CLI | ||
| if: env.SENTRY_AUTH_TOKEN != '' | ||
| run: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.58.2 sh | ||
|
|
||
| - name: Determine build version | ||
| run: | | ||
| version_line=$(grep '^version:' pubspec.yaml | awk '{print $2}') | ||
| # Remove any + suffix first (for pubspec.yaml versions like 1.2.3+4) | ||
| version=${version_line%%+*} | ||
|
|
||
| # Parse version: x.y.z-suffix.n → build_name=x.y.z, build_number=n | ||
| # Supports: x.y.z, x.y.z-alpha.n, x.y.z-beta.n, x.y.z-rc.n, etc. | ||
| # Note: build_name is x.y.z only (plist/Android compatibility) | ||
| if [[ $version =~ ^([0-9]+\.[0-9]+\.[0-9]+)-[a-zA-Z]+\.([0-9]+)$ ]]; then | ||
| build_name="${BASH_REMATCH[1]}" | ||
| build_number="${BASH_REMATCH[2]}" | ||
| elif [[ $version =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then | ||
| build_name="${BASH_REMATCH[1]}" | ||
| build_number=1 | ||
| else | ||
| build_name="$version" | ||
| build_number=1 | ||
| fi | ||
|
|
||
| echo "SIZE_VERSION=$build_name" >> "$GITHUB_ENV" | ||
| echo "SIZE_BUILD=$build_number" >> "$GITHUB_ENV" | ||
|
|
||
| # QuickFix for failing iOS 18.0 builds https://github.com/actions/runner-images/issues/12758#issuecomment-3187115656 | ||
| - name: Switch to Xcode 16.4 for iOS 18.5 | ||
| run: sudo xcode-select --switch /Applications/Xcode_16.4.app | ||
|
|
||
| - name: Build Flutter iOS | ||
| run: | | ||
| flutter pub get | ||
| flutter build ipa --release --no-codesign \ | ||
| --build-name "$SIZE_VERSION" \ | ||
| --build-number "$SIZE_BUILD" | ||
|
|
||
| - name: Get merge base SHA | ||
| id: merge-base | ||
| if: env.SENTRY_AUTH_TOKEN != '' | ||
| run: | | ||
| if [ "${{ github.event_name }}" == "pull_request" ]; then | ||
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | ||
| else | ||
| BASE_SHA=$(git merge-base HEAD origin/main || echo "${{ github.event.before }}") | ||
| fi | ||
| echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Upload iOS XCArchive to Sentry Size Analysis | ||
| if: env.SENTRY_AUTH_TOKEN != '' | ||
| run: | | ||
| UPLOAD_ARGS=( | ||
| "build/ios/archive/Runner.xcarchive" | ||
| "--org" "${{ env.SENTRY_ORG }}" | ||
| "--project" "${{ env.SENTRY_PROJECT }}" | ||
| "--build-configuration" "Release" | ||
| "--head-sha" "${{ github.event.pull_request.head.sha || github.sha }}" | ||
| "--head-repo-name" "${{ github.repository }}" | ||
| "--head-ref" "${{ github.head_ref || github.ref_name }}" | ||
| "--base-ref" "${{ github.base_ref || 'main' }}" | ||
| ) | ||
|
|
||
| if [ -n "${{ steps.merge-base.outputs.sha }}" ]; then | ||
| UPLOAD_ARGS+=("--base-sha" "${{ steps.merge-base.outputs.sha }}") | ||
| fi | ||
|
|
||
| if [ -n "${{ github.event.pull_request.number }}" ]; then | ||
| UPLOAD_ARGS+=("--pr-number" "${{ github.event.pull_request.number }}") | ||
| fi | ||
|
|
||
| sentry-cli build upload "${UPLOAD_ARGS[@]}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| -keep class io.sentry.samples.flutter.** { *; } | ||
| -keep class io.sentry.flutter.sample.** { *; } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,9 +243,9 @@ const _jvmStackTrace = | |
| at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:292) | ||
| at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:59) | ||
| at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler\$1.success(MethodChannel.java:267) | ||
| at io.sentry.samples.flutter.MainActivity.configureFlutterEngine\$lambda-0(MainActivity.kt:40) | ||
| at io.sentry.samples.flutter.MainActivity.lambda\$TiSaAm1LIEmKLVswI4BlR_5sw5Y(Unknown Source:0) | ||
| at io.sentry.samples.flutter.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2) | ||
| at io.sentry.flutter.sample.MainActivity.configureFlutterEngine\$lambda-0(MainActivity.kt:40) | ||
| at io.sentry.flutter.sample.MainActivity.lambda\$TiSaAm1LIEmKLVswI4BlR_5sw5Y(Unknown Source:0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Old package ID 🔍 Detailed AnalysisThe old package ID 💡 Suggested FixUpdate all remaining references of 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| at io.sentry.flutter.sample.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2) | ||
| at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) | ||
| at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296) | ||
| at io.flutter.embedding.engine.dart.DartMessenger.lambda\$dispatchMessageToQueue\$0\$DartMessenger(DartMessenger.java:320) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
MainActivity.ktpackage declarationio.sentry.flutter.samplemismatches its directoryio/sentry/samples/flutter/.Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The
MainActivity.ktfile's package declarationio.sentry.flutter.sampledoes not match its physical directory structureio/sentry/samples/flutter/. This fundamental mismatch will cause the Kotlin compiler to reject the code, leading to an immediate failure of the Android build step in the CI workflow. This prevents the successful creation of the Android AAB artifact.💡 Suggested Fix
Either move
MainActivity.kttoio/sentry/flutter/sample/or revert its package declaration toio.sentry.samples.flutter.🤖 Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:
4268466