name: Baseline profile # Records a fresh app/src/main/baseline-prof.txt on an emulator and pushes it to the # ci/baseline-profile branch for review. Run it from the Actions tab or push to profile/. on: workflow_dispatch: push: branches: ["profile/**"] permissions: contents: write jobs: profile: if: github.server_url == 'https://github.com' runs-on: ubuntu-latest timeout-minutes: 90 steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 with: distribution: temurin java-version: 21 - uses: gradle/actions/setup-gradle@v4 # Rules must use the names from the source, so the profile is recorded on a build without R8 - name: Build a non-minified release APK run: | sed -i 's/isMinifyEnabled = true/isMinifyEnabled = false/; s/isShrinkResources = true/isShrinkResources = false/' app/build.gradle.kts ./gradlew :app:assembleRelease -q keytool -genkeypair -keystore "$RUNNER_TEMP/p.jks" -storepass profile -keypass profile -alias p \ -keyalg RSA -keysize 2048 -validity 365 -dname "CN=profile" >/dev/null 2>&1 apksigner="$(ls -d "$ANDROID_HOME"/build-tools/*/ | sort -V | tail -n 1)apksigner" "$apksigner" sign --ks "$RUNNER_TEMP/p.jks" --ks-pass pass:profile --out "$RUNNER_TEMP/app.apk" \ app/build/outputs/apk/release/app-release-unsigned.apk git checkout app/build.gradle.kts - name: Enable KVM 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 - name: Record the profile uses: reactivecircus/android-emulator-runner@v2 with: api-level: 34 target: google_apis arch: x86_64 profile: pixel_6 emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none script: bash scripts/baseline-profile.sh "$RUNNER_TEMP/app.apk" "$RUNNER_TEMP/baseline-prof.txt" - name: Push it for review run: | sort -u "$RUNNER_TEMP/baseline-prof.txt" > "$RUNNER_TEMP/sorted.txt" git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git checkout --orphan profile-output git rm -rq --cached . cp "$RUNNER_TEMP/sorted.txt" baseline-prof.txt git add baseline-prof.txt git commit -qm "Baseline profile recorded from ${GITHUB_SHA::7}" git push -f origin HEAD:refs/heads/ci/baseline-profile echo "::notice title=Baseline profile::$(wc -l < baseline-prof.txt) rules pushed to ci/baseline-profile"