Files
android-client/.github/workflows/build-debug.yml
Diego Romar d277cf686d restart go engine on network change (#97)
* Add network change detector and listeners

* Add network toggle listener to VPNService

* Add unit tests for ConcreteNetworkChangeListener

* Rename NetworkChangeListener to NetworkAvailabilityListener

* Change EngineRunner's Set implementation

From HashSet to ConcurrentHashMap's KeySet,
which is thread-safe.

* Update submodule to the latest tag (v0.59.6)

* Add EngineRestarter to restart the Go engine

* Add LOGTAG to NetworkChangeDetector

* Add some documentation to NetworkToggleListener

* Use EngineRestarter as implementation of NetworkToggleListener

When subscribing to ConcreteNetworkAvailabilityListener

* Replace HashMap usage with ConcurrentHashMap

The availableNetworkTypes HashMap is accessed from network
callback threads without synchronization

* Wrap connectivityManager.unregisterNetworkCallback with try-catch

* Add restart runnable and timeout callback to EngineRestarter

Restart runnable is used as a debouncing mechanism to
prevent concurrent restarts
Timeout callback is to reset the isRestartInProgress flag's
value if the engine takes too long to restart

* Update git submodule reference to latest tag

* Reverse cleanup order on VPNService's onDestroy

Now it disposes of network listener components
before stopping engineRunner

* Ci tests (#99)

Add testing steps for CI

* Remove line break

---------

Co-authored-by: Zoltan Papp <zoltan.pmail@gmail.com>
2025-11-18 18:31:34 -03:00

134 lines
3.5 KiB
YAML

name: build debug
on:
pull_request:
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
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: 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: Run instrumented tests
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
disable-animations: true
script: ./gradlew connectedDebugAndroidTest --no-daemon
- 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