name: Baseline profile generation on: # every day at 00:43 schedule: - cron: '43 0 * * *' workflow_dispatch: env: AVD_API_LEVEL: 31 AVD_ARCH: x86_64 jobs: baseline-profile: runs-on: macos-latest timeout-minutes: 45 env: TERM: dumb steps: - name: Checkout repository uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: token: ${{ secrets.POST_RELEASE_GH_TOKEN }} fetch-depth: 0 - name: Set up JDK uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0 with: distribution: temurin java-version: 18 - name: Set up Git author shell: bash run: | git config user.name "GitHub Actions" git config user.email noreply@github.com - name: Setup Gradle caching uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2.3.3 with: gradle-home-cache-cleanup: true # Restore AVD from cache - name: Cache AVD uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2 id: avd-cache with: path: | ~/.android/avd/* ~/.android/adb* key: ${{ runner.os }}-avd-${{ env.AVD_API_LEVEL }}-${{ env.AVD_ARCH }} - name: Decrypt secrets run: | ./scripts/setup-age.sh ./scripts/signing-setup.sh "$ENCRYPT_KEY" env: ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }} # This allows us to build most of what we need without the emulator running # and using resources - name: Build app and benchmark run: ./gradlew :benchmark:assembleBenchmark :android:assembleBenchmark # Now use reactivecircus/android-emulator-runner to spin up an emulator. We're gonna use it again # to actually run the test once the emulator has booted. - name: Create AVD snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # v2 with: api-level: ${{ env.AVD_API_LEVEL }} arch: ${{ env.AVD_ARCH }} channel: canary target: aosp_atd force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false disk-size: 8G script: echo "Generated AVD snapshot for caching." # Run our baseline profile generator. We need to manually pull the baseline profiles off the # emulator when using the GA runner - name: Run benchmark uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 # v2 with: api-level: ${{ env.AVD_API_LEVEL }} arch: ${{ env.AVD_ARCH }} channel: canary target: aosp_atd disable-animations: true disable-spellchecker: true disk-size: 8G script: | # Run our benchmark, enabling only tests using BaselineProfile ./gradlew connectedBenchmarkAndroidTest -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile --stacktrace # Need to manually pull the generated profiles from the emulator adb pull /sdcard/Android/media/dev.msfjarvis.claw.benchmark benchmark/build/outputs/baseline-prof/ # If we're on main branch, copy over the baseline profile and # commit it to the repository (if changed) - name: Commit baseline profile into main if: github.ref == 'refs/heads/main' run: | # Pull down any changes which may have been committed while this workflow has been running git pull # Sort the baseline profile, saving it to app/ sort -o android/src/main/baseline-prof.txt benchmark/build/outputs/baseline-prof/BaselineProfileGenerator_startup-baseline-prof.txt # If the baseline profile has changed, commit it if [[ $(git diff --stat android/src/main/baseline-prof.txt) != '' ]]; then git add android/src/main/baseline-prof.txt git commit -m "chore(android): refresh baseline profile" && git push fi # Upload the entire generated folder and attach it to the CI run - name: Attach baseline profile uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: Baseline profile output path: benchmark/build/outputs/baseline-prof - name: Clean secrets if: always() run: scripts/signing-cleanup.sh