Baseline profile generation #163
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 day at 00:43 | |
schedule: | |
- cron: '43 0 * * *' | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- 'benchmark/**' | |
jobs: | |
baseline-profile: | |
runs-on: macos-latest | |
timeout-minutes: 45 | |
env: | |
TERM: dumb | |
ORG_GRADLE_PROJECT_TIVI_TMDB_API_KEY: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TMDB_API_KEY }} | |
ORG_GRADLE_PROJECT_TIVI_TVDB_API_KEY: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TVDB_API_KEY }} | |
ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_ID: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_ID }} | |
ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_SECRET: ${{ secrets.ORG_GRADLE_PROJECT_TIVI_TRAKT_CLIENT_SECRET }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
# We need to use a Personal Access Token from an admin to be able to commit to main, | |
# as it is a protected branch. | |
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-fine-grained-personal-access-token | |
token: ${{ secrets.TIVI_OWNER_PAT }} | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
# Android sdkmanager requires JRE 8 🤷 | |
- name: Setup JDK for sdkmanager | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 8 | |
- name: Accept Android SDK licenses | |
run: yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses | |
- name: Setup JDK for build | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- uses: gradle/gradle-build-action@v2 | |
with: | |
# Disable caching. This action is very different to the normal build action, and we | |
# don't want to spoil the cache which is used for the 'build' action. | |
cache-read-only: true | |
- name: Decrypt secrets | |
run: ./release/decrypt-secrets.sh | |
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 assembleBenchmark | |
- name: Clear unused Gradle Managed Devices | |
run: ./gradlew cleanManagedDevices --unused-only | |
- name: Run benchmark on Gradle Managed Device | |
# --info used to add a repro to https://issuetracker.google.com/issues/193118030 | |
# config cache is disabled due to https://issuetracker.google.com/issues/262270582 | |
run: | | |
./gradlew api31BenchmarkAndroidTest \ | |
-Dorg.gradle.workers.max=1 \ | |
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile \ | |
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" \ | |
--info \ | |
--no-configuration-cache | |
# 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 | |
# Copy the baseline profile to :android-app:app | |
cp android-app/benchmark/build/outputs/managed_device_android_test_additional_output/api31/BaselineProfileGenerator_generateBaselineProfile-baseline-prof.txt android-app/app/src/main/baseline-prof.txt | |
# If the baseline profile has changed, commit it | |
if [[ $(git diff --stat android-app/app/src/main/baseline-prof.txt) != '' ]]; then | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add android-app/app/src/main/baseline-prof.txt | |
git commit -m "Update app baseline profile" && git push | |
fi | |
# Upload the entire output folder and attach it to the CI run | |
- name: Upload baseline profile | |
uses: actions/upload-artifact@v3 | |
with: | |
name: baseline-profile-output | |
path: android-app/benchmark/build/outputs/managed_device_android_test_additional_output | |
- name: Upload reports | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: reports | |
path: | | |
**/build/reports/* | |
- name: Clean secrets | |
if: always() | |
run: ./release/clean-secrets.sh |