name: Baseline profile generation on: # every day at 00:43 schedule: - cron: '43 0 * * *' workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} jobs: baseline-profile: runs-on: macos-latest timeout-minutes: 45 env: TERM: dumb steps: - name: Checkout repository uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: token: ${{ secrets.POST_RELEASE_GH_TOKEN }} fetch-depth: 0 - name: Accept all SDK licenses shell: bash run: printf 'y\ny\ny\ny\ny\ny\n' | $ANDROID_HOME/tools/bin/sdkmanager --licenses - name: Get build-tools directory id: build-tools-path shell: bash run: echo "dir=${ANDROID_HOME}/build-tools/34.0.0-rc3" >> "${GITHUB_OUTPUT}" - name: Cache build-tools uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 with: path: ${{ steps.build-tools-path.outputs.dir }} key: ${{ runner.os }}-34.0.0-rc3 - name: Set up JDK uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.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@749f47bda3e44aa060e82d7b3ef7e40d953bd629 # v2.4.2 with: gradle-home-cache-cleanup: true cache-read-only: true - 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 - name: Clear unused Gradle Managed Devices run: ./gradlew cleanManagedDevices --unused-only - name: Run benchmark on Gradle Managed Device run: | ./gradlew api31BenchmarkAndroidTest \ -Dorg.gradle.workers.max=1 \ -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile \ -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" # 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, output to android/ sort -o android/src/main/baseline-prof.txt benchmark/build/outputs/managed_device_android_test_additional_output/benchmark/api31/BaselineProfileGenerator_generateBaselineProfile-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 output 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/managed_device_android_test_additional_output - name: Clean secrets if: always() run: scripts/signing-cleanup.sh