Files
app/.github/workflows/android.yml
T
Neo-DesktopandClaude Opus 5.5 b0f0d53045 CI: cache the downloads (Robolectric's jars, the SDK packages)
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>
2026-11-28 19:27:41 +00:00

349 lines
14 KiB
YAML

# docs: every function documented (tools/doc_check.py), and the app's AT
# command reference D-Modem's (tools/at_reference.py).
# build: the APK (all four ABIs), the unit tests and lint.
# native: the native engine on the runner against a dmodemd over loopback
# SIP (native-test).
# device: the instrumented tests on an emulator (x86_64, the one ABI it
# builds): the native library loads, binds and answers AT commands.
#
# release: the release APK and bundle (R8), signed with the release
# environment's key: main, v* tags and a manual run only, not a pull
# request (its R8 build is the slow one; build's debug APK is what a
# pull request is tried with).
#
# Packages: apt's downloads are cached (.github/actions/apt), keyed on
# the runner image and the package list. The Android SDK packages that
# the image does not have (CMake, the emulator's system image) are cached
# the same way (.github/actions/android-sdk). Robolectric's Android
# framework jars have their own cache entry, keyed on their versions
# (app/build.gradle.kts), so the unit tests do not download them from
# Maven Central.
#
# D-Modem is a public submodule: the checkout needs no token.
#
# Signing: ANDROID_KEYSTORE_BASE64 (a PKCS12 keystore, base64),
# ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS and ANDROID_KEY_PASSWORD
# (the store's if empty). The repository's secrets hold the debug
# keystore, the protected "release" environment's the release one (an
# environment's secret wins over the repository's of the same name). A
# fork's pull request has neither: its builds take the SDK's debug key
# (and its release build is unsigned).
name: Android
# (a branch's commits run once, as its pull request: pushed, only main's;
# a change to docs alone runs nothing: the Markdown, docs/, COPYING and
# the site's files, which pages.yml builds)
on:
push:
branches: [main]
tags: ["v*"]
paths: ['**', '!**.md', '!docs/**', '!COPYING', '!mkdocs.yml', '!.github/workflows/pages.yml', '!tools/settings_ref.py']
pull_request:
paths: ['**', '!**.md', '!docs/**', '!COPYING', '!mkdocs.yml', '!.github/workflows/pages.yml', '!tools/settings_ref.py']
workflow_dispatch:
# a newer commit on a pull request cancels the run before it (main's all run)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NDK_VERSION: "29.0.14206865"
CMAKE_VERSION: "3.31.6"
jobs:
docs:
runs-on: ubuntu-24.04
# (a hung test ends here, not at GitHub's 6 hours)
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Every function documented
run: python3 tools/doc_check.py
- name: The AT command reference is D-Modem's
run: python3 tools/at_reference.py --check
build:
runs-on: ubuntu-24.04
# (a hung test ends here, not at GitHub's 6 hours)
timeout-minutes: 40
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v5
with:
# (Robolectric's jars: their own cache, below)
gradle-home-cache-excludes: caches/modules-2/files-2.1/org.robolectric
# Robolectric's Android framework jars (about 200 MB each, app/build.gradle.kts), in Gradle's
# cache: their own cache entry, keyed on their versions, so a run does not download them
# from Maven Central (its rate limit, HTTP 429)
- name: Robolectric's jars, key
id: robolectric
run: echo "key=robolectric-$(grep -h 'android-all-instrumented:' app/build.gradle.kts | sort | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
- id: robolectric-restore
uses: actions/cache/restore@v5
with:
path: ~/.gradle/caches/modules-2/files-2.1/org.robolectric
key: ${{ steps.robolectric.outputs.key }}
- name: SDK packages
uses: ./.github/actions/android-sdk
with:
packages: ndk;${{ env.NDK_VERSION }} cmake;${{ env.CMAKE_VERSION }} platforms;android-37.0
- name: OpenSSH, PuTTY, mksh (the interop tests), gawk (proot's build)
uses: ./.github/actions/apt
with:
packages: openssh-client openssh-server putty-tools gawk mksh
recommends: 'true'
- run: sudo mkdir -p /run/sshd
# the keystore from its secret, for the build (app/build.gradle.kts); none on a fork's pull request
- name: Signing keystore
env:
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
run: |
if [ -n "$KEYSTORE_BASE64" ]; then
printf '%s' "$KEYSTORE_BASE64" | tr -d '[:space:]' | base64 -d > "$RUNNER_TEMP/keystore.p12"
echo "ANDROID_KEYSTORE_FILE=$RUNNER_TEMP/keystore.p12" >> "$GITHUB_ENV"
else
echo "No keystore secret: the SDK's debug key (a release build unsigned)"
fi
- name: Build, unit tests, lint
run: ./gradlew assembleDebug assembleDebugAndroidTest testDebugUnitTest lintDebug :shared:jvmTest :shared:linuxX64Test
env:
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
# (saved also when a test fails: the jars that Gradle downloaded are good)
- name: Robolectric's jars, downloaded
id: robolectric-got
if: ${{ !cancelled() && steps.robolectric-restore.outputs.cache-hit != 'true' }}
run: |
d=~/.gradle/caches/modules-2/files-2.1/org.robolectric/android-all-instrumented
[ "$(find "$d" -name '*.jar' 2>/dev/null | wc -l)" -ge 2 ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
- if: ${{ !cancelled() && steps.robolectric-got.outputs.save == 'true' }}
uses: actions/cache/save@v5
continue-on-error: true
with:
path: ~/.gradle/caches/modules-2/files-2.1/org.robolectric
key: ${{ steps.robolectric.outputs.key }}
- name: The APK's signer
if: ${{ !cancelled() && hashFiles('app/build/outputs/apk/debug/app-debug.apk') != '' }}
run: |
tools=$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -1)
"$tools/apksigner" verify --print-certs app/build/outputs/apk/debug/app-debug.apk
# the APK even when a test fails, so a build can still be tried on a phone; as
# the .apk itself, not zipped (archive: false, upload-artifact v7: the artifact
# takes the file's name)
- uses: actions/upload-artifact@v7
if: ${{ !cancelled() && hashFiles('app/build/outputs/apk/debug/app-debug.apk') != '' }}
with:
path: app/build/outputs/apk/debug/app-debug.apk
archive: false
- uses: actions/upload-artifact@v7
if: always()
with:
name: reports
path: |
app/build/reports
app/build/test-results
release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-24.04
# (a hung build ends here, not at GitHub's 6 hours)
timeout-minutes: 40
# main and v* tags: the release environment and its key (that environment takes only those);
# anything else (a pull request) none, so the repository's debug key
environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && 'release' || '' }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v5
- name: SDK packages
uses: ./.github/actions/android-sdk
with:
packages: ndk;${{ env.NDK_VERSION }} cmake;${{ env.CMAKE_VERSION }} platforms;android-37.0
- name: gawk (proot's build)
uses: ./.github/actions/apt
with:
packages: gawk
# the keystore from its secret, for the build (app/build.gradle.kts); none on a fork's pull request
- name: Signing keystore
env:
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
run: |
if [ -n "$KEYSTORE_BASE64" ]; then
printf '%s' "$KEYSTORE_BASE64" | tr -d '[:space:]' | base64 -d > "$RUNNER_TEMP/keystore.p12"
echo "ANDROID_KEYSTORE_FILE=$RUNNER_TEMP/keystore.p12" >> "$GITHUB_ENV"
else
echo "No keystore secret: the SDK's debug key (a release build unsigned)"
fi
- name: Release APK and bundle
run: ./gradlew assembleRelease bundleRelease
env:
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: The APK's signer
if: ${{ env.ANDROID_KEYSTORE_FILE != '' }}
run: |
tools=$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -1)
"$tools/apksigner" verify --print-certs app/build/outputs/apk/release/app-release.apk
- uses: actions/upload-artifact@v7
with:
name: release
path: |
app/build/outputs/apk/release/*.apk
app/build/outputs/bundle/release/*.aab
app/build/outputs/mapping/release/mapping.txt
native:
runs-on: ubuntu-24.04
# (a hung test ends here, not at GitHub's 6 hours)
timeout-minutes: 25
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Packages
uses: ./.github/actions/apt
with:
packages: cmake ninja-build g++ libssl-dev libgtest-dev
- name: Build
run: |
cmake -S native-test -B build-host -G Ninja
cmake --build build-host
- name: Engine test
run: ctest --test-dir build-host --output-on-failure
# the iOS app's DModemKit (its Swift) on this engine: Swift runs on Linux too
# (the runner image's Swift: setup-swift still runs on Node 20)
- name: Swift
run: swift --version
- name: DModemKit (Swift) on the engine
run: swift test --package-path ios/DModemKit
env:
DMODEM_HOST_BUILD: ${{ github.workspace }}/build-host
# the apps' SSH client (native-ssh: libdmodemssh on libssh), and the
# iOS app's Swift on it, against a real sshd
- name: SSH client
run: |
cmake -S native-ssh -B build-ssh -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-ssh
sudo apt-get install -y --no-install-recommends openssh-server putty-tools
sudo useradd -m dmtest
echo 'dmtest:Sesame-42' | sudo chpasswd
# a key in a file, one of PuTTY's (.ppk) and one in an agent
ssh-keygen -q -t ed25519 -N '' -f "$RUNNER_TEMP/key"
: > "$RUNNER_TEMP/empty"
puttygen -t rsa -b 2048 -o "$RUNNER_TEMP/key.ppk" --new-passphrase "$RUNNER_TEMP/empty"
puttygen "$RUNNER_TEMP/key.ppk" -O public-openssh -o "$RUNNER_TEMP/ppk.pub"
ssh-keygen -q -t ecdsa -N '' -f "$RUNNER_TEMP/agentkey"
eval "$(ssh-agent -a "$RUNNER_TEMP/agent.sock")"
ssh-add "$RUNNER_TEMP/agentkey"
unset SSH_AUTH_SOCK
cat "$RUNNER_TEMP/key.pub" "$RUNNER_TEMP/agentkey.pub" "$RUNNER_TEMP/ppk.pub" > "$RUNNER_TEMP/authorized_keys"
sudo install -d -m 700 -o dmtest ~dmtest/.ssh
sudo install -m 600 -o dmtest "$RUNNER_TEMP/authorized_keys" ~dmtest/.ssh/authorized_keys
sudo mkdir -p /run/sshd
sudo /usr/sbin/sshd -p 2222 -o ListenAddress=127.0.0.1 -o PasswordAuthentication=yes
DMODEM_SSH_TEST_KEY="$RUNNER_TEMP/key" DMODEM_SSH_TEST_PPK="$RUNNER_TEMP/key.ppk" \
DMODEM_SSH_TEST_AGENT="$RUNNER_TEMP/agent.sock" build-ssh/dmodemssh_test
DMODEM_SSH_TEST_PPK="$RUNNER_TEMP/key.ppk" swift test --package-path ios/DModemSSH
env:
DMODEM_SSH_TEST: 127.0.0.1:2222:dmtest:Sesame-42
DMODEM_SSH_HOST_BUILD: ${{ github.workspace }}/build-ssh
# (Apple's ways on Linux: the portable fallbacks the iOS build has)
- name: Engine test, Apple's fallbacks
run: |
cmake -S native-test -B build-fallback -G Ninja \
-DCMAKE_CXX_FLAGS=-DDMODEM_PORTABLE_FALLBACKS -DCMAKE_C_FLAGS=-DDMODEM_PORTABLE_FALLBACKS
cmake --build build-fallback
ctest --test-dir build-fallback --output-on-failure
device:
runs-on: ubuntu-24.04
# (a hung test ends here, not at GitHub's 6 hours)
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v5
- name: gawk (proot's build)
uses: ./.github/actions/apt
with:
packages: gawk
- name: KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: SDK packages
uses: ./.github/actions/android-sdk
with:
# (the emulator's system image too: the emulator runner finds it installed)
packages: ndk;${{ env.NDK_VERSION }} cmake;${{ env.CMAKE_VERSION }} platforms;android-37.0 system-images;android-35;google_apis;x86_64
- name: Instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
arch: x86_64
target: google_apis
disable-animations: true
# (the emulator's ABI only: the other three are the build job's)
script: ./gradlew -Pdmodem.abis=x86_64 connectedDebugAndroidTest
- uses: actions/upload-artifact@v7
if: always()
with:
name: device-reports
path: app/build/reports/androidTests