mirror of
https://github.com/D-Modem/app.git
synced 2026-11-29 18:08:05 -08:00
Robolectric's Android framework jars (about 200 MB each) get their own cache entry, keyed on their versions. The build job saves it also when a test fails. setup-gradle's cache does not keep them a second time. .github/actions/android-sdk: sdkmanager install, with the packages that the runner image does not have (CMake each run until now, and the emulator's system image) cached, keyed on the image and the package list. The three Android jobs use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRSYSk1rgeTZ9ZWMcZL Signed-off-by: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com>
63 lines
2.4 KiB
YAML
63 lines
2.4 KiB
YAML
# sdkmanager install with its downloads cached (actions/cache): the
|
|
# packages that the runner image does not have (for example CMake, or the
|
|
# emulator's system image) are kept in the cache, keyed on the runner image
|
|
# (ImageOS, ImageVersion) and the package list. On a hit, sdkmanager finds
|
|
# them installed and downloads nothing. On a miss, sdkmanager downloads
|
|
# them (it tries again up to 3 times), and the cache is saved for the next
|
|
# run. The packages that the image has are not cached.
|
|
name: Android SDK packages
|
|
description: sdkmanager install, cached
|
|
inputs:
|
|
packages:
|
|
description: the sdkmanager packages (spaces or newlines between), for example "cmake;3.31.6"
|
|
required: true
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
# the key, and the directories of the packages that the image does not have
|
|
# ("cmake;3.31.6" is $ANDROID_HOME/cmake/3.31.6)
|
|
- id: key
|
|
shell: bash
|
|
env:
|
|
PKGS: ${{ inputs.packages }}
|
|
run: |
|
|
pkgs=$(printf '%s\n' $PKGS | sort -u | tr '\n' ' ')
|
|
echo "pkgs=$pkgs" >> "$GITHUB_OUTPUT"
|
|
dirs=
|
|
for p in $pkgs; do
|
|
d="$ANDROID_HOME/${p//;//}"
|
|
[ -e "$d" ] || dirs="$dirs$d"$'\n'
|
|
done
|
|
{
|
|
echo 'dirs<<EOF'
|
|
printf '%s' "$dirs"
|
|
echo 'EOF'
|
|
} >> "$GITHUB_OUTPUT"
|
|
[ -n "$dirs" ] && echo "any=true" >> "$GITHUB_OUTPUT" || echo "any=false" >> "$GITHUB_OUTPUT"
|
|
# (ImageOS, ImageVersion: the runner's environment, not the env context)
|
|
echo "key=sdk-${ImageOS:-none}-$RUNNER_ARCH-${ImageVersion:-none}-$(printf '%s' "$pkgs" | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
|
|
|
|
- id: restore
|
|
if: steps.key.outputs.any == 'true'
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: ${{ steps.key.outputs.dirs }}
|
|
key: ${{ steps.key.outputs.key }}
|
|
|
|
- id: install
|
|
shell: bash
|
|
env:
|
|
PKGS: ${{ steps.key.outputs.pkgs }}
|
|
run: |
|
|
set -euo pipefail
|
|
sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
|
|
yes | "$sdk" --licenses > /dev/null || true
|
|
for i in 1 2 3; do "$sdk" $PKGS && break; [ $i = 3 ] && exit 1; sleep $((i * 10)); done
|
|
|
|
- if: steps.key.outputs.any == 'true' && steps.restore.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
continue-on-error: true
|
|
with:
|
|
path: ${{ steps.key.outputs.dirs }}
|
|
key: ${{ steps.key.outputs.key }}
|