Skip to content

Generate Baseline Profile #23

Generate Baseline Profile

Generate Baseline Profile #23

name: Generate Baseline Profile
on:
workflow_dispatch:
workflow_call:
secrets:
token:
required: true
jobs:
test:
runs-on: macos-latest
timeout-minutes: 30
strategy:
matrix:
jdk-version: [ "17" ]
ndk-version: [ "21.4.7075529" ]
api-level: [ 29 ]
target: [ default ]
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.CD_GITHUB_TOKEN || secrets.token }}
- name: Checkout Android SDK Benchmark
uses: actions/checkout@v4
with:
repository: embrace-io/android-sdk-benchmark
ref: main
path: ./android-sdk-benchmark
token: ${{ secrets.CD_GITHUB_TOKEN || secrets.token }}
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-gradle-jdk${{ matrix.jdk-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle
- name: Install JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Clean Managed Devices
run: |
cd android-sdk-benchmark
./gradlew cleanManagedDevices --unused-only
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Generate Baseline Profile
run: |
cd android-sdk-benchmark
./gradlew -Dorg.gradle.workers.max=4 -i :macrobenchmark:nexus6Api31BaselineProfileAndroidTest -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile
# Sets the Baseline Profile on its proper place so it gets correctly bundled into Play Store
- name: Move & Rename Baseline Profiles
run: |
cat /Users/runner/work/embrace-android-sdk/embrace-android-sdk/android-sdk-benchmark/macrobenchmark/build/outputs/managed_device_android_test_additional_output/baselineprofile/nexus6Api31/BaselineProfileGenerator_startup-baseline-prof.txt | grep '^[^[]*io/embrace/android/embracesdk' > /Users/runner/work/embrace-android-sdk/embrace-android-sdk/embrace-android-sdk/src/main/baseline-prof.txt
# Commits the generated Baseline Profile to your origin/remote
- name: Commit Baseline Profiles
run: |
git config --global user.name 'embrace-ci[bot]'
git config --global user.email 'embrace-ci@users.noreply.github.com'
git add embrace-android-sdk/src/main/baseline-prof.txt
git commit -m "Generate baseline profiles"
git push
- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties