From 8f007774fda5e745f1e654b42dbf012fa4420702 Mon Sep 17 00:00:00 2001 From: Simon Le Bras Date: Fri, 12 Jan 2024 13:44:30 +0100 Subject: [PATCH] Automate baseline profile generation with GHA --- .github/workflows/baseline-profile.yml | 73 ++++++++++++++++++++++++++ .github/workflows/build.yml | 5 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/baseline-profile.yml diff --git a/.github/workflows/baseline-profile.yml b/.github/workflows/baseline-profile.yml new file mode 100644 index 00000000..0d4858dd --- /dev/null +++ b/.github/workflows/baseline-profile.yml @@ -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 github-actions@github.com + 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/* diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 956dc654..85bc3285 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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()