Files
app/.github/workflows/android.yml
T
Claude 1f2aad5720 iOS: SSH logins by a private key, PuTTY's .ppk imported
The Remote screen keeps one key in the app: chosen from Files
(OpenSSH's, PEM, or PuTTY's .ppk turned into OpenSSH's form with the
same passphrase) or made here (Ed25519), its public key to copy, its
passphrase asked when connecting. SSHShell gains the engine's key
helpers (keyEncrypted, publicKey, exportKey, newKey), tested on Linux,
with a .ppk login against CI's sshd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
2026-11-12 18:11:43 +00:00

324 lines
13 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.
#
# D-Modem 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).
#
# 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
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- 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
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v5
- 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)
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 }}
- 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
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- uses: gradle/actions/setup-gradle@v5
- 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: 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
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- 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
token: ${{ secrets.DMODEM_TOKEN || github.token }}
- 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
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@v7
if: always()
with:
name: device-reports
path: app/build/reports/androidTests