Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
577f604
Add R8 regression & library shrinking gate with android analyze
AjeshRPai Oct 23, 2026
15d23c5
Merge branch 'main' into r8-regression-gate-demo
AjeshRPai Oct 23, 2026
a87895b
Fix android analyze JSON results unwrapping, zizmor env inputs, and A…
AjeshRPai Oct 23, 2026
583e359
Pre-commit-hook
AjeshRPai Oct 26, 2026
c5181a4
Split R8 regression gate into modular app, library, and staged-diff s…
AjeshRPai Oct 27, 2026
be01dc1
Address review feedback on the R8 regression gate
AjeshRPai Oct 29, 2026
af13a4b
Add an R8 keep rule diff to the R8 regression gate
AjeshRPai Oct 29, 2026
b8ad536
Set the R8 regression gate's permissions per job
AjeshRPai Oct 29, 2026
8d47ff1
Updates the keep rules and agp version
AjeshRPai Oct 29, 2026
be49721
TEMPORARY: seed main's keep rules for this PR's keep rule diff
AjeshRPai Oct 29, 2026
b1d2206
Remove the R8 keep rule diff from the R8 regression gate
AjeshRPai Oct 30, 2026
e3c92a8
Support the latest Android CLI output and refresh the R8 baseline
AjeshRPai Nov 18, 2026
29d2147
Remove the Gemini review from the R8 regression gate
AjeshRPai Nov 18, 2026
779c33c
Merge branch 'main' into r8-modular-regression-gate
AjeshRPai Nov 24, 2026
f24e026
Summarize the libraries in the R8 regression gate comment
AjeshRPai Nov 24, 2026
768c1ad
Show each R8 regression only once in the gate comment
AjeshRPai Nov 24, 2026
02f28e1
Read R8 enablement and full mode from r8.json first
AjeshRPai Nov 24, 2026
aa34459
Remove the R8 git hooks from the regression gate
AjeshRPai Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 215 additions & 0 deletions .github/workflows/r8_regression_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: R8 Regression Gate

# Each job sets the permissions it needs.
permissions: {}

on:
push:
branches: [ 'main' ]
pull_request:
branches: [ '*' ]
workflow_dispatch:
inputs:
pr_number:
description: 'Pull request number to review (leave empty to check the latest commit)'
required: false
type: string
max_score_drop:
description: 'Max allowed drop in R8 scores (percentage points)'
required: false
default: '2.0'
type: string
max_dex_growth_pct:
description: 'Max allowed uncompressed DEX growth (%)'
required: false
default: '5.0'
type: string
min_lib_shrinking_pct:
description: 'Min required library DEX shrinking percentage (%)'
required: false
default: '90.0'
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
r8-regression-gate:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.repository == 'android/androidify' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.fork == false)
permissions:
contents: write # commit the updated r8-baseline.json on main
issues: write
pull-requests: write # post the findings comment

steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.PAT || github.token }}
fetch-depth: 0
persist-credentials: ${{ github.event_name == 'push' }}

- name: Prepare Review Context
id: context
env:
GH_TOKEN: ${{ secrets.PAT || github.token }}
PR_NUMBER: ${{ inputs.pr_number || github.event.pull_request.number }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if [[ -n "${PR_NUMBER}" ]]; then
if [[ -z "${BASE_REF}" ]]; then
gh pr checkout "${PR_NUMBER}"
fi
echo "mode=pr" >> "${GITHUB_OUTPUT}"
echo "pr_number=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
else
echo "mode=commit" >> "${GITHUB_OUTPUT}"
echo "pr_number=" >> "${GITHUB_OUTPUT}"
fi

- name: Set up JDK 21
uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4

- name: Install Android CLI
run: |
set -euo pipefail
curl -fsSL https://dl.google.com/android/cli/latest/linux_x86_64/install.sh | bash
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"

- name: Decode google-services.json
env:
DEBUG_GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.DEBUG_GOOGLE_SERVICES_JSON_BASE64 }}
run: |
if [[ -z "${DEBUG_GOOGLE_SERVICES_JSON_BASE64}" ]]; then
cp test-google-services.json app/google-services.json
else
echo "${DEBUG_GOOGLE_SERVICES_JSON_BASE64}" | base64 --decode > app/google-services.json
fi

- name: Build Release App Bundle (.aab) & Module Libraries (.aar)
run: ./gradlew :app:bundleRelease assembleRelease -x test -x uploadCrashlyticsMappingFileRelease

- name: Check App Bundle R8 Scores & DEX Size
id: app_r8_gate
env:
MAX_SCORE_DROP: ${{ inputs.max_score_drop || '2.0' }}
MAX_DEX_GROWTH_PCT: ${{ inputs.max_dex_growth_pct || '5.0' }}
run: |
set +e
python3 ./scripts/check_app_r8_score.py \
--aab app/build/outputs/bundle/release/app-release.aab \
--baseline r8-baseline.json \
--max-score-drop "${MAX_SCORE_DROP}" \
--max-dex-growth-pct "${MAX_DEX_GROWTH_PCT}" \
--markdown-summary "${RUNNER_TEMP}/r8_summary.md"
EXIT_CODE=$?
set -e
if [[ ${EXIT_CODE} -eq 0 ]]; then
echo "passed=true" >> "${GITHUB_OUTPUT}"
else
echo "passed=false" >> "${GITHUB_OUTPUT}"
fi

