Files
app/.github/workflows/android.yml
T
Claude bd3fa40dfd CI: each commit run once, superseded runs cancelled, time limits, one ABI on the emulator
- Pushes run CI only on main; a branch's commits run as its pull
  request (each PR commit ran everything twice). workflow_dispatch to
  run a branch by hand.
- A newer commit on a pull request cancels the run before it.
- Every job has a time limit: a hung test had a build job running for
  over an hour, with GitHub's default 6 hours to go.
- The emulator job builds x86_64 only (-Pdmodem.abis, new: the ABIs of
  the native code and proot, all four by default); the build job still
  builds all four.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSgB6M9Vp9dEP1haEE
2026-10-30 14:16:54 +00:00

175 lines
5.7 KiB
YAML

# docs: every function documented (tools/doc_check.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.
#
# D-Modem-RE is a private submodule: the DMODEM_TOKEN secret is a token
# that can read it (a fine-grained personal access token with Contents:
# read on D-Modem/D-Modem).
name: Android
# (a branch's commits run once, as its pull request: pushed, only main's)
on:
push:
branches: [main]
pull_request:
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@v4
with:
submodules: recursive
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- name: Every function documented
run: python3 tools/doc_check.py
build:
runs-on: ubuntu-24.04
# (a hung test ends here, not at GitHub's 6 hours)
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v4
- name: SDK packages
run: |
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
"ndk;$NDK_VERSION" "cmake;$CMAKE_VERSION" "platforms;android-37.0"
- name: OpenSSH, PuTTY, mksh (the interop tests), gawk (proot's build)
run: sudo apt-get install -y -q openssh-client openssh-server putty-tools gawk mksh && sudo mkdir -p /run/sshd
- name: Build, unit tests, lint
run: ./gradlew assembleDebug assembleDebugAndroidTest testDebugUnitTest lintDebug :shared:jvmTest :shared:linuxX64Test
# the APK even when a test fails, so a build can still be tried on a phone
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: app-debug
path: app/build/outputs/apk/debug/app-debug.apk
if-no-files-found: ignore
- uses: actions/upload-artifact@v4
if: always()
with:
name: reports
path: |
app/build/reports
app/build/test-results
native:
runs-on: ubuntu-24.04
# (a hung test ends here, not at GitHub's 6 hours)
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- name: Packages
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends cmake ninja-build g++ libssl-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
- uses: swift-actions/setup-swift@v2
with:
swift-version: "6.1"
- name: DModemKit (Swift) on the engine
run: swift test --package-path ios/DModemKit
env:
DMODEM_HOST_BUILD: ${{ github.workspace }}/build-host
# (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@v4
with:
submodules: recursive
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v4
- name: gawk (proot's build)
run: sudo apt-get install -y -q 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
run: |
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
"ndk;$NDK_VERSION" "cmake;$CMAKE_VERSION" "platforms;android-37.0"
- 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@v4
if: always()
with:
name: device-reports
path: app/build/reports/androidTests