-
-
Notifications
You must be signed in to change notification settings - Fork 277
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 # pin@v2.21.0 | ||
| 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 # pin@v2.21.0 | ||
| 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 }}" | ||
|
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. same comment as for android. let's debug this. |
||
| "--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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package io.sentry.samples.flutter | ||
| package io.sentry.flutter.sample | ||
|
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: 🔍 Detailed AnalysisThe 💡 Suggested FixEither move 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. 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. this is real
Contributor
Author
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. yup, haven't gotten to fixing this yet |
||
|
|
||
| import android.os.Handler | ||
| import io.flutter.embedding.android.FlutterActivity | ||
|
|
||
| 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) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
you shouldn't need to set
head-sha,head-repo-name,head-ref,base-ref,base-shaorpr-numberin github actions as they will be automatically fetched. were you having issue with this? I'd love to debug if it wasn't working.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.
haven't tried without tbh, this is mostly cursor code :D
I'll remove it and re-run