forked from ankidroid/Anki-Android
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): apk size comparison workflow
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: APK Size Comparison | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
sizeCheck: | ||
name: APK Size Check | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
env: | ||
# could be better, '/home/runner' should be '~/' but neither that nor '$HOME' worked | ||
STOREFILEDIR: /home/runner/src | ||
STOREFILE: android-keystore | ||
STOREPASS: testpass | ||
KEYPASS: testpass | ||
KEYALIAS: nrkeystorealias | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 1 | ||
|
||
- name: Configure JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: "temurin" | ||
java-version: "21" | ||
|
||
- name: Test Credential Prep | ||
run: | | ||
echo "KSTOREPWD=$STOREPASS" >> $GITHUB_ENV | ||
echo "KEYPWD=$KEYPASS" >> $GITHUB_ENV | ||
mkdir $STOREFILEDIR | ||
cd $STOREFILEDIR | ||
echo y | keytool -genkeypair -dname "cn=AnkiDroid, ou=ankidroid, o=AnkiDroid, c=US" -alias $KEYALIAS -keypass $KEYPASS -keystore "$STOREFILE" -storepass $STOREPASS -keyalg RSA -validity 20000 | ||
shell: bash | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
timeout-minutes: 5 | ||
with: | ||
# Only write to the cache for builds on the 'main' branches, stops branches evicting main cache | ||
# Builds on other branches will only read from main branch cache writes | ||
# Comment this and the with: above out for performance testing on a branch | ||
cache-read-only: ${{ github.ref != 'refs/heads/main' }} | ||
gradle-home-cache-cleanup: true | ||
|
||
- name: Assemble Baseline APK | ||
# This makes sure we fetch gradle network resources with a retry | ||
uses: nick-invision/retry@v3 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: ./gradlew :AnkiDroid:assemblePlayRelease --daemon | ||
|
||
- name: Get Baseline APK size | ||
run: ls -lrt AnkiDroid/build/outputs/apk/play/release/AnkiDroid-play-arm64-v8a-release.apk | awk '{print $5}' | ||
|
||
- name: Checkout PR | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Assemble PR APK | ||
# This makes sure we fetch gradle network resources with a retry | ||
uses: nick-invision/retry@v3 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: ./gradlew :AnkiDroid:assemblePlayRelease --daemon | ||
|
||
- name: Get PR APK size | ||
run: ls -lrt AnkiDroid/build/outputs/apk/play/release/AnkiDroid-play-arm64-v8a-release.apk | awk '{print $5}' | ||
|