Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/android-static-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
- abi: armeabi-v7a # older 32-bit phones
triple: armv7a-linux-androideabi
qemu: qemu-arm-static
- abi: x86_64
triple: x86_64-linux-android
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -89,6 +91,7 @@ jobs:
"$STRIP" rsync

- name: Verify binary
if: matrix.abi != 'x86_64'
shell: bash
run: |
set -euo pipefail
Expand All @@ -102,6 +105,24 @@ jobs:
${{ matrix.qemu }} ./rsync --version | head -3 || \
echo "WARNING: qemu smoke test did not run cleanly (check on a real device)"

- name: Enable hardware acceleration for emulator
if: matrix.abi == 'x86_64'
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: Run Tests
if: matrix.abi == 'x86_64'
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a
with:
api-level: 30
arch: x86_64
script: ./support/android-run-tests
env:
GH_TOKEN: ${{ github.token }}

- name: Package
shell: bash
run: |
Expand Down
53 changes: 53 additions & 0 deletions support/android-run-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh -e

# Copyright © 2026 Matt Robinson
#
# SPDX-License-Identifier: GPL-3.0-or-later

# TODO check that we are configured to build for Android

if ! adb -e get-state > /dev/null 2>&1; then
echo 'Unable to find a running Android emulator' >&2
exit 1
fi

make tls trimslash t_unsafe t_chmod_secure t_secure_relpath wildtest getgroups getfsdev

termuxfiles=/data/user/0/com.termux/files
tempdir=$(mktemp -d)
trap 'rm -rf "$tempdir"' EXIT

# TODO: Wrangle into a single find command?
(
find . -maxdepth 1 -type f -executable -print0
find ./testsuite -maxdepth 1 -type f -print0
) | tar -cf "$tempdir/transfer.tar" --null -T -

adb -e root

if [ -z "$(adb shell pm list packages com.termux)" ]; then
gh release download --repo termux/termux-app --dir "$tempdir" \
--pattern 'termux-app_v*-debug_x86_64.apk'
adb install "$tempdir"/termux-app_*.apk

# Launch Termux so that it bootstraps the environment
adb shell monkey -p com.termux 1

# termux.properties appears to be created at the end of the bootstrapping
until adb shell test -f $termuxfiles/home/.termux/termux.properties; do
sleep 1
done
fi

adb shell run-as com.termux sh -c "'cat > $termuxfiles/home/transfer.tar'" < "$tempdir/transfer.tar"

adb shell run-as com.termux files/usr/bin/bash -le <<EOF
export PATH=$termuxfiles/usr/bin:\$PATH
export LD_PRELOAD=$termuxfiles/usr/lib/libtermux-exec.so
export HOME=$termuxfiles/home
cd
command -v python || pkg install -y --no-install-recommends python
tar -xf transfer.tar
python ./runtests.py -j 8
EOF

Loading