Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
vvb2060 committed Oct 20, 2023
1 parent bb39a52 commit 628f68a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 114 deletions.
107 changes: 1 addition & 106 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,105 +1,12 @@
name: Magisk Build
name: Magisk Test

on:
push:
branches: [master]
paths:
- "app/**"
- "native/**"
- "stub/**"
- "buildSrc/**"
- "build.py"
- "gradle.properties"
- ".github/workflows/build.yml"
pull_request:
branches: [master]
workflow_dispatch:

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Check out
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Set up sccache
uses: hendrikmuhs/[email protected]
with:
variant: sccache
key: ${{ runner.os }}-${{ github.sha }}
restore-keys: ${{ runner.os }}
max-size: 10000M

- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
!~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Cache build cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-build-cache-${{ github.sha }}
restore-keys: ${{ runner.os }}-build-cache-

- name: Set up NDK
run: python build.py -v ndk

- name: Build release
run: |
python build.py -vr all
- name: Build debug
run: |
python build.py -v all
- name: Stop gradle daemon
run: ./gradlew --stop

# Only upload artifacts built on Linux
- name: Upload build artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
path: out

- name: Upload mapping and native debug symbols
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-symbols
path: app/build/outputs

test:
name: Test on ${{ matrix.api }}
runs-on: macos-latest
needs: build
strategy:
fail-fast: false
matrix:
Expand All @@ -111,23 +18,11 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ github.sha }}
path: out

- name: AVD test
run: |
brew install coreutils bash
Expand Down
Binary file added out/app-debug.apk
Binary file not shown.
13 changes: 5 additions & 8 deletions scripts/avd_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ avd="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager"
sdk="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
emu_args='-no-window -gpu swiftshader_indirect -read-only -no-snapshot -no-audio -no-boot-anim -show-kernel'
boot_timeout=600
boot_delay=120
emu_pid=

# Should be either 'google_apis' or 'default'
Expand Down Expand Up @@ -110,16 +111,17 @@ test_emu() {

# Install the Magisk app
adb install -r -g out/app-${variant}.apk
adb shell appops set com.topjohnwu.magisk REQUEST_INSTALL_PACKAGES allow

# Use the app to run setup and reboot
adb shell echo "'content call --uri content://com.topjohnwu.magisk.provider --method setup'" \| /system/xbin/su \
sleep $boot_delay
adb shell echo "'content call --uri content://io.github.vvb2060.magisk.provider --method setup'" \| /system/xbin/su \
| tee /dev/fd/2 | grep -q 'result=true'
adb reboot
wait_emu wait_for_boot

# Run app tests
adb shell echo "'content call --uri content://com.topjohnwu.magisk.provider --method test'" \| /system/xbin/su \
sleep $boot_delay
adb shell echo "'content call --uri content://io.github.vvb2060.magisk.provider --method test'" \| /system/xbin/su \
| tee /dev/fd/2 | grep -q 'result=true'
adb shell echo "'su -c id'" \| /system/xbin/su 2000 | tee /dev/fd/2 | grep -q 'uid=0'
}
Expand Down Expand Up @@ -147,11 +149,6 @@ run_test() {
wait $emu_pid
test_emu debug

# Re-patch and test release build
./build.py -r avd_patch -s "$ramdisk"
kill -INT $emu_pid
wait $emu_pid
test_emu release

# Cleanup
kill -INT $emu_pid
Expand Down

0 comments on commit 628f68a

Please sign in to comment.