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
@@ -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