Baseline profile generation #116
This file contains 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: Baseline profile generation | |
on: | |
# every thur at 19:30 | |
schedule: | |
- cron: '30 19 * * 4' | |
jobs: | |
baseline-profile: | |
runs-on: macos-latest | |
timeout-minutes: 45 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.CIS_OWNER_PAT }} | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 19 | |
- name: Decode Firebase google-services.json | |
env: | |
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }} | |
run: echo $FIREBASE_CONFIG > app/google-services.json | |
- name: Decode Keystore properties file | |
env: | |
KEY_PROPERTIES: ${{ secrets.KEY_STORE_PROPERTIES }} | |
run: echo $KEY_PROPERTIES > app/keystore.properties | |
- uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-home-cache-cleanup: true | |
# This allows us to build most of what we need without the emulator running | |
# and using resources | |
- name: Build benchmark and app | |
run: ./gradlew :benchmark:assembleBenchmark :app:assembleBenchmark | |
# Now use reactivecircus/android-emulator-runner to spin up an emulator and 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@v2 | |
with: | |
api-level: 31 | |
target: google_apis | |
arch: x86_64 | |
profile: Galaxy Nexus | |
script: | | |
# Run our benchmark, enabling only tests using BaselineProfile | |
./gradlew connectedBenchmarkAndroidTest -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile | |
# Need to manually pull the generated profiles from the emulator | |
adb pull /sdcard/Android/media/app.hymnal.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 develop | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
cp benchmark/build/outputs/baseline-prof/BaselineProfileGenerator_generateBaselineProfile-baseline-prof.txt app/src/main/baseline-prof.txt | |
# If the baseline profile has changed, commit it | |
if [[ $(git diff --stat app/src/main/baseline-prof.txt) != '' ]]; then | |
git config --global user.name 'Baseline Profile - GitHub Actions' | |
git config --global user.email 'github@actions' | |
git add app/src/main/baseline-prof.txt | |
git commit -m "Update app 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@v3 | |
with: | |
name: Baseline profile output | |
path: benchmark/build/outputs/baseline-prof |