Skip to content

Commit

Permalink
Automate baseline profile generation with GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlebras committed Jan 12, 2024
1 parent fee1eee commit 8f00777
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
73 changes: 73 additions & 0 deletions .github/workflows/baseline-profile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Baseline profile generation

on:
push:
branches:
- main
paths-ignore:
- 'haze/src/androidMain/generated/baselineProfiles/baseline-prof.txt' # don't recursively update baseline profile
workflow_dispatch:
pull_request:
paths:
- 'internal/baseline-profile/**'

jobs:
baseline-profile:
runs-on: macos-latest
timeout-minutes: 45

steps:
- uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 20

- uses: gradle/gradle-build-action@v2

# This allows us to build most of what we need without the emulator running
# and using resources
- name: Build sample app and benchmark
run: ./gradlew assembleNonMinifiedRelease

- name: Clear unused Gradle Managed Devices
run: ./gradlew cleanManagedDevices --unused-only

- name: Generate Baseline Profile
run: |
./gradlew generateBaselineProfile \
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" \
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile \
-Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=20 \
-Dorg.gradle.workers.max=4
# 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
# If the baseline profile has changed, commit it
if [[ $(git diff --stat haze/src/androidMain/generated/baselineProfiles/baseline-prof.txt) != '' ]]; then
git config user.name github-actions
git config user.email [email protected]
git add haze/src/androidMain/generated/baselineProfiles/baseline-prof.txt
git commit -m "Update baseline profile" && git push
fi
- name: Upload baseline profile
uses: actions/upload-artifact@v4
with:
name: baseline-profile-output
path: internal/baseline-profile/build/outputs/managed_device_android_test_additional_output

- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: reports
path: |
**/build/reports/*
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:
- uses: gradle/gradle-build-action@v2

- name: Build
run: ./gradlew build
run: |
./gradlew build \
-x :internal:baseline-profile:pixel7Api34NonMinifiedReleaseAndroidTest \
-x :internal:baseline-profile:collectNonMinifiedReleaseBaselineProfile
- name: Upload reports + Roborazzi outputs
if: failure()
Expand Down

0 comments on commit 8f00777

Please sign in to comment.