andr: stop including non bd capture related dependencies in generated… #4437
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: android | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| # Cancel in-progress CI jobs when a new commit is pushed to a PR. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| actions: write | |
| contents: write | |
| pull-requests: write | |
| statuses: write | |
| jobs: | |
| pre_check: | |
| name: pre_check | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_run: ${{ steps.check_changes.outputs.run_tests }} | |
| steps: | |
| # Checkout repo to Github Actions runner | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Check for Bazel build file changes | |
| - name: Check for Bazel build file changes | |
| id: bazel_check | |
| run: ./ci/check_bazel.sh //examples/android:android_app | |
| continue-on-error: true | |
| - name: Check for workflow file changes | |
| id: workflow_check | |
| run: ./ci/files_changed.sh .github/workflows/android.yaml MODULE.bazel MODULE.bazel.lock | |
| continue-on-error: true | |
| - name: Check for relevant Gradle changes | |
| id: gradle_check | |
| run: ./ci/files_changed.sh "^platform/jvm/gradle-test-app/.*\.(gradle|kts|kt|xml)$" && ./ci/files_changed.sh "^platform/jvm/capture/src/test/.*$" | |
| continue-on-error: true | |
| - name: Check for Cargo.toml changes | |
| id: cargo_check | |
| run: ./ci/files_changed.sh Cargo.toml | |
| continue-on-error: true | |
| - name: Determine if tests should run | |
| id: check_changes_separate | |
| run: | | |
| bazel_status="${{ steps.bazel_check.outputs.check_result }}" | |
| workflow_status="${{ steps.workflow_check.outputs.check_result }}" | |
| gradle_status="${{ steps.gradle_check.outputs.check_result }}" | |
| cargo_status="${{ steps.cargo_check.outputs.check_result }}" | |
| # Check if any status indicates a relevant change or error | |
| if [[ "$bazel_status" == "1" || "$workflow_status" == "1" || "$gradle_status" == "1" || "$cargo_status" == "1" ]]; then | |
| echo "An unexpected issue occurred during checks." | |
| exit 1 | |
| elif [[ "$bazel_status" == "0" || "$workflow_status" == "0" || "$gradle_status" == "0" || "$cargo_status" == "0" ]]; then | |
| echo "Changes detected in one or more checks. Running tests." | |
| echo "run_tests=true" >> $GITHUB_ENV | |
| elif [[ "$bazel_status" == "2" && "$workflow_status" == "2" && "$gradle_status" == "2" && "$cargo_status" == "2" ]]; then | |
| echo "No relevant changes found." | |
| echo "run_tests=false" >> $GITHUB_ENV | |
| else | |
| echo "Unknown issue." | |
| exit 1 | |
| fi | |
| shell: bash | |
| - name: Run downstream tests if changes are detected | |
| id: check_changes | |
| if: env.run_tests == 'true' | |
| run: ./ci/run_tests.sh | |
| build_and_compare_sizes: | |
| runs-on: ubuntu-latest | |
| if: needs.pre_check.outputs.should_run == 'true' | |
| needs: pre_check | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Bazel | |
| uses: bazel-contrib/setup-bazel@0.15.0 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }} | |
| repository-cache: true | |
| - name: Cache llvm-strip Installation | |
| uses: actions/cache@v4 | |
| id: llvm-cache | |
| with: | |
| path: ${{ runner.temp }}/llvm-bin | |
| key: llvm-strip-${{ runner.os }} | |
| - name: Populate llvm-strip cache if missing | |
| if: steps.llvm-cache.outputs.cache-hit != 'true' | |
| run: | | |
| set -euo pipefail | |
| mkdir -p "$RUNNER_TEMP/llvm-bin" | |
| if command -v llvm-strip &> /dev/null; then | |
| cp -f "$(command -v llvm-strip)" "$RUNNER_TEMP/llvm-bin/" | |
| else | |
| sudo apt update && sudo apt install -y llvm | |
| cp -f "$(command -v llvm-strip)" "$RUNNER_TEMP/llvm-bin/" | |
| fi | |
| - name: Add llvm-strip to PATH | |
| run: echo "$RUNNER_TEMP/llvm-bin" >> $GITHUB_PATH | |
| - name: Install llvm-strip if needed | |
| if: steps.llvm-cache.outputs.cache-hit != 'true' | |
| run: | | |
| if command -v llvm-strip &> /dev/null; then | |
| echo "llvm-strip is already installed." | |
| else | |
| echo "llvm-strip not found. Installing now..." | |
| sudo apt update && sudo apt install -y llvm | |
| fi | |
| - name: Verify llvm-strip version | |
| run: llvm-strip --version | |
| - name: Build Bazel APK and AAR | |
| timeout-minutes: 30 | |
| run: | | |
| # Build APK for x86_64 (this also builds the AAR dependency) | |
| ./bazelw build --config ci --config release-android --android_platforms=@rules_android//:x86_64 //examples/android:android_app | |
| # Build AAR for x86_64 to match the APK architecture and reuse build artifacts | |
| ./bazelw build :capture_aar --config ci --config release-android --android_platforms=@rules_android//:x86_64 | |
| - name: Upload PR APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android_app.apk | |
| path: ./bazel-bin/examples/android/android_app.apk | |
| - name: Save size baselines and push to branch (main only) | |
| if: github.ref == 'refs/heads/main' && success() | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Get APK size | |
| APK_PATH=$(find bazel-bin/examples/android -name "android_app.apk" | head -n 1) | |
| APK_SIZE_FILE=ci/baseline_binary_size.txt | |
| stat -c%s "$APK_PATH" > "$APK_SIZE_FILE" | |
| # Get AAR SO size | |
| ./tools/capture_so_size.sh x86_64 > so_size_output.txt | |
| SO_SIZE_KB=$(grep "SO_SIZE_KB=" so_size_output.txt | cut -d'=' -f2) | |
| SO_SIZE_FILE=ci/baseline_so_size_x86_64_kb.txt | |
| echo "$SO_SIZE_KB" > "$SO_SIZE_FILE" | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@users.noreply.github.com" | |
| git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
| git fetch origin ci-baseline | |
| git worktree add temp-worktree origin/ci-baseline | |
| cp "$APK_SIZE_FILE" temp-worktree/ci/ | |
| cp "$SO_SIZE_FILE" temp-worktree/ci/ | |
| cd temp-worktree | |
| git add ci/baseline_binary_size.txt ci/baseline_so_size_x86_64_kb.txt | |
| if ! git diff --cached --quiet; then | |
| git commit -m "ci: update APK and AAR SO size baselines [skip ci]" | |
| git push origin HEAD:ci-baseline | |
| else | |
| echo "No changes to baseline sizes." | |
| fi | |
| cd .. | |
| git worktree remove temp-worktree --force | |
| - name: Fetch size baselines from branch (PR only) | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| run: | | |
| git fetch origin ci-baseline | |
| git worktree add temp-baseline origin/ci-baseline | |
| cp temp-baseline/ci/baseline_binary_size.txt ci/ | |
| if [ -f temp-baseline/ci/baseline_so_size_x86_64_kb.txt ]; then | |
| cp temp-baseline/ci/baseline_so_size_x86_64_kb.txt ci/ | |
| fi | |
| git worktree remove temp-baseline --force | |
| - name: Compute and compare APK size | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| id: apk_size | |
| run: | | |
| APK_PATH=$(find bazel-bin/examples/android -name "android_app.apk" | head -n 1) | |
| BASELINE_PATH=ci/baseline_binary_size.txt | |
| if [ -z "$APK_PATH" ]; then | |
| echo "Current APK file not found!" | |
| exit 1 | |
| fi | |
| CURRENT_SIZE=$(stat -c%s "$APK_PATH") | |
| CURRENT_KB=$((CURRENT_SIZE / 1024)) | |
| echo "current_kb=$CURRENT_KB" >> $GITHUB_OUTPUT | |
| if [ ! -f "$BASELINE_PATH" ]; then | |
| echo "baseline_kb=" >> $GITHUB_OUTPUT | |
| echo "diff_kb=" >> $GITHUB_OUTPUT | |
| else | |
| BASELINE_SIZE=$(cat "$BASELINE_PATH") | |
| BASELINE_KB=$((BASELINE_SIZE / 1024)) | |
| DIFF_KB=$((CURRENT_KB - BASELINE_KB)) | |
| echo "baseline_kb=$BASELINE_KB" >> $GITHUB_OUTPUT | |
| echo "diff_kb=$DIFF_KB" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Compute and compare AAR SO size | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| id: so_size | |
| run: | | |
| # Run the capture_so_size script to get the current SO size | |
| ./tools/capture_so_size.sh x86_64 > so_size_output.txt | |
| SO_SIZE_KB=$(grep "SO_SIZE_KB=" so_size_output.txt | cut -d'=' -f2) | |
| BASELINE_PATH=ci/baseline_so_size_x86_64_kb.txt | |
| if [ -z "$SO_SIZE_KB" ]; then | |
| echo "Current SO size not found!" | |
| exit 1 | |
| fi | |
| echo "current_kb=$SO_SIZE_KB" >> $GITHUB_OUTPUT | |
| if [ ! -f "$BASELINE_PATH" ]; then | |
| echo "baseline_kb=" >> $GITHUB_OUTPUT | |
| echo "diff_kb=" >> $GITHUB_OUTPUT | |
| else | |
| BASELINE_KB=$(cat "$BASELINE_PATH") | |
| DIFF_KB=$((SO_SIZE_KB - BASELINE_KB)) | |
| echo "baseline_kb=$BASELINE_KB" >> $GITHUB_OUTPUT | |
| echo "diff_kb=$DIFF_KB" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Report sizes on PR | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| continue-on-error: true | |
| uses: actions/github-script@v6 | |
| env: | |
| APK_CURRENT_KB: ${{ steps.apk_size.outputs.current_kb }} | |
| APK_BASELINE_KB: ${{ steps.apk_size.outputs.baseline_kb }} | |
| APK_DIFF_KB: ${{ steps.apk_size.outputs.diff_kb }} | |
| SO_CURRENT_KB: ${{ steps.so_size.outputs.current_kb }} | |
| SO_BASELINE_KB: ${{ steps.so_size.outputs.baseline_kb }} | |
| SO_DIFF_KB: ${{ steps.so_size.outputs.diff_kb }} | |
| with: | |
| script: | | |
| const apkCurrent = process.env.APK_CURRENT_KB; | |
| const apkBaseline = process.env.APK_BASELINE_KB; | |
| const apkDiff = process.env.APK_DIFF_KB; | |
| const soCurrent = process.env.SO_CURRENT_KB; | |
| const soBaseline = process.env.SO_BASELINE_KB; | |
| const soDiff = process.env.SO_DIFF_KB; | |
| let body = '## Size Comparison Report (x86_64)\n\n'; | |
| // Combined table for both APK and SO sizes | |
| if ((apkBaseline && apkBaseline !== '') || (soBaseline && soBaseline !== '')) { | |
| body += ` | |
| | Metric | APK (KB) | SO (KB) | | |
| |------------|-----------|---------|`; | |
| if (apkBaseline && apkBaseline !== '') { | |
| body += ` | |
| | Baseline | ${apkBaseline} | ${soBaseline || 'N/A'} |`; | |
| } | |
| body += ` | |
| | Current | ${apkCurrent} | ${soCurrent} | | |
| | Difference | ${apkDiff || 'N/A'} | ${soDiff || 'N/A'} | | |
| `; | |
| // Summary for APK | |
| if (apkBaseline && apkBaseline !== '') { | |
| if (parseInt(apkDiff, 10) > 0) { | |
| body += `\n> APK size increased by ${apkDiff} KB.`; | |
| } else if (parseInt(apkDiff, 10) < 0) { | |
| body += `\n> APK size decreased by ${Math.abs(apkDiff)} KB.`; | |
| } else { | |
| body += `\n> APK size unchanged.`; | |
| } | |
| } | |
| // Summary for SO | |
| if (soBaseline && soBaseline !== '') { | |
| if (parseInt(soDiff, 10) > 0) { | |
| body += ` SO size increased by ${soDiff} KB.`; | |
| } else if (parseInt(soDiff, 10) < 0) { | |
| body += ` SO size decreased by ${Math.abs(soDiff)} KB.`; | |
| } else { | |
| body += ` SO size unchanged.`; | |
| } | |
| } | |
| } else { | |
| body += `Current sizes: APK ${apkCurrent} KB, SO ${soCurrent} KB (No baselines available for comparison).`; | |
| } | |
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| }); | |
| const foundComment = comments.data.find((x) => x.user.login === 'github-actions[bot]'); | |
| const comment = { | |
| issue_number: context.payload.pull_request.number, | |
| comment_id: foundComment?.id, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body, | |
| }; | |
| if (foundComment?.id) { | |
| await github.rest.issues.updateComment(comment); | |
| } else { | |
| await github.rest.issues.createComment(comment); | |
| } | |
| gradle_tests: | |
| # Requires a "larger runner", for nested virtualization support | |
| runs-on: ubuntu-latest-8-cores | |
| env: | |
| SKIP_PROTO_GEN: 1 | |
| if: needs.pre_check.outputs.should_run == 'true' | |
| needs: pre_check | |
| steps: | |
| - name: Checkout project sources | |
| uses: actions/checkout@v4 | |
| - name: Setup Android cmd line tools + NDK | |
| uses: ./.github/actions/common-android-setup | |
| with: | |
| setup-emulator: 'true' | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: ${{ runner.os }}-avd-api-23-2 | |
| - name: Create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| timeout-minutes: 30 | |
| uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # pin@v2.35.0 | |
| with: | |
| channel: stable | |
| force-avd-creation: false | |
| api-level: 23 | |
| target: default | |
| ram-size: 2048M | |
| arch: x86_64 | |
| disk-size: 6144M | |
| profile: Nexus 6 | |
| disable-animations: true | |
| emulator-options: -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: Gradle capture-timber unit tests | |
| working-directory: ./platform/jvm | |
| run: ./gradlew capture-timber:testReleaseUnitTest --info | |
| - name: Gradle capture-plugin unit tests | |
| working-directory: ./platform/jvm | |
| run: ./gradlew capture-plugin:test --info | |
| - name: Check Licenses for modules | |
| working-directory: ./platform/jvm | |
| run: ./gradlew replay:checkLicense common:checkLicense capture:checkLicense | |
| - name: Build Microbenchmark target | |
| working-directory: ./platform/jvm | |
| run: ./gradlew microbenchmark:assembleAndroidTest | |
| - name: Instrumentation Tests | |
| uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # pin@v2.35.0 | |
| with: | |
| channel: stable | |
| force-avd-creation: false | |
| api-level: 23 | |
| target: default | |
| ram-size: 2048M | |
| arch: x86_64 | |
| disk-size: 6144M | |
| profile: Nexus 6 | |
| disable-animations: true | |
| emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: cd platform/jvm && adb uninstall io.bitdrift.gradletestapp.test; adb uninstall io.bitdrift.gradletestapp; cd ../.. && ./tools/android_sdk_wrapper.sh platform/jvm/gradlew -Prust-target=x86_64 -p platform/jvm gradle-test-app:check gradle-test-app:connectedCheck --stacktrace | |
| run_android_benchmarks: | |
| runs-on: ubuntu-latest-8-cores | |
| continue-on-error: true | |
| env: | |
| SKIP_PROTO_GEN: 1 | |
| if: needs.pre_check.outputs.should_run == 'true' | |
| needs: pre_check | |
| steps: | |
| - name: Checkout project sources | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Android cmd line tools + NDK | |
| uses: ./.github/actions/common-android-setup | |
| with: | |
| setup-emulator: 'true' | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: ${{ runner.os }}-avd-api31-benchmark | |
| - name: Create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| timeout-minutes: 30 | |
| uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # pin@v2.35.0 | |
| with: | |
| channel: stable | |
| force-avd-creation: false | |
| api-level: 31 | |
| target: default | |
| ram-size: 2048M | |
| arch: x86_64 | |
| disk-size: 6144M | |
| profile: Nexus 6 | |
| disable-animations: true | |
| emulator-options: -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: Run Microbenchmarks | |
| uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # pin@v2.35.0 | |
| timeout-minutes: 30 | |
| with: | |
| channel: stable | |
| force-avd-creation: false | |
| api-level: 31 | |
| target: default | |
| ram-size: 2048M | |
| arch: x86_64 | |
| disk-size: 6144M | |
| profile: Nexus 6 | |
| disable-animations: true | |
| emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: ./tools/android_sdk_wrapper.sh platform/jvm/gradlew -Prust-target=x86_64 -p platform/jvm microbenchmark:connectedReleaseAndroidTest -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.suppressErrors=EMULATOR,UNLOCKED --stacktrace | |
| - name: Find benchmark JSON | |
| id: find_benchmark | |
| run: | | |
| BENCHMARK_JSON=$(find platform/jvm/microbenchmark/build/outputs -name "*benchmarkData.json" -type f | head -n 1) | |
| if [ -z "$BENCHMARK_JSON" ]; then | |
| echo "No benchmark JSON file found!" | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Found benchmark file: $BENCHMARK_JSON" | |
| echo "found=true" >> $GITHUB_OUTPUT | |
| echo "path=$BENCHMARK_JSON" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Save benchmark baseline (main only) | |
| if: github.ref == 'refs/heads/main' && steps.find_benchmark.outputs.found == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BENCHMARK_JSON="${{ steps.find_benchmark.outputs.path }}" | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@users.noreply.github.com" | |
| git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
| git fetch origin ci-baseline || true | |
| git worktree add temp-worktree origin/ci-baseline | |
| cp "$BENCHMARK_JSON" temp-worktree/ci/android_benchmark_baseline.json | |
| cd temp-worktree | |
| git add ci/android_benchmark_baseline.json | |
| if ! git diff --cached --quiet; then | |
| git commit -m "ci: update benchmark baseline [skip ci]" | |
| git push origin HEAD:ci-baseline | |
| else | |
| echo "No changes to benchmark baseline." | |
| fi | |
| cd .. | |
| git worktree remove temp-worktree --force | |
| - name: Fetch benchmark baseline (PR only) | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| id: fetch_baseline | |
| run: | | |
| git fetch origin ci-baseline || true | |
| git worktree add temp-baseline origin/ci-baseline || true | |
| echo "Checking for baseline file..." | |
| ls -la temp-baseline/ci/ || echo "Could not list temp-baseline/ci/" | |
| if [ -f temp-baseline/ci/android_benchmark_baseline.json ]; then | |
| echo "Found baseline file, copying..." | |
| cp temp-baseline/ci/android_benchmark_baseline.json ci/android_benchmark_baseline.json | |
| echo "found=true" >> $GITHUB_OUTPUT | |
| echo "Baseline found and copied." | |
| else | |
| echo "No benchmark baseline found." | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| fi | |
| git worktree remove temp-baseline --force || true | |
| - name: Parse and compare benchmark results | |
| if: github.event_name == 'pull_request' && steps.find_benchmark.outputs.found == 'true' | |
| id: benchmark_results | |
| run: | | |
| BENCHMARK_JSON="${{ steps.find_benchmark.outputs.path }}" | |
| BASELINE_JSON="" | |
| echo "fetch_baseline.outputs.found = '${{ steps.fetch_baseline.outputs.found }}'" | |
| if [ "${{ steps.fetch_baseline.outputs.found }}" == "true" ]; then | |
| BASELINE_JSON="ci/android_benchmark_baseline.json" | |
| echo "Using baseline: $BASELINE_JSON" | |
| else | |
| echo "No baseline found, running without comparison" | |
| fi | |
| # Parse and format the benchmark results using Python | |
| if [ -n "$BASELINE_JSON" ]; then | |
| python3 ./ci/parse_benchmark_results.py "$BENCHMARK_JSON" "$BASELINE_JSON" > benchmark_report.md | |
| else | |
| python3 ./ci/parse_benchmark_results.py "$BENCHMARK_JSON" > benchmark_report.md | |
| fi | |
| echo "Generated report:" | |
| cat benchmark_report.md | |
| # Store the report for the PR comment (handle multiline) | |
| { | |
| echo 'benchmark_report<<EOF' | |
| cat benchmark_report.md | |
| echo 'EOF' | |
| } >> $GITHUB_OUTPUT | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: | | |
| platform/jvm/microbenchmark/build/outputs/connected_android_test_additional_output/ | |
| benchmark_report.md | |
| if: always() | |
| - name: Report benchmarks on PR | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| continue-on-error: true | |
| uses: actions/github-script@v6 | |
| env: | |
| BENCHMARK_REPORT: ${{ steps.benchmark_results.outputs.benchmark_report }} | |
| with: | |
| script: | | |
| const benchmarkReport = process.env.BENCHMARK_REPORT; | |
| let body = '## Android Benchmark Results\n\n'; | |
| body += benchmarkReport || 'No benchmark data available.'; | |
| // Look for existing benchmark comment to update | |
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| }); | |
| const markerText = '## Android Benchmark Results'; | |
| const foundComment = comments.data.find((c) => | |
| c.user.login === 'github-actions[bot]' && c.body.includes(markerText) | |
| ); | |
| const comment = { | |
| issue_number: context.payload.pull_request.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body, | |
| }; | |
| if (foundComment?.id) { | |
| comment.comment_id = foundComment.id; | |
| await github.rest.issues.updateComment(comment); | |
| } else { | |
| await github.rest.issues.createComment(comment); | |
| } | |
| verify_android_hello_world_per_version: | |
| needs: build_and_compare_sizes | |
| runs-on: ubuntu-latest-8-cores | |
| strategy: | |
| matrix: | |
| api-level: [24, 35] | |
| steps: | |
| # Checkout repo to Github Actions runner | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # See https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/ | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: android_app.apk | |
| path: . | |
| - name: AVD cache | |
| uses: actions/cache@v3 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: ${{ runner.os }}-avd-api${{ matrix.api-level }}-1 | |
| - name: Create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| timeout-minutes: 30 | |
| uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # pin@v2.35.0 | |
| with: | |
| channel: stable | |
| api-level: ${{ matrix.api-level }} | |
| target: google_apis | |
| ram-size: 2048M | |
| arch: x86_64 | |
| disk-size: 6144M | |
| profile: Nexus 6 | |
| emulator-options: -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: run tests | |
| uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # pin@v2.35.0 | |
| timeout-minutes: 15 | |
| with: | |
| force-avd-creation: false | |
| channel: stable | |
| api-level: ${{ matrix.api-level }} | |
| target: google_apis | |
| ram-size: 2048M | |
| arch: x86_64 | |
| disk-size: 6144M | |
| profile: Nexus 6 | |
| emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| script: ./ci/verify_android.sh | |
| - name: Cache hint on hello world failure | |
| if: ${{ failure() }} | |
| run: | | |
| echo "Android hello world verification failed. If this failed due to what appears to be an adb issue, consider blowing away the AVD cache in the GitHub Actions UI for this workflow." | |
| # This is a noop job that completes once all the jobs spawned by the previous step completes. By blocking PR merges on this | |
| # job completing, we are able to gate it on all the previous jobs without explicitly enumerating them. | |
| verify_android: | |
| runs-on: ubuntu-latest | |
| needs: ["pre_check", "build_and_compare_sizes", "verify_android_hello_world_per_version", "gradle_tests", "run_android_benchmarks"] | |
| if: always() | |
| steps: | |
| # Checkout repo to Github Actions runner | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: check result | |
| run: ./ci/check_result.sh ${{ needs.pre_check.result }} && ./ci/check_result.sh ${{ needs.build_and_compare_sizes.result }} && ./ci/check_result.sh ${{ needs.verify_android_hello_world_per_version.result }} && ./ci/check_result.sh ${{ needs.gradle_tests.result }} |