mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-24 22:26:29 +09:00
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:
1 parent
9888a7d0f9
commit
6fa78f41bc
3 files changed
+260
No files matched your search
@@ -38,6 +38,10 @@ workflows:
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'mic92/hestia@v3.1.0'
|
||||
- 'nixos/nix-installer-action@v1.0.0'
|
||||
'.github/workflows/integration-android-template.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/download-artifact@v8.0.2'
|
||||
- 'actions/upload-artifact@v7.0.2'
|
||||
'.github/workflows/integration-test-template.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/download-artifact@v8.0.2'
|
||||
@@ -81,6 +85,13 @@ workflows:
|
||||
- 'mic92/hestia@v3.1.0'
|
||||
- 'nixos/nix-installer-action@v1.0.0'
|
||||
- 'tailscale/github-action@v4.4.0'
|
||||
'.github/workflows/test-integration-android.yaml':
|
||||
- 'actions/cache@v6.1.0'
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/upload-artifact@v7.0.2'
|
||||
- 'dorny/paths-filter@v4.0.3'
|
||||
- 'mic92/hestia@v3.1.0'
|
||||
- 'nixos/nix-installer-action@v1.0.0'
|
||||
'.github/workflows/test-integration.yaml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/upload-artifact@v7.0.2'
|
||||
|
||||
@@ -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/
|
||||
@@ -0,0 +1,156 @@
|
||||
name: integration-android
|
||||
# Runs the official Tailscale Android app in an emulator against headscale.
|
||||
# Separate from the generated arm64 matrix because the emulator needs KVM,
|
||||
# which only the x86_64 hosted runners expose.
|
||||
on: [pull_request]
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
defaults:
|
||||
run:
|
||||
shell: nix develop --fallback --command bash -e {0}
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
files-changed: ${{ steps.changed-files.outputs.files }}
|
||||
android-sha: ${{ steps.versions.outputs.android-sha }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: dorny/paths-filter@v4.0.3
|
||||
with:
|
||||
filters: |
|
||||
files:
|
||||
- '*.nix'
|
||||
- 'go.*'
|
||||
- '**/*.go'
|
||||
- 'integration/**'
|
||||
- 'config-example.yaml'
|
||||
- '.github/workflows/test-integration-android.yaml'
|
||||
- '.github/workflows/integration-android-template.yml'
|
||||
- 'Dockerfile.*'
|
||||
- uses: NixOS/nix-installer-action@v1.0.0
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
- uses: Mic92/hestia@v3.1.0
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
- name: Build binaries
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
run: |
|
||||
go build -o hi ./cmd/hi
|
||||
CGO_ENABLED=0 GOOS=linux go build -o headscale ./cmd/headscale
|
||||
- name: Resolve Android versions
|
||||
id: versions
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
run: |
|
||||
sha=$(git ls-remote https://github.com/tailscale/tailscale-android refs/heads/main | cut -f1)
|
||||
echo "android-sha=${sha}" >> "$GITHUB_OUTPUT"
|
||||
- name: Force overlay2 storage driver
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
run: |
|
||||
sudo mkdir -p /etc/docker
|
||||
echo '{"storage-driver":"overlay2"}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
- name: Build images
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
run: |
|
||||
docker build --file Dockerfile.integration-ci --tag headscale:${{ github.sha }} .
|
||||
docker save headscale:${{ github.sha }} | gzip > images.tar.gz
|
||||
- uses: actions/upload-artifact@v7.0.2
|
||||
if: steps.changed-files.outputs.files == 'true'
|
||||
with:
|
||||
name: android-build
|
||||
path: |
|
||||
hi
|
||||
images.tar.gz
|
||||
retention-days: 3
|
||||
# Built once per run and shared as artifacts, like the headscale image;
|
||||
# one image per Android API level under test (33: Android 13).
|
||||
build-emulator:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build
|
||||
if: needs.build.outputs.files-changed == 'true'
|
||||
strategy:
|
||||
# One flaky download should not cancel the other images.
|
||||
fail-fast: false
|
||||
matrix:
|
||||
api: [33]
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.1
|
||||
- name: Free disk space
|
||||
run: sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL
|
||||
- name: Force overlay2 storage driver
|
||||
run: |
|
||||
sudo mkdir -p /etc/docker
|
||||
echo '{"storage-driver":"overlay2"}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
- name: Build emulator image
|
||||
run: |
|
||||
docker build --file Dockerfile.android-integration \
|
||||
--build-arg ANDROID_API=${{ matrix.api }} \
|
||||
--tag android-emulator:${{ github.sha }}-${{ matrix.api }} .
|
||||
docker save android-emulator:${{ github.sha }}-${{ matrix.api }} | zstd -T0 -3 > android-emulator.tar.zst
|
||||
ls -lh android-emulator.tar.zst
|
||||
- uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: android-emulator-${{ matrix.api }}
|
||||
path: android-emulator.tar.zst
|
||||
compression-level: 0
|
||||
retention-days: 3
|
||||
# Debug build of tailscale-android main, cached by commit: rebuilding it
|
||||
# takes ~10 minutes.
|
||||
build-android-head:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build
|
||||
if: needs.build.outputs.files-changed == 'true'
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/cache@v6.1.0
|
||||
id: cache
|
||||
with:
|
||||
path: tailscale-debug.apk
|
||||
key: tailscale-android-debug-${{ needs.build.outputs.android-sha }}
|
||||
- uses: actions/checkout@v7.0.1
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
with:
|
||||
repository: tailscale/tailscale-android
|
||||
ref: ${{ needs.build.outputs.android-sha }}
|
||||
path: tailscale-android
|
||||
- name: Build debug APK
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
(cd tailscale-android && make docker-tailscale-debug)
|
||||
cp tailscale-android/tailscale-debug.apk .
|
||||
- uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: android-head-apk
|
||||
path: tailscale-debug.apk
|
||||
retention-days: 3
|
||||
android:
|
||||
needs: [build, build-emulator]
|
||||
if: needs.build.outputs.files-changed == 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { version: unstable, api: 33 }
|
||||
- { version: latest, api: 33 }
|
||||
uses: ./.github/workflows/integration-android-template.yml
|
||||
with:
|
||||
version: ${{ matrix.version }}
|
||||
api: ${{ matrix.api }}
|
||||
android-head:
|
||||
needs: [build, build-emulator, build-android-head]
|
||||
if: needs.build.outputs.files-changed == 'true'
|
||||
uses: ./.github/workflows/integration-android-template.yml
|
||||
with:
|
||||
version: head
|
||||
api: 33
|
||||
Reference in new issue
Block a user