Files
android-client/.github/workflows/build-debug.yml
Zoltan Papp 173fd62e58 ci: fix cache path resolution and screenrecord loop race
The ${{ env.ANDROID_HOME }} expression resolves against workflow-level
env, not the runner's process environment, so the NDK and AVD system-
image cache paths came out empty-prefixed and the saves were dropped
with "Path Validation Error". Hardcode the ubuntu-latest sdk path
(/usr/local/lib/android/sdk) for both.

Also fix the screen recording: touch the sentinel file BEFORE launching
the background loop, otherwise the loop sees no file on its first
iteration and exits immediately, producing zero recordings.
2026-05-10 22:12:10 +02:00

191 lines
5.5 KiB
YAML

name: build debug
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
build-debug:
runs-on: ubuntu-latest
outputs:
apk_path: ${{ steps.build.outputs.apk_path }}
bundle_path: ${{ steps.build.outputs.bundle_path }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get short Git hash
id: version
run: |
SHORT_GIT_SHA=$(git rev-parse --short HEAD)
echo "version_name=ci-${SHORT_GIT_SHA}" >> $GITHUB_OUTPUT
- name: Build Android
id: build
uses: ./.github/actions/build-android
with:
version_name: ${{ steps.version.outputs.version_name }}
build_type: debug
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: debug-artifacts-${{ steps.version.outputs.version_name }}
path: |
${{ steps.build.outputs.apk_path }}
${{ steps.build.outputs.bundle_path }}
retention-days: 3
- name: Upload AAR artifact for tests
uses: actions/upload-artifact@v4
with:
name: netbird-aar
path: ${{ steps.build.outputs.aar_path }}
retention-days: 1
unit-tests:
needs: build-debug
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"
cache: "gradle"
- name: Download AAR artifact
uses: actions/download-artifact@v4
with:
name: netbird-aar
path: gomobile
- name: Run unit tests
run: ./gradlew test --no-daemon
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-test-results
path: |
app/build/reports/tests/
tool/build/reports/tests/
retention-days: 3
instrumented-tests:
needs: build-debug
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 30
environment: instrumentation-test-secrets
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"
cache: "gradle"
- name: Download AAR artifact
uses: actions/download-artifact@v4
with:
name: netbird-aar
path: gomobile
- name: Verify required secrets
env:
INSTRUMENTATION_NB_SETUP_KEY: ${{ secrets.INSTRUMENTATION_NB_SETUP_KEY }}
run: |
if [ -z "$INSTRUMENTATION_NB_SETUP_KEY" ]; then
echo "::error::INSTRUMENTATION_NB_SETUP_KEY repository secret is not configured"
exit 1
fi
- name: Enable KVM group perms
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: AVD cache
id: avd-cache
uses: actions/cache@v4
with:
# ANDROID_HOME is set by the runner image but not visible to
# ${{ env.X }} at expression-eval time; hardcoded to the path on
# ubuntu-latest.
path: |
~/.android/avd/*
~/.android/adb*
/usr/local/lib/android/sdk/system-images/android-30/google_apis/x86_64
key: avd-api30-google_apis-x86_64-pixel_3a-v1
- name: Create AVD snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
target: google_apis
arch: x86_64
profile: pixel_3a
disk-size: 4096M
heap-size: 512M
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
disable-animations: true
script: echo "Generated AVD snapshot for caching."
- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
env:
INSTRUMENTATION_NB_SETUP_KEY: ${{ secrets.INSTRUMENTATION_NB_SETUP_KEY }}
with:
api-level: 30
target: google_apis
arch: x86_64
profile: pixel_3a
disk-size: 4096M
heap-size: 512M
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
disable-animations: true
script: bash .github/scripts/run-instrumented-tests.sh
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: instrumented-test-results
path: |
app/build/reports/androidTests/
tool/build/reports/androidTests/
retention-days: 3
- name: Upload screen recordings
if: always()
uses: actions/upload-artifact@v4
with:
name: instrumented-test-screen-recordings
path: screen-recordings/
if-no-files-found: warn
retention-days: 3