github: run Android integration tests on x86 KVM runners

Arm64 runners have no KVM. Tests head (tailscale-android main, debug),
unstable and latest on Android 13. The emulator image is built once per
run and shared as an artifact; the head APK is cached by commit.

Updates tailscale/tailscale#15660
This commit is contained in:
Kristoffer Dalby authored and Kristoffer Dalby committed 2026-11-20 11:19:11 +01:00
1 parent 9888a7d0f9
commit 6fa78f41bc
3 files changed
+260

No files matched your search

@@ -0,0 +1,93 @@
name: Integration Android Template
on:
workflow_call:
inputs:
version:
description: head, unstable or latest
required: true
type: string
api:
description: Android API level of the emulator image
required: true
type: number
jobs:
test:
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7.0.1
- name: Free disk space
# The emulator image unpacks to >10 GB.
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL
df -h /
- uses: actions/download-artifact@v8.0.2
with:
name: android-build
path: /tmp/artifacts
- uses: actions/download-artifact@v8.0.2
with:
name: android-emulator-${{ inputs.api }}
path: /tmp/artifacts
- uses: actions/download-artifact@v8.0.2
if: inputs.version == 'head'
with:
name: android-head-apk
# Under the repo root, which hi mounts at the same path.
path: ${{ github.workspace }}
- name: Enable 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
ls -l /dev/kvm
- name: Force overlay2 storage driver and load images
run: |
sudo mkdir -p /etc/docker
echo '{"storage-driver":"overlay2"}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
gunzip -c /tmp/artifacts/images.tar.gz | docker load
zstd -dc /tmp/artifacts/android-emulator.tar.zst | docker load
rm /tmp/artifacts/*.tar.*
chmod +x /tmp/artifacts/hi
- name: Resolve APK
id: apk
run: |
case "${{ inputs.version }}" in
head)
echo "url=${GITHUB_WORKSPACE}/tailscale-debug.apk" >> "$GITHUB_OUTPUT"
exit 0 ;;
latest) track=stable ;;
unstable) track=unstable ;;
esac
apk() { curl -fsS "https://pkgs.tailscale.com/$1/?mode=json" | jq -r .APKs.universal; }
file=$(apk "${track}")
echo "url=https://pkgs.tailscale.com/${track}/${file}" >> "$GITHUB_OUTPUT"
echo "Testing ${file}"
# Release APKs share a signing key, so unstable can upgrade latest.
# The unstable APK can lag a stable patch, and Android refuses
# downgrades, so only upgrade from a strictly older stable.
if [ "${{ inputs.version }}" = unstable ]; then
from=$(apk stable)
if printf '%s\n' "${from}" "${file}" | sort -VCu; then
echo "upgrade_from=https://pkgs.tailscale.com/stable/${from}" >> "$GITHUB_OUTPUT"
else
echo "Skipping upgrade: ${from} is not older than ${file}"
fi
fi
- name: Run Android integration tests
env:
HEADSCALE_INTEGRATION_HEADSCALE_IMAGE: headscale:${{ github.sha }}
HEADSCALE_INTEGRATION_ANDROID_IMAGE: android-emulator:${{ github.sha }}-${{ inputs.api }}
HEADSCALE_INTEGRATION_ANDROID_APK: ${{ steps.apk.outputs.url }}
HEADSCALE_INTEGRATION_ANDROID_UPGRADE_FROM: ${{ steps.apk.outputs.upgrade_from }}
run: /tmp/artifacts/hi run "^TestAndroid" --failfast=false --timeout=90m
- uses: actions/upload-artifact@v7.0.2
if: always()
with:
name: android-${{ inputs.version }}-api${{ inputs.api }}-artifacts
path: control_logs/