- name: Check Module & Library Shrinking Percentage
id: lib_r8_gate
env:
MIN_LIB_SHRINKING_PCT: ${{ inputs.min_lib_shrinking_pct || '90.0' }}
run: |
set +e
python3 ./scripts/check_library_shrinking.py \
--scan-libraries \
--min-lib-shrinking-pct "${MIN_LIB_SHRINKING_PCT}" \
--markdown-summary "${RUNNER_TEMP}/r8_summary.md" \
--append-summary
EXIT_CODE=$?
set -e
if [[ ${EXIT_CODE} -eq 0 ]]; then
echo "passed=true" >> "${GITHUB_OUTPUT}"
else
echo "passed=false" >> "${GITHUB_OUTPUT}"
fi

- name: Update R8 Baseline on Merge to main
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.app_r8_gate.outputs.passed == 'true' && steps.lib_r8_gate.outputs.passed == 'true'
run: |
python3 ./scripts/check_app_r8_score.py \
--aab app/build/outputs/bundle/release/app-release.aab \
--baseline r8-baseline.json \
--save-baseline

- name: Commit Updated R8 Baseline
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.app_r8_gate.outputs.passed == 'true' && steps.lib_r8_gate.outputs.passed == 'true'
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5
with:
commit_message: "🤖 Update r8-baseline.json after merge [skip ci]"
file_pattern: 'r8-baseline.json'

- name: Post Findings on Pull Request
if: steps.context.outputs.pr_number != '' && always()
env:
GH_TOKEN: ${{ secrets.PAT || github.token }}
HAS_PAT: ${{ secrets.PAT != '' }}
PR_NUMBER: ${{ steps.context.outputs.pr_number }}
run: |
set -euo pipefail
SUMMARY="${RUNNER_TEMP}/r8_summary.md"
if [[ ! -f "${SUMMARY}" ]]; then
exit 0
fi
MARKER='<!-- r8-regression-gate -->'
COMMENT_FILE="$(mktemp)"
{
echo "${MARKER}"
cat "${SUMMARY}"
} > "${COMMENT_FILE}"
# Keep one comment per PR: edit this workflow's earlier comment instead of adding a new one.
AUTHOR='github-actions[bot]'
if [[ "${HAS_PAT}" == "true" ]]; then
AUTHOR="$(gh api user --jq .login)"
fi
COMMENTS="repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments"
COMMENT_ID="$(gh api "${COMMENTS}" --paginate \
--jq ".[] | select(.user.login == \"${AUTHOR}\" and (.body | startswith(\"${MARKER}\"))) | .id" | sed -n '1p')"
if [[ -n "${COMMENT_ID}" ]]; then
gh api --method PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" -F body=@"${COMMENT_FILE}" > /dev/null
else
gh api --method POST "${COMMENTS}" -F body=@"${COMMENT_FILE}" > /dev/null
fi
rm -f "${COMMENT_FILE}"

- name: Upload R8 Configuration Analyzer HTML Report
if: steps.app_r8_gate.outputs.passed == 'false' || steps.lib_r8_gate.outputs.passed == 'false'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: r8-config-analyzer-report
path: app/build/reports/r8/r8-config-analyzer-release.html
if-no-files-found: ignore

- name: Enforce R8 Regression Gate
if: steps.app_r8_gate.outputs.passed == 'false' || steps.lib_r8_gate.outputs.passed == 'false'
run: |
echo "::error::R8 Regression Gate failed. See step summary or PR comment for details."
exit 1
4 changes: 0 additions & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.firebase.** { *; }
-keep interface com.firebase.** { *; }
-keep class org.apache.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
Expand All @@ -45,8 +43,6 @@
-dontwarn javax.lang.model.**

# OkHttp
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

# Ignore SAX parser warning
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
appVersionCode = "11"
appVersionName = "1.4.0"
appVersionWearOffset = "60000000"
agp = "9.2.1"
agp = "9.3.2"
bcpkixJdk18on = "1.84"
core = "1.7.0"
extensionsXr = "1.3.0"
Expand Down
41 changes: 41 additions & 0 deletions r8-baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"results": [
{
"optimization": {
"bundleAnalysisResult": {
"agpVersion": "9.3.2",
"r8Json": {
"version": "9.3.16",
"options": {
"isRepackageClassesEnabled": true,
"isProguardCompatibilityModeEnabled": false
},
"stats": {
"shrinkingRatio": 0.5249,
"optimizationRatio": 0.5215,
"obfuscationRatio": 0.5245
},
"resourceOptimizationStatus": "R8_RESOURCE_OPTIMIZATION_STATUS_OPTIMIZED",
"r8DexChecksumStatus": "EXACT_MATCH"
},
"r8DexMarkerMetadata": {
"r8Enabled": true,
"d8Enabled": false,
"fullModeEnabled": true
},
"mappingObfuscationRatio": 0.6852733,
"dexHeuristicObfuscationRatio": 0.6869329,
"uncompressedDexSizeBytes": "18860312"
}
},
"artifactPath": "app/build/outputs/bundle/release/app-release.aab",
"basic": {
"appInfo": {
"packageName": "com.android.developers.androidify",
"versionName": "1.4.0",
"versionCode": "11"
}
}
}
]
}
Loading
Loading