Merge pull request #256 from android/version-updates #53
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: Generate Baseline Profiles | ||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
# This job checks for any file changed within MacrobenchmarkSample/ folder | ||
# to distinguish if the build check for Macrobenchmark is needed to be run. | ||
# It sets the outputs.macrobenchmark to true/false based on the changes. | ||
# In the next build job, it checks for needs.changes.outputs.macrobenchmark == 'true' | ||
# or skips the job otherwise. | ||
changes: | ||
if: github.repository_owner == 'android' | ||
runs-on: ubuntu-latest | ||
# Set job outputs to values from filter step to be able to use it in next job | ||
outputs: | ||
macrobenchmark: ${{ steps.filter.outputs.macrobenchmark }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: dorny/paths-filter@v2 | ||
id: filter | ||
with: | ||
filters: | | ||
macrobenchmark: | ||
- 'MacrobenchmarkSample/**' | ||
baseline-profile: | ||
needs: changes | ||
# # Only run action for the main repo & not forks and if change is in macrobenchmark sample | ||
if: github.repository_owner == 'android' && (needs.changes.outputs.macrobenchmark == 'true' || github.event_name == 'workflow_dispatch') | ||
runs-on: macos-latest | ||
timeout-minutes: 60 | ||
defaults: | ||
run: | ||
working-directory: ./MacrobenchmarkSample | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup JDK | ||
id: setup-java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: "zulu" | ||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-home-cache-cleanup: true | ||
- name: Copy CI gradle.properties | ||
working-directory: ./ | ||
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | ||
- name: Clean GMD | ||
run: ./gradlew cleanManagedDevices --unused-only | ||
# Runs all Baseline Profiles generators on Gradle Managed Device | ||
# If the module contains both benchmarks and generators, we need to filter just the generators, | ||
# because benchmarks should be run on a physical device and thus would fail by default. | ||
- name: Run generator with GMD | ||
uses: nick-fields/retry@v2 | ||
with: | ||
Check failure on line 71 in .github/workflows/generate-bp.yml GitHub Actions / Generate Baseline ProfilesInvalid workflow file
|
||
max_attempts: 2 | ||
command: > | ||
./gradlew :app:generateBaselineProfile | ||
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" | ||
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile | ||
- name: Upload Logcat logs | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: "Logcat" | ||
path: MacrobenchmarkSample/baselineProfile/build/outputs/androidTest-results/managedDevice/pixel6Api31/logcat-*.txt | ||
# Upload all the generated profiles to artifacts | ||
- name: Upload generated profiles | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "Baseline Profiles" | ||
path: MacrobenchmarkSample/app/src/release/generated/baselineProfiles/*.txt | ||
# Create a PR with the generated Baseline Profiles | ||
- name: Create PR with generated profiles | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.ANDROID_DEVREL_BOT_TOKEN }} | ||
commit-message: '[Generated] Baseline Profiles' | ||
committer: BP Bot <[email protected]> | ||
author: BP Bot <[email protected]> | ||
title: '[Generated] Baseline Profiles' | ||
body: 'Updates baseline profiles' | ||
reviewers: ${{ github.actor }} | ||
branch: bot/update-baseline-profiles | ||
# If you generate the rules before producing your production app, you need to build it here with the profile. | ||
# We use benchmark variant, because release variant is not specified, | ||
# but generally this is where you want to generate your production version of your app | ||
- name: Build production app | ||
run: > | ||
./gradlew assembleRelease | ||
- name: Upload app with Baseline Profile | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "Production App" | ||
path: MacrobenchmarkSample/app/build/outputs/apk/release/*.apk | ||